|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: how to figure out what level a node is on
Hi,
It is hard to understand your problem from your post, in general will help if you can add a sample to show your data, what XSLT code you already tried, if any, and the expected output. I will take a guess and consider that you are interested in the level of imbrication of a given element inside the document. In that case you can just count the number of ancestors. xml: <?xml version="1.0" encoding="UTF-8"?>
<menu>
<item name="topMenu">
<item name="subMenu">
<item name="subSubMenu">
</item>
</item>
</item>
</menu>stylesheet: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:apply-templates select="//item"/> </xsl:template> <xsl:template match="item"> [<xsl:value-of select="@name"/>-<xsl:value-of select="count(ancestor::*)"/>] </xsl:template> </xsl:stylesheet> result: [topMenu-1] [subMenu-2] [subSubMenu-3] Hope that helps, George ----------------------------------------------- George Cristian Bina <oXygen/> XML Editor - http://www.oxygenxml.com Morten Andersen wrote: I'm building a menu using xslt. Therefore I need to figure out what level an item is on.
|
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








