Thanks. That was exactly what I wanted to do.
At 12:40 14-05-2004, you wrote:
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.
How can I figure that out?
thanks
Morten Andersen
Master of applied mathematics and computer science
Amanuensis
Interest areas:
-e-learning
-software engineering
-applied math
The Maersk Institute of Production technology at Southern Danish
University www.mip.sdu.dk
Campusvej 55
DK-5230 Odense M
Denmark
+45 65 50 36 54
+45 26 83 11 03
Jabber id: hat(_at_)jabber(_dot_)dk
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--
Morten Andersen
Master of applied mathematics and computer science
Amanuensis
Interest areas:
-e-learning
-software engineering
-applied math
The Maersk Institute of Production technology at Southern Danish University
www.mip.sdu.dk
Campusvej 55
DK-5230 Odense M
Denmark
+45 65 50 36 54
+45 26 83 11 03
Jabber id: hat(_at_)jabber(_dot_)dk