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

RE: Generating HTML <link> navigation

Subject: RE: Generating HTML <link> navigation
From: "Mario Caprino" <mariocaprino@xxxxxxxxxxx>
Date: Fri, 22 Oct 2004 14:31:30 +0200
exsl following sibling
I believe I might have scared of any replies by giving to much unecessary details to the specific problem I'm trying to solve, so I wish to try and simplify my question. I hope this may make it easier to understand my difficulty.

I have the current list of elements;
<xsl:variable name="list">
<li id="1" href="one.html" />
<li id="2" href="two.html" />
<li id="3" href="three.html" />
<li id="4" href="four.html" />
</xsl:variable>

<xsl:variable name="id" select="3" />

What I would like to do is extract the two neighbouring elements, the one before and after, a specific element I am looking up. So say I want to look up the element with @id=3, I would then like to retrieve the @href value of id=@2 and id=@4. My actuall problem does not use sequential numbers as @id's, so I can not use arithmetic on the @id value.

I can retrieve the element with a specific @id with the follwing expression:
<xsl:variable name="li" select="exsl:node-set($list)/li[@id=$id]/@href" />

What I don't understand is how to get the neighbouring elements. I believe I have to use the axis following-sibling:: and preceding-sibling::, but I can't come up with the exact XPath expression.
Based on the logic for retrieving a specific element attribute value my current _non_working_ expression for retrieving neighbour values are;


<xsl:variable name="prev" select="exsl:node-set($list)/following-sibling::li[@id=$id][1]/@href" />
<xsl:variable name="next" select="exsl:node-set($list)/preceding-sibling::li[@id=$id][1]/@href" />


What would be the correct way to retrieve the neighbouring element values realtive to one specific element?

Thank you for your help.

Best regards,
Mario Caprino

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar  get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


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.