1 <?xml version=
"1.0" encoding=
"UTF-8" ?>
2 <xsl:stylesheet version=
"1.0"
3 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform">
4 <!-- Add a table of contents to index.html -->
5 <xsl:output method=
"html" doctype-system=
"about:legacy-compat"/>
7 <!-- Attach @id to headings -->
8 <xsl:template match=
"div[@class='subsection']/h2">
10 <xsl:attribute name=
"id">
11 <xsl:value-of select=
"."/>
13 <xsl:value-of select=
"."/>
17 <!-- Insert table of contents -->
18 <xsl:template match=
"div[@class='toc']">
20 <xsl:for-each select=
"//div[@class='subsection']/h2">
23 <xsl:attribute name=
"href">
24 #
<xsl:value-of select=
"."/>
26 <xsl:value-of select=
"."/>
27 <xsl:value-of select=
"id(.)"/>
30 <xsl:if test=
"position() != last()">
31 <xsl:text> ยท
</xsl:text>
37 <!-- Rebuild html with table of contents added -->
38 <xsl:template match=
"@*|node()">
40 <xsl:apply-templates select=
"@*|node()">
41 </xsl:apply-templates>