Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
type optional | Lexical QName | Identifies a type declaration (either a built-in type, or a user-defined type imported from a schema) against which copied nodes are to be validated. |
Content
An optional sequence constructor, which is used only if the item being copied is a document node or an element.
Effect
The action depends on the kind of context item, as follows:
Item kind | Action |
atomic value | Adds the atomic value to the result sequence. (Atomic values have no identity, so there is no distinction between the original value and a copy of the value.) |
document | A new document node is added to the result sequence. The sequence constructor is evaluated to provide the content for the document node. This works in the same way as the content of an copy-namespaces , inherit-namespaces , and use-attribute-sets are ignored. The type and validation attributes have the same effect as with |
element | An element node is added to the result sequence, as if by a call on copy-namespaces=“no” is specified. The namespace nodes are also copied to the new children of the element, unless inherit-namespaces=“no” is specified. The use-attribute-sets attribute and the contained sequence constructor are then evaluated to create the attributes and children of the new element in the same way as for type and validation attributes, and works exactly as for validation=“preserve” does not cause the type annotation of the original element to be retained: This is not feasible, because the content of the element is not being copied. |
text | A new text node is added to the result sequence, with the same string value as the context node. The attributes of the |
attribute | A new attribute node is added to the result sequence, as if by a call on copy-namespaces , inherit-namespaces , and use-attribute-sets are ignored. The local name, namespace URI, and string value of the output attribute are guaranteed to be the same as the original, and the prefix will be the same unless there is a conflict (for example, if two attributes added to the same element use the same prefix to refer to different namespace URIs). With a schema-aware processor, the new attribute may be validated and may acquire a type annotation: This depends on the values of the type and validation attributes, and works exactly as for |
processing instruction | A processing instruction node is added to the result sequence, with the same name and value (target and data in XML terminology) as the context node. The attributes of the |
comment | A comment node is added to the result sequence, with the same content as the context node. The attributes of the |
namespace | The namespace node is copied to the result sequence. The new namespace node will have the same name and value (that is, the same namespace prefix and URI) as the original. The attributes of the |
Usage
The main use of
and
are used within textual data in the source and are to be copied unchanged to an HTML output document.
Although
This is sometimes referred to as the
identity template
. This template rule matches any node except a namespace or document node. This is because
@*
matches any attribute node, and
node()
, which is short for
child::node()
, matches any node that is allowed to be the child of something (that is, an element node, text node, comment, or processing instruction). Once this template rule is applied to a node, it copies that node, and if it is an element node, it applies itself to its attributes and child nodes—on the assumption that there is no other template rule with
mode=“copy”
that has a higher priority.An easier way of doing a deep copy is to use