Improve web page build process
[pipeglade.git] / www-template / index-toc.xsl
blobd9d8ef6dd984a499e13b34ea2ac2caf8dcf85e6f
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">
11 <h2>
12 <xsl:attribute name="id">
13 <xsl:value-of select='.'/>
14 </xsl:attribute>
15 <xsl:value-of select="."/>
16 </h2>
17 </xsl:template>
20 <!-- Collect table of contents' entries -->
22 <xsl:template match="div[@class='subsection']/h2" mode="toc">
23 <i class="link-sec">
24 <a class="link-sec">
25 <xsl:attribute name="href">
26 #<xsl:value-of select="."/>
27 </xsl:attribute>
28 <xsl:value-of select="."/>
29 <xsl:value-of select="id(.)"/>
30 </a>
31 </i>
32 <xsl:text> </xsl:text>
33 </xsl:template>
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"/>
42 <div class="toc">
43 <xsl:copy-of select="$headings"/>
44 </div>
45 </xsl:template>
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"/>
54 </xsl:with-param>
55 </xsl:apply-templates>
56 </xsl:template>
58 <xsl:template match="@*|node()" mode="main">
59 <xsl:param name="headings"/>
60 <xsl:copy>
61 <xsl:apply-templates select="@*|node()" mode="main">
62 <xsl:with-param name="headings" select="$headings"/>
63 </xsl:apply-templates>
64 </xsl:copy>
65 </xsl:template>
67 </xsl:stylesheet>