1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
6 <!-- ********************************************************************
7 $Id: toc.xsl 9297 2012-04-22 03:56:16Z bobstayton $
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
18 <xsl:template match="set/toc | book/toc | part/toc">
19 <xsl:variable name="toc.params">
20 <xsl:call-template name="find.path.params">
21 <xsl:with-param name="node" select="parent::*"/>
22 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
26 <!-- Do not output the toc element if one is already generated
27 by the use of $generate.toc parameter, or if
28 generating a source toc is turned off -->
29 <xsl:if test="not(contains($toc.params, 'toc')) and ($process.source.toc != 0 or $process.empty.source.toc != 0)">
30 <xsl:variable name="content">
32 <xsl:when test="* and $process.source.toc != 0">
33 <xsl:apply-templates/>
35 <xsl:when test="count(*) = 0 and $process.empty.source.toc != 0">
36 <!-- trick to switch context node to parent element -->
37 <xsl:for-each select="parent::*">
39 <xsl:when test="self::set">
40 <xsl:call-template name="set.toc">
41 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
44 <xsl:when test="self::book">
45 <xsl:call-template name="division.toc">
46 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
49 <xsl:when test="self::part">
50 <xsl:call-template name="division.toc">
51 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
60 <xsl:if test="string-length(normalize-space($content)) != 0">
61 <xsl:copy-of select="$content"/>
66 <xsl:template match="chapter/toc | appendix/toc | preface/toc | article/toc">
67 <xsl:variable name="toc.params">
68 <xsl:call-template name="find.path.params">
69 <xsl:with-param name="node" select="parent::*"/>
70 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
74 <!-- Do not output the toc element if one is already generated
75 by the use of $generate.toc parameter, or if
76 generating a source toc is turned off -->
77 <xsl:if test="not(contains($toc.params, 'toc')) and ($process.source.toc != 0 or $process.empty.source.toc != 0)">
79 <xsl:when test="* and $process.source.toc != 0">
81 <xsl:apply-templates select="." mode="common.html.attributes"/>
82 <xsl:call-template name="id.attribute"/>
83 <xsl:apply-templates select="title"/>
85 <xsl:apply-templates select="." mode="common.html.attributes"/>
86 <xsl:apply-templates select="*[not(self::title)]"/>
89 <xsl:call-template name="component.toc.separator"/>
91 <xsl:when test="count(*) = 0 and $process.empty.source.toc != 0">
92 <!-- trick to switch context node to section element -->
93 <xsl:for-each select="parent::*">
94 <xsl:call-template name="component.toc">
95 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
98 <xsl:call-template name="component.toc.separator"/>
104 <xsl:template match="section/toc |sect1/toc |sect2/toc |sect3/toc |sect4/toc |sect5/toc">
106 <xsl:variable name="toc.params">
107 <xsl:call-template name="find.path.params">
108 <xsl:with-param name="node" select="parent::*"/>
109 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
113 <!-- Do not output the toc element if one is already generated
114 by the use of $generate.toc parameter, or if
115 generating a source toc is turned off -->
116 <xsl:if test="not(contains($toc.params, 'toc')) and ($process.source.toc != 0 or $process.empty.source.toc != 0)">
118 <xsl:when test="* and $process.source.toc != 0">
120 <xsl:apply-templates select="." mode="common.html.attributes"/>
121 <xsl:call-template name="id.attribute"/>
122 <xsl:apply-templates select="title"/>
124 <xsl:apply-templates select="." mode="common.html.attributes"/>
125 <xsl:apply-templates select="*[not(self::title)]"/>
128 <xsl:call-template name="section.toc.separator"/>
130 <xsl:when test="count(*) = 0 and $process.empty.source.toc != 0">
131 <!-- trick to switch context node to section element -->
132 <xsl:for-each select="parent::*">
133 <xsl:call-template name="section.toc">
134 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
137 <xsl:call-template name="section.toc.separator"/>
143 <!-- ==================================================================== -->
145 <xsl:template match="tocpart|tocchap |toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
146 <xsl:variable name="sub-toc">
147 <xsl:if test="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
149 <xsl:when test="$toc.list.type = 'dl'">
151 <xsl:apply-templates select="." mode="common.html.attributes"/>
152 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
153 <xsl:apply-templates select="." mode="common.html.attributes"/>
154 <xsl:apply-templates select="tocchap|toclevel1|toclevel2| toclevel3|toclevel4|toclevel5"/>
159 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
160 <xsl:apply-templates select="." mode="common.html.attributes"/>
161 <xsl:apply-templates select="tocchap|toclevel1|toclevel2| toclevel3|toclevel4|toclevel5"/>
168 <xsl:apply-templates select="tocentry[position() != last()]"/>
171 <xsl:when test="$toc.list.type = 'dl'">
173 <xsl:apply-templates select="." mode="common.html.attributes"/>
174 <xsl:apply-templates select="tocentry[position() = last()]"/>
176 <xsl:copy-of select="$sub-toc"/>
180 <xsl:apply-templates select="." mode="common.html.attributes"/>
181 <xsl:apply-templates select="tocentry[position() = last()]"/>
182 <xsl:copy-of select="$sub-toc"/>
188 <xsl:template match="tocentry|tocdiv|lotentry|tocfront|tocback">
190 <xsl:when test="$toc.list.type = 'dl'">
192 <xsl:apply-templates select="." mode="common.html.attributes"/>
193 <xsl:call-template name="tocentry-content"/>
198 <xsl:apply-templates select="." mode="common.html.attributes"/>
199 <xsl:call-template name="tocentry-content"/>
205 <xsl:template match="tocentry[position() = last()]" priority="2">
206 <xsl:call-template name="tocentry-content"/>
209 <xsl:template name="tocentry-content">
210 <xsl:variable name="targets" select="key('id',@linkend)"/>
211 <xsl:variable name="target" select="$targets[1]"/>
214 <xsl:when test="@linkend">
215 <xsl:call-template name="check.id.unique">
216 <xsl:with-param name="linkend" select="@linkend"/>
219 <xsl:attribute name="href">
220 <xsl:call-template name="href.target">
221 <xsl:with-param name="object" select="$target"/>
224 <xsl:apply-templates/>
228 <xsl:apply-templates/>
233 <xsl:template match="toc/title">
235 <xsl:apply-templates select="." mode="common.html.attributes"/>
236 <xsl:apply-templates/>
240 <xsl:template match="toc/subtitle">
242 <xsl:apply-templates select="." mode="common.html.attributes"/>
243 <xsl:apply-templates/>
247 <xsl:template match="toc/titleabbrev">
250 <!-- ==================================================================== -->
252 <!-- A lot element must have content, because there is no attribute
253 to select what kind of list should be generated -->
254 <xsl:template match="book/lot | part/lot">
255 <!-- Don't generate a page sequence unless there is content -->
256 <xsl:variable name="content">
258 <xsl:when test="* and $process.source.toc != 0">
260 <xsl:apply-templates select="." mode="common.html.attributes"/>
261 <xsl:apply-templates/>
264 <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
265 <xsl:call-template name="process.empty.lot"/>
270 <xsl:if test="string-length(normalize-space($content)) != 0">
271 <xsl:copy-of select="$content"/>
275 <xsl:template match="chapter/lot | appendix/lot | preface/lot | article/lot">
277 <xsl:when test="* and $process.source.toc != 0">
279 <xsl:apply-templates select="." mode="common.html.attributes"/>
280 <xsl:apply-templates/>
282 <xsl:call-template name="component.toc.separator"/>
284 <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
285 <xsl:call-template name="process.empty.lot"/>
290 <xsl:template match="section/lot |sect1/lot |sect2/lot |sect3/lot |sect4/lot |sect5/lot">
292 <xsl:when test="* and $process.source.toc != 0">
294 <xsl:apply-templates select="." mode="common.html.attributes"/>
295 <xsl:apply-templates/>
297 <xsl:call-template name="section.toc.separator"/>
299 <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
300 <xsl:call-template name="process.empty.lot"/>
305 <xsl:template name="process.empty.lot">
306 <!-- An empty lot element does not provide any information to indicate
307 what should be included in it. You can customize this
308 template to generate a lot based on @role or something -->
310 <xsl:text>Warning: don't know what to generate for </xsl:text>
311 <xsl:text>lot that has no children.</xsl:text>
315 <xsl:template match="lot/title">
317 <xsl:apply-templates select="." mode="common.html.attributes"/>
318 <xsl:apply-templates/>
322 <xsl:template match="lot/subtitle">
324 <xsl:apply-templates select="." mode="common.html.attributes"/>
325 <xsl:apply-templates/>
329 <xsl:template match="lot/titleabbrev">