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: autotoc.xsl 8315 2009-03-11 21:33:31Z 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 <xsl:variable name="toc.listitem.type">
18 <xsl:when test="$toc.list.type = 'dl'">dt</xsl:when>
19 <xsl:otherwise>li</xsl:otherwise>
23 <!-- this is just hack because dl and ul aren't completely isomorphic -->
24 <xsl:variable name="toc.dd.type">
26 <xsl:when test="$toc.list.type = 'dl'">dd</xsl:when>
31 <xsl:template name="make.toc">
32 <xsl:param name="toc-context" select="."/>
33 <xsl:param name="toc.title.p" select="true()"/>
34 <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
36 <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
38 <xsl:variable name="toc.title">
39 <xsl:if test="$toc.title.p">
42 <xsl:call-template name="gentext">
43 <xsl:with-param name="key">TableofContents</xsl:with-param>
51 <xsl:when test="$manual.toc != ''">
52 <xsl:variable name="id">
53 <xsl:call-template name="object.id"/>
55 <xsl:variable name="toc" select="document($manual.toc, .)"/>
56 <xsl:variable name="tocentry" select="$toc//tocentry[@linkend=$id]"/>
57 <xsl:if test="$tocentry and $tocentry/*">
59 <xsl:copy-of select="$toc.title"/>
60 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
61 <xsl:call-template name="manual-toc">
62 <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
70 <xsl:when test="$qanda.in.toc != 0">
71 <xsl:if test="$nodes.plus">
73 <xsl:copy-of select="$toc.title"/>
74 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
75 <xsl:apply-templates select="$nodes.plus" mode="toc">
76 <xsl:with-param name="toc-context" select="$toc-context"/>
77 </xsl:apply-templates>
83 <xsl:if test="$nodes">
85 <xsl:copy-of select="$toc.title"/>
86 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
87 <xsl:apply-templates select="$nodes" mode="toc">
88 <xsl:with-param name="toc-context" select="$toc-context"/>
89 </xsl:apply-templates>
100 <xsl:template name="make.lots">
101 <xsl:param name="toc.params" select="''"/>
102 <xsl:param name="toc"/>
104 <xsl:if test="contains($toc.params, 'toc')">
105 <xsl:copy-of select="$toc"/>
108 <xsl:if test="contains($toc.params, 'figure')">
109 <xsl:call-template name="list.of.titles">
110 <xsl:with-param name="titles" select="'figure'"/>
111 <xsl:with-param name="nodes" select=".//figure"/>
115 <xsl:if test="contains($toc.params, 'table')">
116 <xsl:call-template name="list.of.titles">
117 <xsl:with-param name="titles" select="'table'"/>
118 <xsl:with-param name="nodes" select=".//table"/>
122 <xsl:if test="contains($toc.params, 'example')">
123 <xsl:call-template name="list.of.titles">
124 <xsl:with-param name="titles" select="'example'"/>
125 <xsl:with-param name="nodes" select=".//example"/>
129 <xsl:if test="contains($toc.params, 'equation')">
130 <xsl:call-template name="list.of.titles">
131 <xsl:with-param name="titles" select="'equation'"/>
132 <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
136 <xsl:if test="contains($toc.params, 'procedure')">
137 <xsl:call-template name="list.of.titles">
138 <xsl:with-param name="titles" select="'procedure'"/>
139 <xsl:with-param name="nodes" select=".//procedure[title]"/>
144 <!-- ====================================================================== -->
146 <xsl:template name="set.toc">
147 <xsl:param name="toc-context" select="."/>
148 <xsl:param name="toc.title.p" select="true()"/>
150 <xsl:call-template name="make.toc">
151 <xsl:with-param name="toc-context" select="$toc-context"/>
152 <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
153 <xsl:with-param name="nodes" select="book|setindex"/>
157 <xsl:template name="division.toc">
158 <xsl:param name="toc-context" select="."/>
159 <xsl:param name="toc.title.p" select="true()"/>
161 <xsl:call-template name="make.toc">
162 <xsl:with-param name="toc-context" select="$toc-context"/>
163 <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
164 <xsl:with-param name="nodes" select="part|reference |preface|chapter|appendix |article |bibliography|glossary|index |refentry |bridgehead[$bridgehead.in.toc != 0]"/>
169 <xsl:template name="component.toc">
170 <xsl:param name="toc-context" select="."/>
171 <xsl:param name="toc.title.p" select="true()"/>
173 <xsl:call-template name="make.toc">
174 <xsl:with-param name="toc-context" select="$toc-context"/>
175 <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
176 <xsl:with-param name="nodes" select="section|sect1 |simplesect[$simplesect.in.toc != 0] |refentry |article|bibliography|glossary |appendix|index |bridgehead[not(@renderas) and $bridgehead.in.toc != 0] |.//bridgehead[@renderas='sect1' and $bridgehead.in.toc != 0]"/>
180 <xsl:template name="component.toc.separator">
181 <!-- Customize to output something between
182 component.toc and first output -->
185 <xsl:template name="section.toc">
186 <xsl:param name="toc-context" select="."/>
187 <xsl:param name="toc.title.p" select="true()"/>
189 <xsl:call-template name="make.toc">
190 <xsl:with-param name="toc-context" select="$toc-context"/>
191 <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
192 <xsl:with-param name="nodes" select="section|sect1|sect2|sect3|sect4|sect5|refentry |bridgehead[$bridgehead.in.toc != 0]"/>
197 <xsl:template name="section.toc.separator">
198 <!-- Customize to output something between
199 section.toc and first output -->
201 <!-- ==================================================================== -->
203 <xsl:template name="subtoc">
204 <xsl:param name="toc-context" select="."/>
205 <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
207 <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
209 <xsl:variable name="subtoc">
210 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
212 <xsl:when test="$qanda.in.toc != 0">
213 <xsl:apply-templates mode="toc" select="$nodes.plus">
214 <xsl:with-param name="toc-context" select="$toc-context"/>
215 </xsl:apply-templates>
218 <xsl:apply-templates mode="toc" select="$nodes">
219 <xsl:with-param name="toc-context" select="$toc-context"/>
220 </xsl:apply-templates>
226 <xsl:variable name="depth">
228 <xsl:when test="local-name(.) = 'section'">
229 <xsl:value-of select="count(ancestor::section) + 1"/>
231 <xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
232 <xsl:when test="local-name(.) = 'sect2'">2</xsl:when>
233 <xsl:when test="local-name(.) = 'sect3'">3</xsl:when>
234 <xsl:when test="local-name(.) = 'sect4'">4</xsl:when>
235 <xsl:when test="local-name(.) = 'sect5'">5</xsl:when>
236 <xsl:when test="local-name(.) = 'refsect1'">1</xsl:when>
237 <xsl:when test="local-name(.) = 'refsect2'">2</xsl:when>
238 <xsl:when test="local-name(.) = 'refsect3'">3</xsl:when>
239 <xsl:when test="local-name(.) = 'simplesect'">
242 <xsl:when test="local-name(..) = 'section'">
243 <xsl:value-of select="count(ancestor::section)"/>
245 <xsl:when test="local-name(..) = 'sect1'">2</xsl:when>
246 <xsl:when test="local-name(..) = 'sect2'">3</xsl:when>
247 <xsl:when test="local-name(..) = 'sect3'">4</xsl:when>
248 <xsl:when test="local-name(..) = 'sect4'">5</xsl:when>
249 <xsl:when test="local-name(..) = 'sect5'">6</xsl:when>
250 <xsl:when test="local-name(..) = 'refsect1'">2</xsl:when>
251 <xsl:when test="local-name(..) = 'refsect2'">3</xsl:when>
252 <xsl:when test="local-name(..) = 'refsect3'">4</xsl:when>
253 <xsl:otherwise>1</xsl:otherwise>
256 <xsl:otherwise>0</xsl:otherwise>
260 <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
262 <xsl:variable name="subtoc.list">
264 <xsl:when test="$toc.dd.type = ''">
265 <xsl:copy-of select="$subtoc"/>
268 <xsl:element name="{$toc.dd.type}" namespace="http://www.w3.org/1999/xhtml">
269 <xsl:copy-of select="$subtoc"/>
275 <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
276 <xsl:call-template name="toc.line">
277 <xsl:with-param name="toc-context" select="$toc-context"/>
279 <xsl:if test="$toc.listitem.type = 'li' and $toc.section.depth > $depth and ( ($qanda.in.toc = 0 and count($nodes)>0) or ($qanda.in.toc != 0 and count($nodes.plus)>0) ) and $toc.max.depth > $depth.from.context">
280 <xsl:copy-of select="$subtoc.list"/>
283 <xsl:if test="$toc.listitem.type != 'li' and $toc.section.depth > $depth and ( ($qanda.in.toc = 0 and count($nodes)>0) or ($qanda.in.toc != 0 and count($nodes.plus)>0) ) and $toc.max.depth > $depth.from.context">
284 <xsl:copy-of select="$subtoc.list"/>
288 <xsl:template name="toc.line">
289 <xsl:param name="toc-context" select="."/>
290 <xsl:param name="depth" select="1"/>
291 <xsl:param name="depth.from.context" select="8"/>
294 <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
296 <!-- * if $autotoc.label.in.hyperlink is zero, then output the label -->
297 <!-- * before the hyperlinked title (as the DSSSL stylesheet does) -->
298 <xsl:if test="$autotoc.label.in.hyperlink = 0">
299 <xsl:variable name="label">
300 <xsl:apply-templates select="." mode="label.markup"/>
302 <xsl:copy-of select="$label"/>
303 <xsl:if test="$label != ''">
304 <xsl:value-of select="$autotoc.label.separator"/>
309 <xsl:attribute name="href">
310 <xsl:call-template name="href.target">
311 <xsl:with-param name="context" select="$toc-context"/>
312 <xsl:with-param name="toc-context" select="$toc-context"/>
316 <!-- * if $autotoc.label.in.hyperlink is non-zero, then output the label -->
317 <!-- * as part of the hyperlinked title -->
318 <xsl:if test="not($autotoc.label.in.hyperlink = 0)">
319 <xsl:variable name="label">
320 <xsl:apply-templates select="." mode="label.markup"/>
322 <xsl:copy-of select="$label"/>
323 <xsl:if test="$label != ''">
324 <xsl:value-of select="$autotoc.label.separator"/>
328 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
333 <xsl:template match="book" mode="toc">
334 <xsl:param name="toc-context" select="."/>
336 <xsl:call-template name="subtoc">
337 <xsl:with-param name="toc-context" select="$toc-context"/>
338 <xsl:with-param name="nodes" select="part|reference |preface|chapter|appendix |article |bibliography|glossary|index |refentry |bridgehead[$bridgehead.in.toc != 0]"/>
342 <xsl:template match="setindex" mode="toc">
343 <xsl:param name="toc-context" select="."/>
345 <!-- If the setindex tag is not empty, it should be it in the TOC -->
346 <xsl:if test="* or $generate.index != 0">
347 <xsl:call-template name="subtoc">
348 <xsl:with-param name="toc-context" select="$toc-context"/>
353 <xsl:template match="part|reference" mode="toc">
354 <xsl:param name="toc-context" select="."/>
356 <xsl:call-template name="subtoc">
357 <xsl:with-param name="toc-context" select="$toc-context"/>
358 <xsl:with-param name="nodes" select="appendix|chapter|article |index|glossary|bibliography |preface|reference|refentry |bridgehead[$bridgehead.in.toc != 0]"/>
362 <xsl:template match="preface|chapter|appendix|article" mode="toc">
363 <xsl:param name="toc-context" select="."/>
365 <xsl:call-template name="subtoc">
366 <xsl:with-param name="toc-context" select="$toc-context"/>
367 <xsl:with-param name="nodes" select="section|sect1 |simplesect[$simplesect.in.toc != 0] |refentry |glossary|bibliography|index |bridgehead[$bridgehead.in.toc != 0]"/>
371 <xsl:template match="sect1" mode="toc">
372 <xsl:param name="toc-context" select="."/>
373 <xsl:call-template name="subtoc">
374 <xsl:with-param name="toc-context" select="$toc-context"/>
375 <xsl:with-param name="nodes" select="sect2 |bridgehead[$bridgehead.in.toc != 0]"/>
379 <xsl:template match="sect2" mode="toc">
380 <xsl:param name="toc-context" select="."/>
382 <xsl:call-template name="subtoc">
383 <xsl:with-param name="toc-context" select="$toc-context"/>
384 <xsl:with-param name="nodes" select="sect3 |bridgehead[$bridgehead.in.toc != 0]"/>
388 <xsl:template match="sect3" mode="toc">
389 <xsl:param name="toc-context" select="."/>
391 <xsl:call-template name="subtoc">
392 <xsl:with-param name="toc-context" select="$toc-context"/>
393 <xsl:with-param name="nodes" select="sect4 |bridgehead[$bridgehead.in.toc != 0]"/>
397 <xsl:template match="sect4" mode="toc">
398 <xsl:param name="toc-context" select="."/>
400 <xsl:call-template name="subtoc">
401 <xsl:with-param name="toc-context" select="$toc-context"/>
402 <xsl:with-param name="nodes" select="sect5 |bridgehead[$bridgehead.in.toc != 0]"/>
406 <xsl:template match="sect5" mode="toc">
407 <xsl:param name="toc-context" select="."/>
409 <xsl:call-template name="subtoc">
410 <xsl:with-param name="toc-context" select="$toc-context"/>
414 <xsl:template match="simplesect" mode="toc">
415 <xsl:param name="toc-context" select="."/>
417 <xsl:call-template name="subtoc">
418 <xsl:with-param name="toc-context" select="$toc-context"/>
422 <xsl:template match="section" mode="toc">
423 <xsl:param name="toc-context" select="."/>
425 <xsl:call-template name="subtoc">
426 <xsl:with-param name="toc-context" select="$toc-context"/>
427 <xsl:with-param name="nodes" select="section|refentry |simplesect[$simplesect.in.toc != 0] |bridgehead[$bridgehead.in.toc != 0]"/>
431 <xsl:template match="bridgehead" mode="toc">
432 <xsl:param name="toc-context" select="."/>
434 <xsl:if test="$bridgehead.in.toc != 0">
435 <xsl:call-template name="subtoc">
436 <xsl:with-param name="toc-context" select="$toc-context"/>
441 <xsl:template match="bibliography|glossary" mode="toc">
442 <xsl:param name="toc-context" select="."/>
444 <xsl:call-template name="subtoc">
445 <xsl:with-param name="toc-context" select="$toc-context"/>
449 <xsl:template match="index" mode="toc">
450 <xsl:param name="toc-context" select="."/>
452 <!-- If the index tag is not empty, it should be it in the TOC -->
453 <xsl:if test="* or $generate.index != 0">
454 <xsl:call-template name="subtoc">
455 <xsl:with-param name="toc-context" select="$toc-context"/>
460 <xsl:template match="refentry" mode="toc">
461 <xsl:param name="toc-context" select="."/>
463 <xsl:variable name="refmeta" select=".//refmeta"/>
464 <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
465 <xsl:variable name="refnamediv" select=".//refnamediv"/>
466 <xsl:variable name="refname" select="$refnamediv//refname"/>
467 <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
468 <xsl:variable name="title">
470 <xsl:when test="$refentrytitle">
471 <xsl:apply-templates select="$refentrytitle[1]" mode="titleabbrev.markup"/>
473 <xsl:when test="$refdesc">
474 <xsl:apply-templates select="$refdesc" mode="titleabbrev.markup"/>
476 <xsl:when test="$refname">
477 <xsl:apply-templates select="$refname[1]" mode="titleabbrev.markup"/>
482 <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
483 <span class="refentrytitle">
485 <xsl:attribute name="href">
486 <xsl:call-template name="href.target">
487 <xsl:with-param name="toc-context" select="$toc-context"/>
490 <xsl:copy-of select="$title"/>
493 <span class="refpurpose">
494 <xsl:if test="$annotate.toc != 0">
495 <!-- * DocBook 5 says inlinemediaobject (among other things) -->
496 <!-- * is allowed in refpurpose; so we need to run -->
497 <!-- * apply-templates on refpurpose here, instead of value-of -->
498 <xsl:apply-templates select="refnamediv/refpurpose"/>
504 <xsl:template match="title" mode="toc">
505 <xsl:param name="toc-context" select="."/>
508 <xsl:attribute name="href">
509 <xsl:call-template name="href.target">
510 <xsl:with-param name="object" select=".."/>
511 <xsl:with-param name="toc-context" select="$toc-context"/>
514 <xsl:apply-templates/>
518 <xsl:template name="manual-toc">
519 <xsl:param name="toc-context" select="."/>
520 <xsl:param name="tocentry"/>
522 <!-- be careful, we don't want to change the current document to the other tree! -->
524 <xsl:if test="$tocentry">
525 <xsl:variable name="node" select="key('id', $tocentry/@linkend)"/>
527 <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
528 <xsl:variable name="label">
529 <xsl:apply-templates select="$node" mode="label.markup"/>
531 <xsl:copy-of select="$label"/>
532 <xsl:if test="$label != ''">
533 <xsl:value-of select="$autotoc.label.separator"/>
536 <xsl:attribute name="href">
537 <xsl:call-template name="href.target">
538 <xsl:with-param name="object" select="$node"/>
539 <xsl:with-param name="toc-context" select="$toc-context"/>
542 <xsl:apply-templates select="$node" mode="titleabbrev.markup"/>
546 <xsl:if test="$tocentry/*">
547 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
548 <xsl:call-template name="manual-toc">
549 <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
554 <xsl:if test="$tocentry/following-sibling::*">
555 <xsl:call-template name="manual-toc">
556 <xsl:with-param name="tocentry" select="$tocentry/following-sibling::*[1]"/>
562 <!-- ==================================================================== -->
564 <xsl:template name="list.of.titles">
565 <xsl:param name="toc-context" select="."/>
566 <xsl:param name="titles" select="'table'"/>
567 <xsl:param name="nodes" select=".//table"/>
569 <xsl:if test="$nodes">
570 <div class="list-of-{$titles}s">
573 <xsl:call-template name="gentext">
574 <xsl:with-param name="key">
576 <xsl:when test="$titles='table'">ListofTables</xsl:when>
577 <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
578 <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
579 <xsl:when test="$titles='example'">ListofExamples</xsl:when>
580 <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
581 <xsl:otherwise>ListofUnknown</xsl:otherwise>
588 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
589 <xsl:apply-templates select="$nodes" mode="toc">
590 <xsl:with-param name="toc-context" select="$toc-context"/>
591 </xsl:apply-templates>
597 <xsl:template match="figure|table|example|equation|procedure" mode="toc">
598 <xsl:param name="toc-context" select="."/>
600 <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
601 <xsl:variable name="label">
602 <xsl:apply-templates select="." mode="label.markup"/>
604 <xsl:copy-of select="$label"/>
605 <xsl:if test="$label != ''">
606 <xsl:value-of select="$autotoc.label.separator"/>
609 <xsl:attribute name="href">
610 <xsl:call-template name="href.target">
611 <xsl:with-param name="toc-context" select="$toc-context"/>
614 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
619 <!-- Used only if qanda.in.toc parameter is non-zero -->
620 <xsl:template match="qandaset" mode="toc">
621 <xsl:param name="toc-context" select="."/>
622 <xsl:call-template name="subtoc">
623 <xsl:with-param name="toc-context" select="$toc-context"/>
624 <xsl:with-param name="nodes" select="qandadiv | qandaentry"/>
628 <xsl:template match="qandadiv|qandaentry" mode="toc">
629 <xsl:apply-templates select="." mode="qandatoc.mode"/>