|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Iterating over all the Ancestors
Bix,
Walking up the tree is easy: <xsl:for-each select="ancestor::*"> walks all the elements up to the root (but not including it: it's not an element). You can include the context node itself by using the ancestor-or-self:: axix. So in your case <xsl:template match="data">
<xsl:for-each select="ancestor-or-self::*">
<xsl:if test="ancestor::*">
<!-- if the ancestor element has an ancestor element, it's not
first: prepend it with some formatting -->
<xsl:text> -> </xsl:text>
</xsl:if>
<xsl:value-of select="text"/>
<!-- reports the value of the <text> element child, which is our label -->
</xsl:for-each>
</xsl:template>By default, a for-each traverses in document order, so this will go top-down. (There are ways to tweak it if you want something different.) I hope this helps, Wendell At 01:19 PM 11/26/2002, you wrote: I have been trying to figure out a way of iterating over the parent nodes of a particular child all the way to the root of the tree. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== 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








