[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: traversing the tree from an arbitrary node

Subject: Re: traversing the tree from an arbitrary node
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 09:42:19 +0100
traversing a tree node list
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.