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

Re: preceding-sibling reversed ?

Subject: Re: preceding-sibling reversed ?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 29 Aug 2002 12:39:49 +0100
preceding sibling first node
> I'm still a bit perplexed. 
that's usually the way with my answers until Jeni re-words them (I don't
know why I bother:-)

> If you evaluate a nodeset in a string context
> then only the first
> node in the nodeset is considered. 

note that node sets are sets so unordered.

If you evaluate in a string context then the first node in document
order is taken.

However within a step position referes to the order in the direction
specified by the axis that started the step.

> following-sibling::div[@class = 'slide']/@id is the same as
> following-sibling::div[@class = 'slide'][1]/@id.

these are the same, yes.

On the other hand, 
> 	preceding-sibling::div[@class = 'slide']/@id is the same as
> 	preceding-sibling::div[@class = 'slide'][last()]/@id.

yes that [last()] is part of a step using a reverse axis.
the "first node" semantics is the same as using (...)[1]

preceding-sibling::div[@class = 'slide']/@id 
if used as a string selects more than one node (potentially)
so it is first evaluated as

(preceding-sibling::div[@class = 'slide']/@id)[1]

which takes the first node from teh set in document order.

in this case, that happens to be the same as

(preceding-sibling::div[@class = 'slide'])[1]/@id

as every div which has a class=slide also has an id attribute, so taking
the first id attribute is the same as taking the first div and then
taking its id.

with the () the [1] is acting on the node set, so uses document order,
but in
preceding-sibling::div[@class = 'slide'][1]
th e[1] is part of the step and so referes to the order specified by the
axis of the step. Note that [] appearing in steps and [] being
predicates on node sets are in fact completely separate parts of teh
Xpath grammar, they just happen to use the same concrete syntax.

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 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.