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

Re: preceding-sibling inside for-each appears to fail

Subject: Re: preceding-sibling inside for-each appears to fail
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Sun, 09 Feb 2003 22:35:40 +0000
preceding sibling attribute
Hi Ted,

Ted Stresen-Reuter wrote:
...

<p>preceding sibling = <xsl:value-of select="preceding-sibling::attribute/@name" /></p>

...


As you can see, following-sibling successfully returns the following sibling, but preceding-sibling always returns the first node rather than the preceding-sibling node.

You need to remember two things here. First, XPath expressions normally return node-sets. Second, node-sets are processed in document order. So your select expression is returning the first member of the set "preceding-sibling::attribute/@name", which is always the first in document order. But if you put a positional predicate in as part of an XPath step then that is applied in the order of the current axis, so try


<p>preceding sibling = <xsl:value-of select="preceding-sibling::attribute[1]/@name" /></p>

Hope this helps -

Francis.


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.