Re: [xsl] Document order for keys?

Subject: Re: [xsl] Document order for keys?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 10 Nov 2003 13:28:22 +0000
Hi James,

> When finding the first of a group of keys: key(?ve-by-firstocc?,
> substring(entrydata[3]/text, 1, 1))[1] would this find the first
> node in document order or the order which its puts the list in (e.g.
> if its alphabetical).

In XPath/XSLT 1.0, nodes are collected together in *sets*, which don't
have any inherent order. When you use a positional predicate on a
node-set (as opposed to using a positional predicate within a step),
then the nodes are always counted in document order. So:


always gives you the first node in $node-set in document order, no
matter how the $node-set was generated.

So to answer your question, you will get the first node in document

In XPath/XSLT 2.0, expressions return sequences, which *do* have an
inherent order. Some expressions may return a sequence of nodes in an
order other than document order. However, backwards compatibility has
been retained: calls to XPath/XSLT 1.0 functions such as key() always
return a sequence of nodes in document order.



Jeni Tennison

 XSL-List info and archive:

Current Thread