xsl:copy
Causes the current XML node in the source document to be copied to the output. The actual effect depends on whether the node is an element, an attribute, or a text node.
Category: instruction
Content:
sequence-constructor
Permitted parent elements:
any XSLT element whose content model is sequence
constructor; any literal result element
Attributes
|
|
New in XSLT 3.0. Allows a node other than the context node to be copied. This is useful when the instruction appears inside xsl:function. |
|
|
|
|
|
|
|
|
Attributes of a generated element can be defined by reference to named attribute sets, provided as a white-space-separated list. They are applied in the order given: if the same attribute is generated more than once, the later value always takes precedence. |
|
|
|
|
|
|
|
|
New in XSLT 3.0, motivated by streaming.
Expression which defines an alternative result in the case where the copied
element would otherwise be empty. The most likely value is
|
Details
When xsl:copy
is applied to an element node, the start and end
element tags are copied; the attributes, character content and child elements
are copied only if xsl:apply-templates is used within xsl:copy
.
Examples
A template that copies the input element to the output, together with all its child elements, character content, and attributes:
<xsl:template match="*|text()|@*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>