| Subject: Re: [xsl] node depth From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Fri, 07 Sep 2007 13:42:15 +0200 | 
Is there any way to find out the depth of the current element in a
recursive template? The XML is the following:
<xsl:template match="section">
       <li>
           <xsl:apply-templates select="label" />
       </li>
       <ul>
           <xsl:apply-templates select="section" />
       </ul>
 </xsl:template> <xsl:template match="label">
    <xsl:apply-templates select="@href[@href != '']" />
    <xsl:value-of select=".[not(@href) | normalize-space(@href) = '']" />
 </xsl:template>  <xsl:template match="label/@href">
     <a href="{.}"><xsl:value-of select="label" /></a>
  </xsl:template>  <xsl:template match="label[.!='']/@href">
     <a href="{.}"><xsl:value-of select="label" /></a>
  </xsl:template>
<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 | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] node depth, Bernie | Thread | Re: [xsl] node depth, Bernie | 
| RE: [xsl] Unable to use count funct, Yaswanth | Date | Re: [xsl] Unable to use count funct, Abel Braaksma | 
| Month |