|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: backwards tree-traversal algorithm?
This isn't quite what you want, but it may help...
Define this template first: <xsl:template match="*" mode="whereAmI"> <xsl:param name="location"/> <xsl:choose> <xsl:when test="name(.) = 'root'">Location = <xsl:value-of select="name(.)"/> / <xsl:value-of select="$location"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="parent::*" mode="whereAmI"> <xsl:with-param name="location"><xsl:value-of select="name(.)"/><xsl:if test="string($location) != ''"> / <xsl:value-of select="$location"/></xsl:if></xsl:with-param> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </xsl:template> Then, when you need to know "where you are", call this one. <xsl:apply-templates select="." mode="whereAmI"/> It should return *if* 'inside' <c/> (with your data)... "Location = root / a / b / c" Cheers, Steve On 10/23/02 10:22 AM, jm3 wrote:: 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). 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
|

Cart








