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

RE: Finding the following sibling of same type

Subject: RE: Finding the following sibling of same type
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Sun, 29 Aug 2004 23:59:50 +0100
xpath first following sibling
>     If I am on the first "first" element node, how can I write an
> XPath expression to get the position of the second instance of the
> "first" element? I can write
> 
>     followin-sibling::first[position() = 1]
> 
> ....to locate the element, but I'm having trouble figuring out how to
> find its position within the parent (main).

count(following-sibling::first[1]/preceding-sibling::*)+1

> 
>     Actually, the real problem is for me to write an XPath expression
> that will select all children of "main" from the first "first" upto
> (but exluding) the next "first". 

<xsl:variable name="first-first" select="first[1]"/>
<xsl:... select="$first-first/following-sibling::*[
   preceding-sibling::first[1] is $first-first]"/>

"is" is an XPath 2.0 operator to test node-identity; in XPath 1.0 replace "A
is B" by "generate-id(A) = generate-id(B)".

Michael Kay

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.