Re: [Fwd: RE: [xsl] Need help OR'ing in XPATH.]

Subject: Re: [Fwd: RE: [xsl] Need help OR'ing in XPATH.]
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 22 Mar 2006 12:50:10 GMT
> Thanks--it worked, I used the first one.  As for the second, I saw the | 
> operator earlier but was concerned that it won't guarantee that it 
> *would* be in document order.  The XPath spec seems to be vague on 
> this[1] -- i.e., whether I can guarantee document order with it, *or* it 
> just so happens that they way the major XSLT implementations implement 
> this operator result in it being in document order.

A node set (as generated by a path expression or the | operator) _never_
specifies an order in xpath1(that's why it is called a set rather than a
list or a sequence). However XSLT1 operations like xsl:apply-templates
and xsl:for-each always (effectively) process teh nodes in the selected node
set in documet order so

<xsl:for-each select="a|b">

is guaranteed to output the result of b before the result of a if b is
earlier than a in document order.

This node set model is dropped in XPath2 which uses ordered sequences as
a basic datatype.

So in XSLT2 <xsl:for-each select=" processes the _sequence_ supplied in
the select attribute in the order of items in the sequence and in xpath2
the union operator | is defined to merge the two sequences  and sort
them into document order.

So the end result in  xslt2 is the same, teh ordering is guaranteed.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread