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 8558 2009-12-11 00:33:17Z 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">
41 <xsl:when test="$make.clean.html != 0">
42 <div class="toc-title">
43 <xsl:call-template name="gentext">
44 <xsl:with-param name="key">TableofContents</xsl:with-param>
50 <strong xmlns:xslo="http://www.w3.org/1999/XSL/Transform">
51 <xsl:call-template name="gentext">
52 <xsl:with-param name="key">TableofContents</xsl:with-param>
62 <xsl:when test="$manual.toc != ''">
63 <xsl:variable name="id">
64 <xsl:call-template name="object.id"/>
66 <xsl:variable name="toc" select="document($manual.toc, .)"/>
67 <xsl:variable name="tocentry" select="$toc//tocentry[@linkend=$id]"/>
68 <xsl:if test="$tocentry and $tocentry/*">
70 <xsl:copy-of select="$toc.title"/>
71 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
72 <xsl:call-template name="manual-toc">
73 <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
81 <xsl:when test="$qanda.in.toc != 0">
82 <xsl:if test="$nodes.plus">
84 <xsl:copy-of select="$toc.title"/>
85 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
86 <xsl:apply-templates select="$nodes.plus" mode="toc">
87 <xsl:with-param name="toc-context" select="$toc-context"/>
88 </xsl:apply-templates>
94 <xsl:if test="$nodes">
96 <xsl:copy-of select="$toc.title"/>
97 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
98 <xsl:apply-templates select="$nodes" mode="toc">
99 <xsl:with-param name="toc-context" select="$toc-context"/>
100 </xsl:apply-templates>
111 <xsl:template name="make.lots">
112 <xsl:param name="toc.params" select="''"/>
113 <xsl:param name="toc"/>
115 <xsl:if test="contains($toc.params, 'toc')">
116 <xsl:copy-of select="$toc"/>
119 <xsl:if test="contains($toc.params, 'figure')">
120 <xsl:call-template name="list.of.titles">
121 <xsl:with-param name="titles" select="'figure'"/>
122 <xsl:with-param name="nodes" select=".//figure"/>
126 <xsl:if test="contains($toc.params, 'table')">
127 <xsl:call-template name="list.of.titles">
128 <xsl:with-param name="titles" select="'table'"/>
129 <xsl:with-param name="nodes" select=".//table"/>
133 <xsl:if test="contains($toc.params, 'example')">
134 <xsl:call-template name="list.of.titles">
135 <xsl:with-param name="titles" select="'example'"/>
136 <xsl:with-param name="nodes" select=".//example"/>
140 <xsl:if test="contains($toc.params, 'equation')">
141 <xsl:call-template name="list.of.titles">
142 <xsl:with-param name="titles" select="'equation'"/>
143 <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
147 <xsl:if test="contains($toc.params, 'procedure')">
148 <xsl:call-template name="list.of.titles">
149 <xsl:with-param name="titles" select="'procedure'"/>
150 <xsl:with-param name="nodes" select=".//procedure[title]"/>
155 <!-- ====================================================================== -->
157 <xsl:template name="set.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="book|setindex"/>
168 <xsl:template name="division.toc">
169 <xsl:param name="toc-context" select="."/>
170 <xsl:param name="toc.title.p" select="true()"/>
172 <xsl:call-template name="make.toc">
173 <xsl:with-param name="toc-context" select="$toc-context"/>
174 <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
175 <xsl:with-param name="nodes" select="part|reference |preface|chapter|appendix |article |bibliography|glossary|index |refentry |bridgehead[$bridgehead.in.toc != 0]"/>
180 <xsl:template name="component.toc">
181 <xsl:param name="toc-context" select="."/>
182 <xsl:param name="toc.title.p" select="true()"/>
184 <xsl:call-template name="make.toc">
185 <xsl:with-param name="toc-context" select="$toc-context"/>
186 <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
187 <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]"/>
191 <xsl:template name="component.toc.separator">
192 <!-- Customize to output something between
193 component.toc and first output -->
196 <xsl:template name="section.toc">
197 <xsl:param name="toc-context" select="."/>
198 <xsl:param name="toc.title.p" select="true()"/>
200 <xsl:call-template name="make.toc">
201 <xsl:with-param name="toc-context" select="$toc-context"/>
202 <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
203 <xsl:with-param name="nodes" select="section|sect1|sect2|sect3|sect4|sect5|refentry |bridgehead[$bridgehead.in.toc != 0]"/>
208 <xsl:template name="section.toc.separator">
209 <!-- Customize to output something between
210 section.toc and first output -->
212 <!-- ==================================================================== -->
214 <xsl:template name="subtoc">
215 <xsl:param name="toc-context" select="."/>
216 <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
218 <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
220 <xsl:variable name="subtoc">
221 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
223 <xsl:when test="$qanda.in.toc != 0">
224 <xsl:apply-templates mode="toc" select="$nodes.plus">
225 <xsl:with-param name="toc-context" select="$toc-context"/>
226 </xsl:apply-templates>
229 <xsl:apply-templates mode="toc" select="$nodes">
230 <xsl:with-param name="toc-context" select="$toc-context"/>
231 </xsl:apply-templates>
237 <xsl:variable name="depth">
239 <xsl:when test="local-name(.) = 'section'">
240 <xsl:value-of select="count(ancestor::section) + 1"/>
242 <xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
243 <xsl:when test="local-name(.) = 'sect2'">2</xsl:when>
244 <xsl:when test="local-name(.) = 'sect3'">3</xsl:when>
245 <xsl:when test="local-name(.) = 'sect4'">4</xsl:when>
246 <xsl:when test="local-name(.) = 'sect5'">5</xsl:when>
247 <xsl:when test="local-name(.) = 'refsect1'">1</xsl:when>
248 <xsl:when test="local-name(.) = 'refsect2'">2</xsl:when>
249 <xsl:when test="local-name(.) = 'refsect3'">3</xsl:when>
250 <xsl:when test="local-name(.) = 'simplesect'">
253 <xsl:when test="local-name(..) = 'section'">
254 <xsl:value-of select="count(ancestor::section)"/>
256 <xsl:when test="local-name(..) = 'sect1'">2</xsl:when>
257 <xsl:when test="local-name(..) = 'sect2'">3</xsl:when>
258 <xsl:when test="local-name(..) = 'sect3'">4</xsl:when>
259 <xsl:when test="local-name(..) = 'sect4'">5</xsl:when>
260 <xsl:when test="local-name(..) = 'sect5'">6</xsl:when>
261 <xsl:when test="local-name(..) = 'refsect1'">2</xsl:when>
262 <xsl:when test="local-name(..) = 'refsect2'">3</xsl:when>
263 <xsl:when test="local-name(..) = 'refsect3'">4</xsl:when>
264 <xsl:otherwise>1</xsl:otherwise>
267 <xsl:otherwise>0</xsl:otherwise>
271 <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
273 <xsl:variable name="subtoc.list">
275 <xsl:when test="$toc.dd.type = ''">
276 <xsl:copy-of select="$subtoc"/>
279 <xsl:element name="{$toc.dd.type}" namespace="http://www.w3.org/1999/xhtml">
280 <xsl:copy-of select="$subtoc"/>
286 <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
287 <xsl:call-template name="toc.line">
288 <xsl:with-param name="toc-context" select="$toc-context"/>
290 <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">
291 <xsl:copy-of select="$subtoc.list"/>
294 <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">
295 <xsl:copy-of select="$subtoc.list"/>
299 <xsl:template name="toc.line">
300 <xsl:param name="toc-context" select="."/>
301 <xsl:param name="depth" select="1"/>
302 <xsl:param name="depth.from.context" select="8"/>
305 <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
307 <!-- * if $autotoc.label.in.hyperlink is zero, then output the label -->
308 <!-- * before the hyperlinked title (as the DSSSL stylesheet does) -->
309 <xsl:if test="$autotoc.label.in.hyperlink = 0">
310 <xsl:variable name="label">
311 <xsl:apply-templates select="." mode="label.markup"/>
313 <xsl:copy-of select="$label"/>
314 <xsl:if test="$label != ''">
315 <xsl:value-of select="$autotoc.label.separator"/>
320 <xsl:attribute name="href">
321 <xsl:call-template name="href.target">
322 <xsl:with-param name="context" select="$toc-context"/>
323 <xsl:with-param name="toc-context" select="$toc-context"/>
327 <!-- * if $autotoc.label.in.hyperlink is non-zero, then output the label -->
328 <!-- * as part of the hyperlinked title -->
329 <xsl:if test="not($autotoc.label.in.hyperlink = 0)">
330 <xsl:variable name="label">
331 <xsl:apply-templates select="." mode="label.markup"/>
333 <xsl:copy-of select="$label"/>
334 <xsl:if test="$label != ''">
335 <xsl:value-of select="$autotoc.label.separator"/>
339 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
344 <xsl:template match="book" mode="toc">
345 <xsl:param name="toc-context" select="."/>
347 <xsl:call-template name="subtoc">
348 <xsl:with-param name="toc-context" select="$toc-context"/>
349 <xsl:with-param name="nodes" select="part|reference |preface|chapter|appendix |article |bibliography|glossary|index |refentry |bridgehead[$bridgehead.in.toc != 0]"/>
353 <xsl:template match="setindex" mode="toc">
354 <xsl:param name="toc-context" select="."/>
356 <!-- If the setindex tag is not empty, it should be it in the TOC -->
357 <xsl:if test="* or $generate.index != 0">
358 <xsl:call-template name="subtoc">
359 <xsl:with-param name="toc-context" select="$toc-context"/>
364 <xsl:template match="part|reference" mode="toc">
365 <xsl:param name="toc-context" select="."/>
367 <xsl:call-template name="subtoc">
368 <xsl:with-param name="toc-context" select="$toc-context"/>
369 <xsl:with-param name="nodes" select="appendix|chapter|article |index|glossary|bibliography |preface|reference|refentry |bridgehead[$bridgehead.in.toc != 0]"/>
373 <xsl:template match="preface|chapter|appendix|article" mode="toc">
374 <xsl:param name="toc-context" select="."/>
376 <xsl:call-template name="subtoc">
377 <xsl:with-param name="toc-context" select="$toc-context"/>
378 <xsl:with-param name="nodes" select="section|sect1 |simplesect[$simplesect.in.toc != 0] |refentry |glossary|bibliography|index |bridgehead[$bridgehead.in.toc != 0]"/>
382 <xsl:template match="sect1" mode="toc">
383 <xsl:param name="toc-context" select="."/>
384 <xsl:call-template name="subtoc">
385 <xsl:with-param name="toc-context" select="$toc-context"/>
386 <xsl:with-param name="nodes" select="sect2 |bridgehead[$bridgehead.in.toc != 0]"/>
390 <xsl:template match="sect2" mode="toc">
391 <xsl:param name="toc-context" select="."/>
393 <xsl:call-template name="subtoc">
394 <xsl:with-param name="toc-context" select="$toc-context"/>
395 <xsl:with-param name="nodes" select="sect3 |bridgehead[$bridgehead.in.toc != 0]"/>
399 <xsl:template match="sect3" mode="toc">
400 <xsl:param name="toc-context" select="."/>
402 <xsl:call-template name="subtoc">
403 <xsl:with-param name="toc-context" select="$toc-context"/>
404 <xsl:with-param name="nodes" select="sect4 |bridgehead[$bridgehead.in.toc != 0]"/>
408 <xsl:template match="sect4" mode="toc">
409 <xsl:param name="toc-context" select="."/>
411 <xsl:call-template name="subtoc">
412 <xsl:with-param name="toc-context" select="$toc-context"/>
413 <xsl:with-param name="nodes" select="sect5 |bridgehead[$bridgehead.in.toc != 0]"/>
417 <xsl:template match="sect5" mode="toc">
418 <xsl:param name="toc-context" select="."/>
420 <xsl:call-template name="subtoc">
421 <xsl:with-param name="toc-context" select="$toc-context"/>
425 <xsl:template match="simplesect" mode="toc">
426 <xsl:param name="toc-context" select="."/>
428 <xsl:call-template name="subtoc">
429 <xsl:with-param name="toc-context" select="$toc-context"/>
433 <xsl:template match="section" mode="toc">
434 <xsl:param name="toc-context" select="."/>
436 <xsl:call-template name="subtoc">
437 <xsl:with-param name="toc-context" select="$toc-context"/>
438 <xsl:with-param name="nodes" select="section|refentry |simplesect[$simplesect.in.toc != 0] |bridgehead[$bridgehead.in.toc != 0]"/>
442 <xsl:template match="bridgehead" mode="toc">
443 <xsl:param name="toc-context" select="."/>
445 <xsl:if test="$bridgehead.in.toc != 0">
446 <xsl:call-template name="subtoc">
447 <xsl:with-param name="toc-context" select="$toc-context"/>
452 <xsl:template match="bibliography|glossary" mode="toc">
453 <xsl:param name="toc-context" select="."/>
455 <xsl:call-template name="subtoc">
456 <xsl:with-param name="toc-context" select="$toc-context"/>
460 <xsl:template match="index" mode="toc">
461 <xsl:param name="toc-context" select="."/>
463 <!-- If the index tag is not empty, it should be it in the TOC -->
464 <xsl:if test="* or $generate.index != 0">
465 <xsl:call-template name="subtoc">
466 <xsl:with-param name="toc-context" select="$toc-context"/>
471 <xsl:template match="refentry" mode="toc">
472 <xsl:param name="toc-context" select="."/>
474 <xsl:variable name="refmeta" select=".//refmeta"/>
475 <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
476 <xsl:variable name="refnamediv" select=".//refnamediv"/>
477 <xsl:variable name="refname" select="$refnamediv//refname"/>
478 <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
479 <xsl:variable name="title">
481 <xsl:when test="$refentrytitle">
482 <xsl:apply-templates select="$refentrytitle[1]" mode="titleabbrev.markup"/>
484 <xsl:when test="$refdesc">
485 <xsl:apply-templates select="$refdesc" mode="titleabbrev.markup"/>
487 <xsl:when test="$refname">
488 <xsl:apply-templates select="$refname[1]" mode="titleabbrev.markup"/>
493 <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
494 <span class="refentrytitle">
496 <xsl:attribute name="href">
497 <xsl:call-template name="href.target">
498 <xsl:with-param name="toc-context" select="$toc-context"/>
501 <xsl:copy-of select="$title"/>
504 <span class="refpurpose">
505 <xsl:if test="$annotate.toc != 0">
506 <!-- * DocBook 5 says inlinemediaobject (among other things) -->
507 <!-- * is allowed in refpurpose; so we need to run -->
508 <!-- * apply-templates on refpurpose here, instead of value-of -->
509 <xsl:apply-templates select="refnamediv/refpurpose"/>
515 <xsl:template match="title" mode="toc">
516 <xsl:param name="toc-context" select="."/>
519 <xsl:attribute name="href">
520 <xsl:call-template name="href.target">
521 <xsl:with-param name="object" select=".."/>
522 <xsl:with-param name="toc-context" select="$toc-context"/>
525 <xsl:apply-templates/>
529 <xsl:template name="manual-toc">
530 <xsl:param name="toc-context" select="."/>
531 <xsl:param name="tocentry"/>
533 <!-- be careful, we don't want to change the current document to the other tree! -->
535 <xsl:if test="$tocentry">
536 <xsl:variable name="node" select="key('id', $tocentry/@linkend)"/>
538 <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
539 <xsl:variable name="label">
540 <xsl:apply-templates select="$node" mode="label.markup"/>
542 <xsl:copy-of select="$label"/>
543 <xsl:if test="$label != ''">
544 <xsl:value-of select="$autotoc.label.separator"/>
547 <xsl:attribute name="href">
548 <xsl:call-template name="href.target">
549 <xsl:with-param name="object" select="$node"/>
550 <xsl:with-param name="toc-context" select="$toc-context"/>
553 <xsl:apply-templates select="$node" mode="titleabbrev.markup"/>
557 <xsl:if test="$tocentry/*">
558 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
559 <xsl:call-template name="manual-toc">
560 <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
565 <xsl:if test="$tocentry/following-sibling::*">
566 <xsl:call-template name="manual-toc">
567 <xsl:with-param name="tocentry" select="$tocentry/following-sibling::*[1]"/>
573 <!-- ==================================================================== -->
575 <xsl:template name="list.of.titles">
576 <xsl:param name="toc-context" select="."/>
577 <xsl:param name="titles" select="'table'"/>
578 <xsl:param name="nodes" select=".//table"/>
580 <xsl:if test="$nodes">
581 <div class="list-of-{$titles}s">
583 <xsl:when test="$make.clean.html != 0">
584 <div class="toc-title">
585 <xsl:call-template name="gentext">
586 <xsl:with-param name="key">
588 <xsl:when test="$titles='table'">ListofTables</xsl:when>
589 <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
590 <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
591 <xsl:when test="$titles='example'">ListofExamples</xsl:when>
592 <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
593 <xsl:otherwise>ListofUnknown</xsl:otherwise>
601 <strong xmlns:xslo="http://www.w3.org/1999/XSL/Transform">
602 <xsl:call-template name="gentext">
603 <xsl:with-param name="key">
605 <xsl:when test="$titles='table'">ListofTables</xsl:when>
606 <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
607 <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
608 <xsl:when test="$titles='example'">ListofExamples</xsl:when>
609 <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
610 <xsl:otherwise>ListofUnknown</xsl:otherwise>
619 <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
620 <xsl:apply-templates select="$nodes" mode="toc">
621 <xsl:with-param name="toc-context" select="$toc-context"/>
622 </xsl:apply-templates>
628 <xsl:template match="figure|table|example|equation|procedure" mode="toc">
629 <xsl:param name="toc-context" select="."/>
631 <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
632 <xsl:variable name="label">
633 <xsl:apply-templates select="." mode="label.markup"/>
635 <xsl:copy-of select="$label"/>
636 <xsl:if test="$label != ''">
637 <xsl:value-of select="$autotoc.label.separator"/>
640 <xsl:attribute name="href">
641 <xsl:call-template name="href.target">
642 <xsl:with-param name="toc-context" select="$toc-context"/>
645 <xsl:apply-templates select="." mode="titleabbrev.markup"/>
650 <!-- Used only if qanda.in.toc parameter is non-zero -->
651 <xsl:template match="qandaset" mode="toc">
652 <xsl:param name="toc-context" select="."/>
653 <xsl:call-template name="subtoc">
654 <xsl:with-param name="toc-context" select="$toc-context"/>
655 <xsl:with-param name="nodes" select="qandadiv | qandaentry"/>
659 <xsl:template match="qandadiv|qandaentry" mode="toc">
660 <xsl:apply-templates select="." mode="qandatoc.mode"/>