Re: [xsl] Determining the context node

Subject: Re: [xsl] Determining the context node
From: Evan Lenz <evan@xxxxxxxxxxxx>
Date: Fri, 14 Apr 2006 08:30:23 -0700
I wrote:
contained other elements) you would get nothing.
For all node types except for elements, <xsl:copy/> behaves exactly the same as <xsl:copy-of select="."/>
I should qualify that. If the current node is a root node, then it just instantiates the content of <xsl:copy> (no different than if <xsl:copy> weren't there). That's because you never copy root nodes (they're created automatically).

The way the XSLT 1.0 spec defines <xsl:copy> is that it copies the current node but excludes any children or attributes of the current node.

Effectively, for nodes that never have children or attributes anyway (namely: attributes, text nodes, processing instructions, namespace nodes, and comments), the behavior is the same as <xsl:copy-of select="."/>.

However, for elements and root nodes, <xsl:copy-of select="."/> performs a deep copy, including all attributes (when the current node is an element) and child nodes (when the current node is an element or root node).

Evan

Current Thread