Re: [xsl] Reverse axis, reverse document order, xsl:for-each

Subject: Re: [xsl] Reverse axis, reverse document order, xsl:for-each
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Thu, 28 Feb 2008 12:02:43 +0100
Michael Kay schrieb:
XSLT 1.0 models the result of any path expression as a set of nodes
in no particular order. The semantics of xsl:for-each are that it
processes this set in the order determined by its xsl:sort
specification; the default for this is "document order".

You can reverse this using <xsl:sort select="position()"
order="descending" data-type="number"/>

Now, that's just great! Golden advice!


The way the semantics are modelled changes significantly in XSLT 2.0,
though of course backwards compatiblity has been retained.

Why is this so?

Depends who you ask. Committees move in mysterious ways. It can be hard to work out why a decision was made even if you were present at all the meetings - which in this case, I wasn't.

Mysterious ways. Easy enough to accept. Especially with the above-mentioned position() trick at hand. I won't question further.

And, last question, is there a way to have a pointer
(xsl:variable) to nodes in RDO without resorting to copying
or reconstructing?

Not in 1.0: the type system only allows sets of nodes, not sequences. 2.0 changes that.

Michael Kay

Thanks a lot, Michael!


Michael Ludwig

Current Thread