[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

node depth

Subject: node depth
From: Bernie <berniecc@xxxxxxxxx>
Date: Fri, 7 Sep 2007 13:26:28 +0200
 node depth
Is there any way to find out the depth of the current element in a
recursive template? The XML is the following:

<webmap>
   <section id='1'>
     <section id='3'>
       <label lang='es_ES'><![CDATA[Tu Ayuntamiento]]></label>
       <section id='29'>
         <label lang='es_ES'><![CDATA[El Alcalde]]></label>
       </section>
       <section id='30'>
         <label lang='es_ES'><![CDATA[Agenda del Alcalde]]></label>
       </section>
     </section>
     <section id='15'>
      <label lang='es_ES'
href='GenteMayor/GenteMayor_es_ES.html'><![CDATA[Gente
Mayor]]></label>
      <section id='46'>
        <label lang='es_ES'><![CDATA[Programa de Vacaciones]]></label>
      </section>
      <section id='47'>
        <label lang='es_ES'><![CDATA[Centros de Dia]]></label>
      </section>
    </section>
  </section>
<webmap>

The XSLT template is the following:

<xsl:template match="section">
    <xsl:if test="label!=''">
    	<li>
        <xsl:choose>
          <xsl:when test="label/@href!=''">
            <a>
        			<xsl:attribute name="href">
        				<xsl:value-of select="label/@href" />
        			</xsl:attribute>
      			  <xsl:value-of select="label" />
      		  </a>
          </xsl:when>
          <xsl:otherwise>
     			  <xsl:value-of select="label" />
          </xsl:otherwise>
        </xsl:choose>
    	</li>
    	<ul>
    		<xsl:apply-templates select="section" />
    	</ul>
    </xsl:if>
  </xsl:template>
-----------------------------

Bernie.

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.