[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

Subject: Re: how to figure out what level a node is on
From: Morten Andersen <mortena@xxxxxxxxxx>
Date: Fri, 14 May 2004 12:38:54 +0200
morten andersen odense
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@xxxxxxxxx

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@xxxxxxxxx


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.