This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: traversing the tree from an arbitrary node
- To: "Chris d'Aquin" <CDAquin at questia dot com>
- Subject: Re: [xsl] traversing the tree from an arbitrary node
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Thu, 16 Aug 2001 09:42:19 +0100
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <OF5B6B628D.A52A85BD-ON86256AA9.0066F930@questia.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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