$v2-2-1/ancestor::li[last()]/text()
where $v2-2-1 is another name for your $id
Cheers,
Dimitre.
On Wed, 27 Oct 2004 18:30:20 +0200, Mario Caprino
<mariocaprino(_at_)hotmail(_dot_)com> wrote:
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[(_at_)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
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--