[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Axis order and variables

Subject: Re: Axis order and variables
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 23 May 2003 15:54:08 +0100
which variable which axis

> I don't get it. I understood that a nodeset had an inherent ordering 
> which was established at the time we do the select on the nodeset...

No if it had an inherent ordering it would be called a list or a
sequence not a set. Note Xpath 2 does use sequences as primitive.
Xpath 1 uses sets. "Node set" is not a tye in Xpath 2 drafts.

 <xsl:variable name="x" select="ancestor::x"/>
 <xsl:value-of select="$x[1]/@n"/>

is equivalent to

<xsl:value-of select="(ancestor::x)[1]/@n"/>

the expression (ancestor::x) returns the set of all ancestors,
the predicate 1 takes teh first element of that set in doc order,
but note the ordering is a feature of teh [1] operation not of the
result of the (ancestor::x) expression.

> If we then select nodes from within that nodeset using 
> another axis, we go back to the document ordering associated with that 
> axis. 
> 
> Thanks for the clarification (hope I understand correctly now though).

No. you are making it too complicated, there is no "going back"
sets are unordered.

Your intuition may have expected an ordering for 
 <xsl:variable name="x" select="ancestor::x"/>
but what would your intuition say for
         <xsl:variable name="x" select="ancestor::x|key('a','b')|child::z"/>
         <xsl:value-of select="$x[1]/@n"/>
?

Fortunately you don't have to have to guess this as the answer is that
select="ancestor::x|key('a','b')|child::z" returns an unordered set of
all of the selected nodes.

David



________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. 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
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.