Copy-namespaces declaration

The copy-namespaces declaration in the query prolog sets the policy for the query. The copy-namespaces policy controls how the namespace bindings are assigned when an existing element node is copied by an element constructor or document node constructor.

The setting preserve specifies that all in-scope-namespaces of the original element are retained in the new copy. The copied node preserves its default namespace or absence of a default namespace. The setting no-preserve specifies that unreferenced in-scope-namespaces of the original element are not retained. The setting inherit specifies that the copied node inherits in-scope namespaces from the constructed node. In case of a conflict, the namespace bindings that were preserved from the original node take precedence.

A copy-namespaces declaration that specifies values other than preserve or no-preserve and inherit results in an error. The prolog can contain only one copy-namespaces declaration for a query.

Syntax

Read syntax diagramSkip visual syntax diagramdeclarecopy-namespaces preserveno-preserve ,inherit;
preserve
Specifies that all in-scope namespaces of the original element are retained in the new copy.
no-preserve
Specifies that unreferenced in-scope namespaces of the original element are not retained in the new copy.
inherit
Specifies that the copied node inherits in-scope namespaces from the constructed node.

Example

The following copy-namespace declaration is valid, but does not change the default behavior for element construction:

declare copy-namespaces preserve, inherit;