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"/>
8 <!-- Attach id attributes to headings -->
10 <xsl:template match=
"div[@class='subsection']/h2" mode=
"main">
12 <xsl:attribute name=
"id">
13 <xsl:value-of select='.'
/>
15 <xsl:value-of select=
"."/>
20 <!-- Collect table of contents' entries -->
22 <xsl:template match=
"div[@class='subsection']/h2" mode=
"toc">
25 <xsl:attribute name=
"href">
26 #
<xsl:value-of select=
"."/>
28 <xsl:value-of select=
"."/>
29 <xsl:value-of select=
"id(.)"/>
32 <xsl:text> </xsl:text>
35 <xsl:template match=
"text()" mode=
"toc"/>
38 <!-- Insert table of contents -->
40 <xsl:template match=
"div[@class='toc']" mode=
"main">
41 <xsl:param name=
"headings"/>
43 <xsl:copy-of select=
"$headings"/>
48 <!-- Build html with table of contents added -->
50 <xsl:template match=
"@*|node()">
51 <xsl:apply-templates mode=
"main">
52 <xsl:with-param name=
"headings">
53 <xsl:apply-templates mode=
"toc"/>
55 </xsl:apply-templates>
58 <xsl:template match=
"@*|node()" mode=
"main">
59 <xsl:param name=
"headings"/>
61 <xsl:apply-templates select=
"@*|node()" mode=
"main">
62 <xsl:with-param name=
"headings" select=
"$headings"/>
63 </xsl:apply-templates>