Re: [xsl] Identity Transform

Subject: Re: [xsl] Identity Transform
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 7 Nov 2005 11:41:30 +0000
Hi Christian,

> Has this something to do with document traversal order, i.e. while
> building the list of selected items using "node()|@*", the attribute
> nodes (satisfying the expression) are found first and are therefore
> added first to the list of items to be copied, in consequence
> satisfying the "attribute-before-children" requirement?

Close. In XSLT 1.0, whenever you process a node-set (using
<xsl:apply-templates> or <xsl:for-each>, for example), those nodes are
processed in *document order*. The attributes of an element always
come before the children of the element, so whether you use
"@*|node()" or "node()|@*", you always copy the attributes first.

In XSLT 2.0 things are slightly different, in that each XPath 2.0
expression generates a sequence of nodes rather than a (by definition,
unordered) set of nodes. However, when you use the union operator ("|"
or "union"), the nodes in the resulting sequence are always sorted
into document order, so again "@*|node()" and "node()|@*" return the
same sequence of nodes.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread