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 8421 2009-05-04 07:49:49Z 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:apply-templates select="title"/>
84 <xsl:apply-templates select="." mode="common.html.attributes"/>
85 <xsl:apply-templates select="*[not(self::title)]"/>
88 <xsl:call-template name="component.toc.separator"/>
90 <xsl:when test="count(*) = 0 and $process.empty.source.toc != 0">
91 <!-- trick to switch context node to section element -->
92 <xsl:for-each select="parent::*">
93 <xsl:call-template name="component.toc">
94 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
97 <xsl:call-template name="component.toc.separator"/>
103 <xsl:template match="section/toc |sect1/toc |sect2/toc |sect3/toc |sect4/toc |sect5/toc">
105 <xsl:variable name="toc.params">
106 <xsl:call-template name="find.path.params">
107 <xsl:with-param name="node" select="parent::*"/>
108 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
112 <!-- Do not output the toc element if one is already generated
113 by the use of $generate.toc parameter, or if
114 generating a source toc is turned off -->
115 <xsl:if test="not(contains($toc.params, 'toc')) and ($process.source.toc != 0 or $process.empty.source.toc != 0)">
117 <xsl:when test="* and $process.source.toc != 0">
119 <xsl:apply-templates select="." mode="common.html.attributes"/>
120 <xsl:apply-templates select="title"/>
122 <xsl:apply-templates select="." mode="common.html.attributes"/>
123 <xsl:apply-templates select="*[not(self::title)]"/>
126 <xsl:call-template name="section.toc.separator"/>
128 <xsl:when test="count(*) = 0 and $process.empty.source.toc != 0">
129 <!-- trick to switch context node to section element -->
130 <xsl:for-each select="parent::*">
131 <xsl:call-template name="section.toc">
132 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
135 <xsl:call-template name="section.toc.separator"/>
141 <!-- ==================================================================== -->
143 <xsl:template match="tocpart|tocchap |toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
144 <xsl:variable name="sub-toc">
145 <xsl:if test="tocchap|toclevel1|toclevel2|toclevel3|toclevel4|toclevel5">
147 <xsl:when test="$toc.list.type = 'dl'">
149 <xsl:apply-templates select="." mode="common.html.attributes"/>
150 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
151 <xsl:apply-templates select="." mode="common.html.attributes"/>
152 <xsl:apply-templates select="tocchap|toclevel1|toclevel2| toclevel3|toclevel4|toclevel5"/>
157 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
158 <xsl:apply-templates select="." mode="common.html.attributes"/>
159 <xsl:apply-templates select="tocchap|toclevel1|toclevel2| toclevel3|toclevel4|toclevel5"/>
166 <xsl:apply-templates select="tocentry[position() != last()]"/>
169 <xsl:when test="$toc.list.type = 'dl'">
171 <xsl:apply-templates select="." mode="common.html.attributes"/>
172 <xsl:apply-templates select="tocentry[position() = last()]"/>
174 <xsl:copy-of select="$sub-toc"/>
178 <xsl:apply-templates select="." mode="common.html.attributes"/>
179 <xsl:apply-templates select="tocentry[position() = last()]"/>
180 <xsl:copy-of select="$sub-toc"/>
186 <xsl:template match="tocentry|tocdiv|lotentry|tocfront|tocback">
188 <xsl:when test="$toc.list.type = 'dl'">
190 <xsl:apply-templates select="." mode="common.html.attributes"/>
191 <xsl:call-template name="tocentry-content"/>
196 <xsl:apply-templates select="." mode="common.html.attributes"/>
197 <xsl:call-template name="tocentry-content"/>
203 <xsl:template match="tocentry[position() = last()]" priority="2">
204 <xsl:call-template name="tocentry-content"/>
207 <xsl:template name="tocentry-content">
208 <xsl:variable name="targets" select="key('id',@linkend)"/>
209 <xsl:variable name="target" select="$targets[1]"/>
212 <xsl:when test="@linkend">
213 <xsl:call-template name="check.id.unique">
214 <xsl:with-param name="linkend" select="@linkend"/>
217 <xsl:attribute name="href">
218 <xsl:call-template name="href.target">
219 <xsl:with-param name="object" select="$target"/>
222 <xsl:apply-templates/>
226 <xsl:apply-templates/>
231 <xsl:template match="toc/title">
233 <xsl:apply-templates select="." mode="common.html.attributes"/>
234 <xsl:apply-templates/>
238 <xsl:template match="toc/subtitle">
240 <xsl:apply-templates select="." mode="common.html.attributes"/>
241 <xsl:apply-templates/>
245 <xsl:template match="toc/titleabbrev">
248 <!-- ==================================================================== -->
250 <!-- A lot element must have content, because there is no attribute
251 to select what kind of list should be generated -->
252 <xsl:template match="book/lot | part/lot">
253 <!-- Don't generate a page sequence unless there is content -->
254 <xsl:variable name="content">
256 <xsl:when test="* and $process.source.toc != 0">
258 <xsl:apply-templates select="." mode="common.html.attributes"/>
259 <xsl:apply-templates/>
262 <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
263 <xsl:call-template name="process.empty.lot"/>
268 <xsl:if test="string-length(normalize-space($content)) != 0">
269 <xsl:copy-of select="$content"/>
273 <xsl:template match="chapter/lot | appendix/lot | preface/lot | article/lot">
275 <xsl:when test="* and $process.source.toc != 0">
277 <xsl:apply-templates select="." mode="common.html.attributes"/>
278 <xsl:apply-templates/>
280 <xsl:call-template name="component.toc.separator"/>
282 <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
283 <xsl:call-template name="process.empty.lot"/>
288 <xsl:template match="section/lot |sect1/lot |sect2/lot |sect3/lot |sect4/lot |sect5/lot">
290 <xsl:when test="* and $process.source.toc != 0">
292 <xsl:apply-templates select="." mode="common.html.attributes"/>
293 <xsl:apply-templates/>
295 <xsl:call-template name="section.toc.separator"/>
297 <xsl:when test="not(child::*) and $process.empty.source.toc != 0">
298 <xsl:call-template name="process.empty.lot"/>
303 <xsl:template name="process.empty.lot">
304 <!-- An empty lot element does not provide any information to indicate
305 what should be included in it. You can customize this
306 template to generate a lot based on @role or something -->
308 <xsl:text>Warning: don't know what to generate for </xsl:text>
309 <xsl:text>lot that has no children.</xsl:text>
313 <xsl:template match="lot/title">
315 <xsl:apply-templates select="." mode="common.html.attributes"/>
316 <xsl:apply-templates/>
320 <xsl:template match="lot/subtitle">
322 <xsl:apply-templates select="." mode="common.html.attributes"/>
323 <xsl:apply-templates/>
327 <xsl:template match="lot/titleabbrev">