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

Finding the following sibling of same type

Subject: Finding the following sibling of same type
From: Kenneth Stephen <marvin.the.cynical.robot@xxxxxxxxx>
Date: Sun, 29 Aug 2004 13:06:42 -0500
finding a sibling
Hi,

    I have an XML document that has the following sequence in it :

<main>
    <first>.....</first>
    <second>....</second>
    <third>....</third>
    <second>...</second>
    <third>....</third>
    <first>....</first>
    <second>....</second>
</main>

    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). The trouble appears to be
that if I put the above XPath expression with in the select of a
for-each, then, within the context of that for-each, the position of
the next "first" node is = 1. Somehow, I need to figure out how to
shift the context to the parent node, but an xsl:for-each select="../"
doesnt seem to solve my problem, because then I dont know how to test
for node equality between the children of the parent and the node that
I'm interested in. Any ideas?

    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". Hence my desire to locate the
position of the next "first".

Thanks,
Kenneth

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.