W
walexand
I have mistake by counting a recursive element. Can someone help me.
XML Sample File
----------------------------------------------------
<content>
<section>
<title>index1</title>
<section>
<title>index11</title>
<section>
<title>index111</title>
<section>
<title>index1111</title>
<section>
<title>index11111</title>
<section>
<title>index11111</title>
</section>
</section>
</section>
</section>
</section>
</section>
</content>
----------------------------------------------------
My XSLT File
----------------------------------------------------
<xsl:template match="section" mode="content">
<xsl:variable name="level" select="count(./parent::section)+1" />
<xsl:element name="h{$level}">
<xsl:value-of select="title" />
</xsl:element>
<xsl:if test="./section">
<xsl:apply-templates select="section" mode="full"/>
</xsl:if>
</xsl:template>
----------------------------------------------------
I want to count automatic an index from the element "title",
To get this:
<h1>...
<h2>...
<h3>...
<h4>...
<h5>...
<h6>...
but my current Output looks like this
----------------------------------------------------
<h1>index1</h1>
<h2>index11</h2>
<h2>index111</h2>
<h2>index1111</h2>
<h2>index11111</h2>
<h2>index11111</h2>
XML Sample File
----------------------------------------------------
<content>
<section>
<title>index1</title>
<section>
<title>index11</title>
<section>
<title>index111</title>
<section>
<title>index1111</title>
<section>
<title>index11111</title>
<section>
<title>index11111</title>
</section>
</section>
</section>
</section>
</section>
</section>
</content>
----------------------------------------------------
My XSLT File
----------------------------------------------------
<xsl:template match="section" mode="content">
<xsl:variable name="level" select="count(./parent::section)+1" />
<xsl:element name="h{$level}">
<xsl:value-of select="title" />
</xsl:element>
<xsl:if test="./section">
<xsl:apply-templates select="section" mode="full"/>
</xsl:if>
</xsl:template>
----------------------------------------------------
I want to count automatic an index from the element "title",
To get this:
<h1>...
<h2>...
<h3>...
<h4>...
<h5>...
<h6>...
but my current Output looks like this
----------------------------------------------------
<h1>index1</h1>
<h2>index11</h2>
<h2>index111</h2>
<h2>index1111</h2>
<h2>index11111</h2>
<h2>index11111</h2>