2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: toc.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11 and other information.
13 ******************************************************************** -->
15 <!-- ==================================================================== -->
17 <xsl:template match=
"toc">
20 <xsl:if test=
"$process.source.toc != 0">
21 <!-- if the toc isn't empty, process it -->
22 <xsl:element name=
"{$toc.list.type}">
23 <xsl:apply-templates/>
28 <xsl:if test=
"$process.empty.source.toc != 0">
30 <xsl:when test=
"parent::section
36 <xsl:apply-templates select=
"parent::*"
37 mode=
"toc.for.section"/>
39 <xsl:when test=
"parent::article">
40 <xsl:apply-templates select=
"parent::*"
41 mode=
"toc.for.component"/>
43 <xsl:when test=
"parent::book
45 <xsl:apply-templates select=
"parent::*"
46 mode=
"toc.for.division"/>
48 <xsl:when test=
"parent::set">
49 <xsl:apply-templates select=
"parent::*"
52 <!-- there aren't any other contexts that allow toc -->
55 <xsl:text>I don't know how to make a TOC in this context!
</xsl:text>
64 <xsl:template match=
"tocpart|tocchap
65 |toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
66 <xsl:variable name=
"sub-toc">
67 <xsl:if test=
"tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
69 <xsl:when test=
"$toc.list.type = 'dl'">
71 <xsl:element name=
"{$toc.list.type}">
72 <xsl:apply-templates select=
"tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
77 <xsl:element name=
"{$toc.list.type}">
78 <xsl:apply-templates select=
"tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>
85 <xsl:apply-templates select=
"tocentry[position() != last()]"/>
88 <xsl:when test=
"$toc.list.type = 'dl'">
90 <xsl:apply-templates select=
"tocentry[position() = last()]"/>
92 <xsl:copy-of select=
"$sub-toc"/>
96 <xsl:apply-templates select=
"tocentry[position() = last()]"/>
97 <xsl:copy-of select=
"$sub-toc"/>
103 <xsl:template match=
"tocentry|tocfront|tocback">
105 <xsl:when test=
"$toc.list.type = 'dl'">
107 <xsl:call-template name=
"tocentry-content"/>
112 <xsl:call-template name=
"tocentry-content"/>
118 <xsl:template match=
"tocentry[position() = last()]" priority=
"2">
119 <xsl:call-template name=
"tocentry-content"/>
122 <xsl:template name=
"tocentry-content">
123 <xsl:variable name=
"targets" select=
"key('id',@linkend)"/>
124 <xsl:variable name=
"target" select=
"$targets[1]"/>
127 <xsl:when test=
"@linkend">
128 <xsl:call-template name=
"check.id.unique">
129 <xsl:with-param name=
"linkend" select=
"@linkend"/>
132 <xsl:attribute name=
"href">
133 <xsl:call-template name=
"href.target">
134 <xsl:with-param name=
"object" select=
"$target"/>
137 <xsl:apply-templates/>
141 <xsl:apply-templates/>
146 <!-- ==================================================================== -->
148 <xsl:template match=
"*" mode=
"toc.for.section">
149 <xsl:call-template name=
"section.toc"/>
152 <xsl:template match=
"*" mode=
"toc.for.component">
153 <xsl:call-template name=
"component.toc"/>
156 <xsl:template match=
"*" mode=
"toc.for.section">
157 <xsl:call-template name=
"section.toc"/>
160 <xsl:template match=
"*" mode=
"toc.for.division">
161 <xsl:call-template name=
"division.toc"/>
164 <xsl:template match=
"*" mode=
"toc.for.set">
165 <xsl:call-template name=
"set.toc"/>
168 <!-- ==================================================================== -->
170 <xsl:template match=
"lot|lotentry">