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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format