just use the ancestor::* axis
<xsl:for-each select="ancestor::*">
<xsl:value-of select="name()"/>
</xsl:for-each/>
I bet you are kicking yourself...
cheers
andrew
-----Original Message-----
From: jm3 [mailto:lists(_at_)jm3(_dot_)net]
Sent: 23 October 2002 15:22
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] backwards tree-traversal algorithm?
hello, having some trouble making this work: within my stylesheet,
i have selected a node somewhere in the midst of the document tree,
several nested elements deep. what i would like to do is, given
this node N (at arbitrary depth), walk *back* up the document tree
hierarchy, element by element, printing the successive parent elements
(technically, printing each element's "name" @ribute).
so with node N being <c> and the following document:
<root>
<a>
<b>
<c/>
</b>
<d/>
<e/>
</a>
</root>
i want to print: b, a, root.
my pseudocode was along the lines of:
current = node
while current != root
current = ../
print current/@name
seems simple.
recursive templates seemed like the way to do this in xsl, but i
can't get this to do anything, apparently because the processor i'm
using (sablotron 0.90) won't let me use XPath on the node set i am
passing with call-template (as a param) because it's "not a node-set".
so i guess i have two questions:
1. what is the best algorithm/approach to walk back up the
parent:: tree, printing each element?
2. does sabcmd not have a node-set() function? is this what's
stopping me?
(if it helps, the stylesheet will know what depth level the current
node is at, and the unique @name attribute of each parent element.)
jm3 / john manoogian III / http://jm3.net / jm3(_at_)jm3(_dot_)net
> > > http://jm3.net/linkworld < < <
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.404 / Virus Database: 228 - Release Date: 15/10/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.404 / Virus Database: 228 - Release Date: 15/10/2002
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list