Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
It is an error if the resulting sequence contains an attribute or namespace node.
Finally, the nodes in the sequence are attached to the new document node as its children. Officially, this involves making a deep copy of each node: This is because nodes in the data model are immutable, so you cannot change the parent of an existing node. In practice, making a copy at this stage is very rarely necessary, because in most cases the node being attached has only just been created and will never be used independently of its new parent. The only case where it is necessary is where the result sequence contains references to existing nodes, which can be produced using the
Even in this case, creating new nodes can be avoided if the result tree is to be immediately serialized.
Validating and Annotating the Document
The
validation
and
type
attributes control whether and how the new document is validated. They are available only if you are using a schema-aware processor. As usual, validation has two effects: it triggers a failure if the result document is invalid according to the schema, and it creates type annotations on the nodes in the tree.
The
validation
attribute has the same four values as on other elements:
strip
,
preserve
,
strict
, and
lax
. If the
validation
attribute is not specified, then the default is provided by the
default-validation
attribute on the
strip
.