[xsl] node depth

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

   <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 id='30'>
         <label lang='es_ES'><![CDATA[Agenda del Alcalde]]></label>
     <section id='15'>
      <label lang='es_ES'
      <section id='46'>
        <label lang='es_ES'><![CDATA[Programa de Vacaciones]]></label>
      <section id='47'>
        <label lang='es_ES'><![CDATA[Centros de Dia]]></label>

The XSLT template is the following:

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


Current Thread