<ul>\r
<xsl:for-each select="following::h2|following::h3|following::h4">\r
<xsl:element name="li">\r
- <xsl:attribute name="class"><xsl:value-of select="concat('level_',local-name())"/></xsl:attribute>\r
- <b><xsl:call-template name="section-number"/></b>\r
+ <xsl:attribute name="class">\r
+ <xsl:value-of select="concat('level_',local-name())"/>\r
+ </xsl:attribute>\r
+ <b><xsl:call-template name="section-number"/><xsl:text> </xsl:text></b>\r
<xsl:element name="a">\r
- <xsl:attribute name="href"><xsl:value-of select="concat('#',a/@name)"/></xsl:attribute>\r
+ <xsl:choose>\r
+ <xsl:when test="a/@name">\r
+ <xsl:attribute name="href">\r
+ <xsl:value-of select="concat('#',a/@name)"/>\r
+ </xsl:attribute>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:attribute name="href">\r
+ <xsl:text>#autotoc-</xsl:text>\r
+ <xsl:call-template name="section-number"/>\r
+ </xsl:attribute>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
<xsl:value-of select="string(current())"/>\r
</xsl:element>\r
</xsl:element>\r
</xsl:template>\r
\r
<xsl:template name="section-number">\r
- <xsl:number level="any" from="h1" count="h2"/>\r
+ <xsl:number level="any" from="div[@id='autotoc']" count="h2"/>\r
<xsl:text>.</xsl:text>\r
<xsl:if test="self::h3|self::h4">\r
<xsl:number level="any" from="h2" count="h3"/>\r
<xsl:number level="any" from="h3" count="h4"/>\r
<xsl:text>.</xsl:text>\r
</xsl:if>\r
- <xsl:text> </xsl:text>\r
</xsl:template>\r
\r
<xsl:template match="h2|h3|h4">\r
<xsl:copy>\r
<xsl:call-template name="copy-attributes"/>\r
- <xsl:if test="preceding::div[@id='autotoc']">\r
- <xsl:call-template name="section-number"/>\r
- </xsl:if>\r
- <xsl:apply-templates/>\r
+ <xsl:choose>\r
+ <xsl:when test="preceding::div[@id='autotoc']">\r
+ <xsl:call-template name="section-number"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:choose>\r
+ <xsl:when test="a">\r
+ <xsl:apply-templates/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:element name="a">\r
+ <xsl:attribute name="class"><xsl:text>anchor</xsl:text></xsl:attribute>\r
+ <xsl:attribute name="name">\r
+ <xsl:text>autotoc-</xsl:text>\r
+ <xsl:call-template name="section-number"/>\r
+ </xsl:attribute>\r
+ <xsl:apply-templates/>\r
+ </xsl:element>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:apply-templates/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
</xsl:copy>\r
</xsl:template>\r
- \r
+\r
<!-- Build dia image-map from special div/span elements -->\r
<xsl:template match="div[@class='diamap']">\r
<xsl:element name="map">\r