RE: [xsl] Finding the following sibling of same type

Subject: RE: [xsl] Finding the following sibling of same type
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Sun, 29 Aug 2004 23:59:50 +0100
>     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]
> locate the element, but I'm having trouble figuring out how to
> find its position within the parent (main).


>     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