Forum Moderators: open

Message Too Old, No Replies

xsl:if current node is an ancestor of $mynode

XPATH question

         

httpwebwitch

6:21 pm on Sep 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've set a variable, $mynode. it's a node deep down in the tree. I found it by doing this:

<xsl:variable select="//node[@id=$myval]" name="mynode"></xsl:variable>

As I iterate through some child nodes in another template, I want to know if the current node is an ancestor of $mynode.

it'll be some use of ancestor-or-self:: or decendent::

I've been hacking away at this Xpath for over an hour to find the right condition, but it's eluding me.

help!

httpwebwitch

6:23 pm on Sep 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



never mind
within moments of posting my question, I found it:

<xsl:if test="descendant::node[@id = $myval]">

I was testing with ancestor:: instead of descendant::