[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: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 23 May 2003 18:42:59 +0100
axis order sequence
> 
> Consider the following XML
> 
>   <x n="1">
>     <x n="2">
>       <test/>
>     </x>
>   </x>
> 
> and transform it via the following XSLT:
> 
>         <xsl:variable name="x" select="ancestor::x"/>
>         <xsl:value-of select="$x[1]/@n"/>
> 
> What is the expected result? Is it "1" or "2"?

It is "1".
> 
> I failed to find a definite answer in W3C specs.

The language used to specify this in the W3C XPath 1.0 spec is
notoriously obscure.

Section 2.4 states that a predicate filters a node-set with respect to
an axis.

The construct $x[1] is a FilterExpr, described in section 3.3. This
states "The predicate filters the expression with respect to the child
axis". 

The child axis is a forwards axis. Section 2.4 tells you that when a
node-set is filtered with respect to a forwards axis, the proximity
position of each node is its position in the sequence in forwards
document order. $x[1] selects the node whose proximity position is 1,
that is, the one that is first in document order.

The mention of the "child axis" is a complete red herring here, it's
just a device to ensure that $x is filtered in forwards document order.

> 
> I have run into this question because the result of
> MSXML 3.0 and Saxon differs from that of MSXML 4.0:
> the former give "1", while the latter gives "2".
> Who is right? Or they are both right?
> 
It looks as if MSXML4 has a bug.

Michael Kay


 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.