RE: [xsl] Generating HTML <link> navigation

Subject: RE: [xsl] Generating HTML <link> navigation
From: "Mario Caprino" <mariocaprino@xxxxxxxxxxx>
Date: Fri, 22 Oct 2004 14:31:30 +0200
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