Skip to content

xsl:copy-of

Copies the value obtained by evaluating the mandatory select attribute. It makes an exact copy.

Available in XSLT 1.0 and later versions. Available in all Saxon editions.

  • Category: instruction
  • Content: none
  • Permitted parent elements: any XSLT element whose content model is sequence-constructor; any literal result element

Attributes

select
expression
Value to be copied (which may be any sequence of nodes, atomic values, and/or function items), given by an expression. If this expression is a string, a number, or a boolean, the effect is the same as using xsl:sequence.
copy-accumulators?
boolean
New in XSLT 3.0. Used to copy the pre-descent and post-descent values of accumulators on source nodes to the new copies.
copy-namespaces?
boolean
Controls whether the in-scope namespaces of any element nodes copied by this instruction are automatically copied to the result. The default is yes. If the value is no, then namespaces will only be copied if they are actually used in the names of elements or attributes. This allows you, for example, to copy the contents of a SOAP message without copying the namespaces declared in its envelope.
type?
eqname
validation?
"strict" | "lax" | "preserve" | "strip"

Notes on the Saxon implementation

Earlier releases of Saxon supported an attribute saxon:read-once to control streaming behaviour. This is now superseded by the streaming features of XSLT 3.0; an error is reported if the attribute is used.

Details

Making a deep copy of an element is particularly useful during streaming. For this reason XSLT 3.0 introduces an equivalent function, copy-of(). For example one can write <xsl:for-each select="employee/copy-of()"> which processes a sequence of copies of the selected <employee> elements; the significance of using copies is that streaming constraints do not apply, since each <employee> element will be represented as a tree in memory, discarded as soon as that element has been processed.

See also

Comments