[xsl] Retrieving top section from a navigation tree

Subject: [xsl] Retrieving top section from a navigation tree
From: "Mario Caprino" <mariocaprino@xxxxxxxxxxx>
Date: Wed, 27 Oct 2004 18:30:20 +0200
Hi,

I have a navigation tree and would like to find out which main navigation section I am located underneath when i have the unique id of the page I am viewing.

Here's an example tree;
<xsl:variable name="ul">
<ul id="menu">
<li id="1">one</li>
<li id="2">two
 <ul>
  <li id="2-1">two-one</li>
  <li id="2-2">two-two
   <ul>
    <li id="2-2-1">two-two-one</li>
   </ul>
  </li>
 </ul>
</li>
<li id="3">three</li>
</ul>
</xsl:variable>

<xsl:variable name="id" select=="'2-2-1'" />

Say I am viewing the page "2-2-1", I would now like to write an xpath expression that retrieves the name (text element) of the containing top li element. In this case the name would be "two".

I have tried to look at the problem from differen perspectives;
- one is to find the top <li> elements and filter out any that does not contain an <li> element that matches the page $id
- the other is to find the <li> element with the specific @id, and traverse outwards to find the containing top <li> element


Sadly I do not understand how I would retrieve the name "two" using any of these methods.

My failed xpath expression so far looks like this;
exsl:node-set($ul)/ul[@id='menu']/li[//li/@id=$id]/text()

Thank you for your help.

Best regards,
Mario Caprino

_________________________________________________________________
MSN Messenger http://www.msn.no/computing/messenger Den raskeste veien mellom deg og dine venner


Current Thread