Commit 7dc74a45 authored by bperraud's avatar bperraud

Refacto of ToC generation xsl code with recursive handle

parent b50d4159
......@@ -21,7 +21,9 @@
<xsl:apply-templates select="node()|@*"/>
<xsl:call-template name="toc"/>
<xsl:call-template name="toc">
<xsl:with-param name="toclevel" select="2"/>
</xsl:call-template>
</body>
</xsl:template>
......@@ -31,81 +33,55 @@
<!-- Gestion de la table des matières -->
<xsl:template name="toc">
<xsl:if test="count(//h2) &gt; 0">
<h2 class="nocount toc-title">Table des matières</h2>
<ul class="toc level2">
<xsl:for-each select="//h2">
<li>
<xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h3) &gt; 0">
<ul class="toc level3">
<xsl:for-each select="..//h3">
<li>
<xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h4) &gt; 0">
<ul class="toc level4">
<xsl:for-each select="..//h4">
<li>
<xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h5) &gt; 0">
<ul class="toc level5">
<xsl:for-each select="..//h5">
<li>
<xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h6) &gt; 0">
<ul class="toc level6">
<xsl:for-each select="..//h6">
<li>
<xsl:call-template name="toc-a"/>
<xsl:template name="toc">
</li>
</xsl:for-each>
</ul>
<xsl:param name="toclevel"/>
<xsl:variable name="hnlevel" select="concat('h', $toclevel)"/>
</xsl:if>
<xsl:choose>
</li>
</xsl:for-each>
</ul>
<xsl:when test="$toclevel = 2">
<xsl:if test="count(//*[local-name()=$hnlevel]) &gt; 0">
<h2 class="nocount toc-title">Table des matières</h2>
</xsl:if>
<ul class="toc level2">
<xsl:for-each select="//*[local-name()=$hnlevel]">
<li>
<xsl:call-template name="toc-a"/>
</li>
</xsl:for-each>
</ul>
<xsl:call-template name="toc">
<xsl:with-param name="toclevel" select="3"/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:when>
</li>
</xsl:for-each>
</ul>
<xsl:otherwise>
<xsl:if test="count(..//*[local-name()=$hnlevel]) &gt; 0">
</xsl:if>
<ul class="toc level{$toclevel}">
<xsl:for-each select="..//*[local-name()=$hnlevel]">
<li>
<xsl:call-template name="toc-a"/>
</li>
</xsl:for-each>
</ul>
<xsl:if test="$toclevel &lt; 6">
<xsl:call-template name="toc">
<xsl:with-param name="toclevel" select="$toclevel + 1"/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:otherwise>
</xsl:if>
</xsl:choose>
</xsl:template>
</xsl:template>
<xsl:template name="toc-a">
<a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment