xsl-list
[Top] [All Lists]

[xsl] node depth

2007-09-07 04:26:56
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.

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>