This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: traversing the tree from an arbitrary node


Hi Chris,

> I am using XT on a Windows NT platform. When I run this line, I get
> the error message of "expected node test":
>
>        <xsl:when test="id('$id')/from-ancestors(*[position()
> =$elementDepth][self::rootTag])">
>
> $id contains the ID of the tag I want, and $elementDepth contains
> the number of steps down from the <rootTag> I expect to be. What I
> am trying to say for that node test is "from the node that has this
> id, go up $elementDepth ancestor nodes and see if that node is
> <rootTag>." What am I doing wrong?

You're basically there except that you need the ancestor axis rather
than this from-ancestor() function. Also, I think you want to pass the
id() function the value of the variable $id rather than the string
'$id'. So the path you need is:

  id($id)/ancestor::*[position() = $elementDepth][self::rootTag]

or (because numbers in predicates are tested against the position of
the node in the node list):

  id($id)/ancestor::*[number($elementDepth)][self::rootTag]

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]