xsl:copy-of
Deep copy of the nodes selected by an XPath expression.
<xsl:copy-of select="$fragment"/>For nodes, xsl:copy-of produces a complete copy including descendants, attributes and text. For atomic values, it adds them to the result sequence (the same as xsl:sequence). It is typically faster than running xsl:apply-templates over the same nodes when no transformation is needed.
Attributes
| Attribute | Description |
|---|---|
select |
XPath expression selecting nodes (or values) to copy. Required. |
copy-namespaces |
yes (default) or no — whether to copy in-scope namespaces. |
Example
Embedding a previously built fragment:
<xsl:variable name="header">
<h1>Title</h1>
<p>Subtitle</p>
</xsl:variable>
<page>
<xsl:copy-of select="$header"/>
<xsl:apply-templates/>
</page>