<xsl:copy-of select=”expression” />
The xsl:copy-of element inserts a duplicate copy of a node set or tree fragment into the output. Perhaps the most important aspect of this element is that it allows you to insert multiple copies of the same set of nodes into different places in the output. For example, you may wish to repeat a page header.
When a node set is copied, the nodes will be copied into the output in their order of occurrence in the source (this is referred to as document order). Each node and all associated attribute nodes, namespace nodes, children and descendants are copied. In other words, it is a complete, unabridged copy of the set.
When a root node is copied, all of the children and descendants are copied, but not the root node itself since there can only be one root. When a tree fragment is copied, it is copied exactly to the output.
For all other circumstances, the xsl:copy-of element behaves exactly like the xsl:value-of element. The value being copied is converted into a string for display in the output.
In contrast, the xsl:copy element copies the current node in the source document to the output. The copy has the same name, namespace, and type as the original node, but any attributes, children, and other descendants are not copied.
This is a self-closing element and it cannot contain any child elements or any content.
The mandatory select attribute is an expression that identifies which nodes are to be copied.
Scroll to Top