]> git.stg.codes - stg.git/blob - doc/xslt/html/autotoc.xsl
Set output encoding to utf-8.
[stg.git] / doc / xslt / html / autotoc.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 version='1.0'>
4
5 <!-- ********************************************************************
6      $Id: autotoc.xsl 8558 2009-12-11 00:33:17Z bobstayton $
7      ********************************************************************
8
9      This file is part of the XSL DocBook Stylesheet distribution.
10      See ../README or http://docbook.sf.net/release/xsl/current/ for
11      copyright and other information.
12
13      ******************************************************************** -->
14
15 <xsl:variable name="toc.listitem.type">
16   <xsl:choose>
17     <xsl:when test="$toc.list.type = 'dl'">dt</xsl:when>
18     <xsl:otherwise>li</xsl:otherwise>
19   </xsl:choose>
20 </xsl:variable>
21
22 <!-- this is just hack because dl and ul aren't completely isomorphic -->
23 <xsl:variable name="toc.dd.type">
24   <xsl:choose>
25     <xsl:when test="$toc.list.type = 'dl'">dd</xsl:when>
26     <xsl:otherwise></xsl:otherwise>
27   </xsl:choose>
28 </xsl:variable>
29
30 <xsl:template name="make.toc">
31   <xsl:param name="toc-context" select="."/>
32   <xsl:param name="toc.title.p" select="true()"/>
33   <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
34
35   <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
36
37   <xsl:variable name="toc.title">
38     <xsl:if test="$toc.title.p">
39       <xsl:choose>
40         <xsl:when test="$make.clean.html != 0">
41           <div class="toc-title">
42             <xsl:call-template name="gentext">
43               <xsl:with-param name="key">TableofContents</xsl:with-param>
44             </xsl:call-template>
45           </div>
46         </xsl:when>
47         <xsl:otherwise>
48           <p>
49             <b>
50               <xsl:call-template name="gentext">
51                 <xsl:with-param name="key">TableofContents</xsl:with-param>
52               </xsl:call-template>
53             </b>
54           </p>
55         </xsl:otherwise>
56       </xsl:choose>
57     </xsl:if>
58   </xsl:variable>
59
60   <xsl:choose>
61     <xsl:when test="$manual.toc != ''">
62       <xsl:variable name="id">
63         <xsl:call-template name="object.id"/>
64       </xsl:variable>
65       <xsl:variable name="toc" select="document($manual.toc, .)"/>
66       <xsl:variable name="tocentry" select="$toc//tocentry[@linkend=$id]"/>
67       <xsl:if test="$tocentry and $tocentry/*">
68         <div class="toc">
69           <xsl:copy-of select="$toc.title"/>
70           <xsl:element name="{$toc.list.type}">
71             <xsl:call-template name="manual-toc">
72               <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
73             </xsl:call-template>
74           </xsl:element>
75         </div>
76       </xsl:if>
77     </xsl:when>
78     <xsl:otherwise>
79       <xsl:choose>
80         <xsl:when test="$qanda.in.toc != 0">
81           <xsl:if test="$nodes.plus">
82             <div class="toc">
83               <xsl:copy-of select="$toc.title"/>
84               <xsl:element name="{$toc.list.type}">
85                 <xsl:apply-templates select="$nodes.plus" mode="toc">
86                   <xsl:with-param name="toc-context" select="$toc-context"/>
87                 </xsl:apply-templates>
88               </xsl:element>
89             </div>
90           </xsl:if>
91         </xsl:when>
92         <xsl:otherwise>
93           <xsl:if test="$nodes">
94             <div class="toc">
95               <xsl:copy-of select="$toc.title"/>
96               <xsl:element name="{$toc.list.type}">
97                 <xsl:apply-templates select="$nodes" mode="toc">
98                   <xsl:with-param name="toc-context" select="$toc-context"/>
99                 </xsl:apply-templates>
100               </xsl:element>
101             </div>
102           </xsl:if>
103         </xsl:otherwise>
104       </xsl:choose>
105
106     </xsl:otherwise>
107   </xsl:choose>
108 </xsl:template>
109
110 <xsl:template name="make.lots">
111   <xsl:param name="toc.params" select="''"/>
112   <xsl:param name="toc"/>
113
114   <xsl:if test="contains($toc.params, 'toc')">
115     <xsl:copy-of select="$toc"/>
116   </xsl:if>
117
118   <xsl:if test="contains($toc.params, 'figure')">
119     <xsl:call-template name="list.of.titles">
120       <xsl:with-param name="titles" select="'figure'"/>
121       <xsl:with-param name="nodes" select=".//figure"/>
122     </xsl:call-template>
123   </xsl:if>
124
125   <xsl:if test="contains($toc.params, 'table')">
126     <xsl:call-template name="list.of.titles">
127       <xsl:with-param name="titles" select="'table'"/>
128       <xsl:with-param name="nodes" select=".//table"/>
129     </xsl:call-template>
130   </xsl:if>
131
132   <xsl:if test="contains($toc.params, 'example')">
133     <xsl:call-template name="list.of.titles">
134       <xsl:with-param name="titles" select="'example'"/>
135       <xsl:with-param name="nodes" select=".//example"/>
136     </xsl:call-template>
137   </xsl:if>
138
139   <xsl:if test="contains($toc.params, 'equation')">
140     <xsl:call-template name="list.of.titles">
141       <xsl:with-param name="titles" select="'equation'"/>
142       <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
143     </xsl:call-template>
144   </xsl:if>
145
146   <xsl:if test="contains($toc.params, 'procedure')">
147     <xsl:call-template name="list.of.titles">
148       <xsl:with-param name="titles" select="'procedure'"/>
149       <xsl:with-param name="nodes" select=".//procedure[title]"/>
150     </xsl:call-template>
151   </xsl:if>
152 </xsl:template>
153
154 <!-- ====================================================================== -->
155
156 <xsl:template name="set.toc">
157   <xsl:param name="toc-context" select="."/>
158   <xsl:param name="toc.title.p" select="true()"/>
159
160   <xsl:call-template name="make.toc">
161     <xsl:with-param name="toc-context" select="$toc-context"/>
162     <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
163     <xsl:with-param name="nodes" select="book|setindex"/>
164   </xsl:call-template>
165 </xsl:template>
166
167 <xsl:template name="division.toc">
168   <xsl:param name="toc-context" select="."/>
169   <xsl:param name="toc.title.p" select="true()"/>
170
171   <xsl:call-template name="make.toc">
172     <xsl:with-param name="toc-context" select="$toc-context"/>
173     <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
174     <xsl:with-param name="nodes" select="part|reference
175                                          |preface|chapter|appendix
176                                          |article
177                                          |bibliography|glossary|index
178                                          |refentry
179                                          |bridgehead[$bridgehead.in.toc != 0]"/>
180
181   </xsl:call-template>
182 </xsl:template>
183
184 <xsl:template name="component.toc">
185   <xsl:param name="toc-context" select="."/>
186   <xsl:param name="toc.title.p" select="true()"/>
187
188   <xsl:call-template name="make.toc">
189     <xsl:with-param name="toc-context" select="$toc-context"/>
190     <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
191     <xsl:with-param name="nodes" select="section|sect1
192                                          |simplesect[$simplesect.in.toc != 0]
193                                          |refentry
194                                          |article|bibliography|glossary
195                                          |appendix|index
196                                          |bridgehead[not(@renderas)
197                                                      and $bridgehead.in.toc != 0]
198                                          |.//bridgehead[@renderas='sect1'
199                                                         and $bridgehead.in.toc != 0]"/>
200   </xsl:call-template>
201 </xsl:template>
202
203 <xsl:template name="component.toc.separator">
204   <!-- Customize to output something between
205        component.toc and first output -->
206 </xsl:template>
207
208 <xsl:template name="section.toc">
209   <xsl:param name="toc-context" select="."/>
210   <xsl:param name="toc.title.p" select="true()"/>
211
212   <xsl:call-template name="make.toc">
213     <xsl:with-param name="toc-context" select="$toc-context"/>
214     <xsl:with-param name="toc.title.p" select="$toc.title.p"/>
215     <xsl:with-param name="nodes"
216                     select="section|sect1|sect2|sect3|sect4|sect5|refentry
217                            |bridgehead[$bridgehead.in.toc != 0]"/>
218
219   </xsl:call-template>
220 </xsl:template>
221
222 <xsl:template name="section.toc.separator">
223   <!-- Customize to output something between
224        section.toc and first output -->
225 </xsl:template>
226 <!-- ==================================================================== -->
227
228 <xsl:template name="subtoc">
229   <xsl:param name="toc-context" select="."/>
230   <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
231
232   <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
233
234   <xsl:variable name="subtoc">
235     <xsl:element name="{$toc.list.type}">
236       <xsl:choose>
237         <xsl:when test="$qanda.in.toc != 0">
238           <xsl:apply-templates mode="toc" select="$nodes.plus">
239             <xsl:with-param name="toc-context" select="$toc-context"/>
240           </xsl:apply-templates>
241         </xsl:when>
242         <xsl:otherwise>
243           <xsl:apply-templates mode="toc" select="$nodes">
244             <xsl:with-param name="toc-context" select="$toc-context"/>
245           </xsl:apply-templates>
246         </xsl:otherwise>
247       </xsl:choose>
248     </xsl:element>
249   </xsl:variable>
250
251   <xsl:variable name="depth">
252     <xsl:choose>
253       <xsl:when test="local-name(.) = 'section'">
254         <xsl:value-of select="count(ancestor::section) + 1"/>
255       </xsl:when>
256       <xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
257       <xsl:when test="local-name(.) = 'sect2'">2</xsl:when>
258       <xsl:when test="local-name(.) = 'sect3'">3</xsl:when>
259       <xsl:when test="local-name(.) = 'sect4'">4</xsl:when>
260       <xsl:when test="local-name(.) = 'sect5'">5</xsl:when>
261       <xsl:when test="local-name(.) = 'refsect1'">1</xsl:when>
262       <xsl:when test="local-name(.) = 'refsect2'">2</xsl:when>
263       <xsl:when test="local-name(.) = 'refsect3'">3</xsl:when>
264       <xsl:when test="local-name(.) = 'simplesect'">
265         <!-- sigh... -->
266         <xsl:choose>
267           <xsl:when test="local-name(..) = 'section'">
268             <xsl:value-of select="count(ancestor::section)"/>
269           </xsl:when>
270           <xsl:when test="local-name(..) = 'sect1'">2</xsl:when>
271           <xsl:when test="local-name(..) = 'sect2'">3</xsl:when>
272           <xsl:when test="local-name(..) = 'sect3'">4</xsl:when>
273           <xsl:when test="local-name(..) = 'sect4'">5</xsl:when>
274           <xsl:when test="local-name(..) = 'sect5'">6</xsl:when>
275           <xsl:when test="local-name(..) = 'refsect1'">2</xsl:when>
276           <xsl:when test="local-name(..) = 'refsect2'">3</xsl:when>
277           <xsl:when test="local-name(..) = 'refsect3'">4</xsl:when>
278           <xsl:otherwise>1</xsl:otherwise>
279         </xsl:choose>
280       </xsl:when>
281       <xsl:otherwise>0</xsl:otherwise>
282     </xsl:choose>
283   </xsl:variable>
284
285   <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
286
287   <xsl:variable name="subtoc.list">
288     <xsl:choose>
289       <xsl:when test="$toc.dd.type = ''">
290         <xsl:copy-of select="$subtoc"/>
291       </xsl:when>
292       <xsl:otherwise>
293         <xsl:element name="{$toc.dd.type}">
294           <xsl:copy-of select="$subtoc"/>
295         </xsl:element>
296       </xsl:otherwise>
297     </xsl:choose>
298   </xsl:variable>
299
300   <xsl:element name="{$toc.listitem.type}">
301     <xsl:call-template name="toc.line">
302       <xsl:with-param name="toc-context" select="$toc-context"/>
303     </xsl:call-template>
304     <xsl:if test="$toc.listitem.type = 'li'
305                   and $toc.section.depth > $depth and 
306                   ( ($qanda.in.toc = 0 and count($nodes)&gt;0) or
307                     ($qanda.in.toc != 0 and count($nodes.plus)&gt;0) )
308                   and $toc.max.depth > $depth.from.context">
309       <xsl:copy-of select="$subtoc.list"/>
310     </xsl:if>
311   </xsl:element>
312   <xsl:if test="$toc.listitem.type != 'li'
313                 and $toc.section.depth > $depth and 
314                 ( ($qanda.in.toc = 0 and count($nodes)&gt;0) or
315                   ($qanda.in.toc != 0 and count($nodes.plus)&gt;0) )
316                 and $toc.max.depth > $depth.from.context">
317     <xsl:copy-of select="$subtoc.list"/>
318   </xsl:if>
319 </xsl:template>
320
321 <xsl:template name="toc.line">
322   <xsl:param name="toc-context" select="."/>
323   <xsl:param name="depth" select="1"/>
324   <xsl:param name="depth.from.context" select="8"/>
325
326  <span>
327   <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
328
329   <!-- * if $autotoc.label.in.hyperlink is zero, then output the label -->
330   <!-- * before the hyperlinked title (as the DSSSL stylesheet does) -->
331   <xsl:if test="$autotoc.label.in.hyperlink = 0">
332     <xsl:variable name="label">
333       <xsl:apply-templates select="." mode="label.markup"/>
334     </xsl:variable>
335     <xsl:copy-of select="$label"/>
336     <xsl:if test="$label != ''">
337       <xsl:value-of select="$autotoc.label.separator"/>
338     </xsl:if>
339   </xsl:if>
340
341   <a>
342     <xsl:attribute name="href">
343       <xsl:call-template name="href.target">
344         <xsl:with-param name="context" select="$toc-context"/>
345         <xsl:with-param name="toc-context" select="$toc-context"/>
346       </xsl:call-template>
347     </xsl:attribute>
348     
349   <!-- * if $autotoc.label.in.hyperlink is non-zero, then output the label -->
350   <!-- * as part of the hyperlinked title -->
351   <xsl:if test="not($autotoc.label.in.hyperlink = 0)">
352     <xsl:variable name="label">
353       <xsl:apply-templates select="." mode="label.markup"/>
354     </xsl:variable>
355     <xsl:copy-of select="$label"/>
356     <xsl:if test="$label != ''">
357       <xsl:value-of select="$autotoc.label.separator"/>
358     </xsl:if>
359   </xsl:if>
360
361     <xsl:apply-templates select="." mode="titleabbrev.markup"/>
362   </a>
363   </span>
364 </xsl:template>
365
366 <xsl:template match="book" mode="toc">
367   <xsl:param name="toc-context" select="."/>
368
369   <xsl:call-template name="subtoc">
370     <xsl:with-param name="toc-context" select="$toc-context"/>
371     <xsl:with-param name="nodes" select="part|reference
372                                          |preface|chapter|appendix
373                                          |article
374                                          |bibliography|glossary|index
375                                          |refentry
376                                          |bridgehead[$bridgehead.in.toc != 0]"/>
377   </xsl:call-template>
378 </xsl:template>
379
380 <xsl:template match="setindex" mode="toc">
381   <xsl:param name="toc-context" select="."/>
382
383   <!-- If the setindex tag is not empty, it should be it in the TOC -->
384   <xsl:if test="* or $generate.index != 0">
385     <xsl:call-template name="subtoc">
386       <xsl:with-param name="toc-context" select="$toc-context"/>
387     </xsl:call-template>
388   </xsl:if>
389 </xsl:template>
390
391 <xsl:template match="part|reference" mode="toc">
392   <xsl:param name="toc-context" select="."/>
393
394   <xsl:call-template name="subtoc">
395     <xsl:with-param name="toc-context" select="$toc-context"/>
396     <xsl:with-param name="nodes" select="appendix|chapter|article
397                                          |index|glossary|bibliography
398                                          |preface|reference|refentry
399                                          |bridgehead[$bridgehead.in.toc != 0]"/>
400   </xsl:call-template>
401 </xsl:template>
402
403 <xsl:template match="preface|chapter|appendix|article" mode="toc">
404   <xsl:param name="toc-context" select="."/>
405
406   <xsl:call-template name="subtoc">
407     <xsl:with-param name="toc-context" select="$toc-context"/>
408     <xsl:with-param name="nodes" select="section|sect1
409                                          |simplesect[$simplesect.in.toc != 0]
410                                          |refentry
411                                          |glossary|bibliography|index
412                                          |bridgehead[$bridgehead.in.toc != 0]"/>
413   </xsl:call-template>
414 </xsl:template>
415
416 <xsl:template match="sect1" mode="toc">
417   <xsl:param name="toc-context" select="."/>
418   <xsl:call-template name="subtoc">
419     <xsl:with-param name="toc-context" select="$toc-context"/>
420     <xsl:with-param name="nodes" select="sect2
421                                          |bridgehead[$bridgehead.in.toc != 0]"/>
422   </xsl:call-template>
423 </xsl:template>
424
425 <xsl:template match="sect2" mode="toc">
426   <xsl:param name="toc-context" select="."/>
427
428   <xsl:call-template name="subtoc">
429     <xsl:with-param name="toc-context" select="$toc-context"/>
430     <xsl:with-param name="nodes" select="sect3
431                                          |bridgehead[$bridgehead.in.toc != 0]"/>
432   </xsl:call-template>
433 </xsl:template>
434
435 <xsl:template match="sect3" mode="toc">
436   <xsl:param name="toc-context" select="."/>
437
438   <xsl:call-template name="subtoc">
439     <xsl:with-param name="toc-context" select="$toc-context"/>
440     <xsl:with-param name="nodes" select="sect4
441                                          |bridgehead[$bridgehead.in.toc != 0]"/>
442   </xsl:call-template>
443 </xsl:template>
444
445 <xsl:template match="sect4" mode="toc">
446   <xsl:param name="toc-context" select="."/>
447
448   <xsl:call-template name="subtoc">
449     <xsl:with-param name="toc-context" select="$toc-context"/>
450     <xsl:with-param name="nodes" select="sect5
451                                          |bridgehead[$bridgehead.in.toc != 0]"/>
452   </xsl:call-template>
453 </xsl:template>
454
455 <xsl:template match="sect5" mode="toc">
456   <xsl:param name="toc-context" select="."/>
457
458   <xsl:call-template name="subtoc">
459     <xsl:with-param name="toc-context" select="$toc-context"/>
460   </xsl:call-template>
461 </xsl:template>
462
463 <xsl:template match="simplesect" mode="toc">
464   <xsl:param name="toc-context" select="."/>
465
466   <xsl:call-template name="subtoc">
467     <xsl:with-param name="toc-context" select="$toc-context"/>
468   </xsl:call-template>
469 </xsl:template>
470
471 <xsl:template match="section" mode="toc">
472   <xsl:param name="toc-context" select="."/>
473
474   <xsl:call-template name="subtoc">
475     <xsl:with-param name="toc-context" select="$toc-context"/>
476     <xsl:with-param name="nodes" select="section|refentry
477                                          |simplesect[$simplesect.in.toc != 0]
478                                          |bridgehead[$bridgehead.in.toc != 0]"/>
479   </xsl:call-template>
480 </xsl:template>
481
482 <xsl:template match="bridgehead" mode="toc">
483   <xsl:param name="toc-context" select="."/>
484
485   <xsl:if test="$bridgehead.in.toc != 0">
486     <xsl:call-template name="subtoc">
487       <xsl:with-param name="toc-context" select="$toc-context"/>
488     </xsl:call-template>
489   </xsl:if>
490 </xsl:template>
491
492 <xsl:template match="bibliography|glossary" mode="toc">
493   <xsl:param name="toc-context" select="."/>
494
495   <xsl:call-template name="subtoc">
496     <xsl:with-param name="toc-context" select="$toc-context"/>
497   </xsl:call-template>
498 </xsl:template>
499
500 <xsl:template match="index" mode="toc">
501   <xsl:param name="toc-context" select="."/>
502
503   <!-- If the index tag is not empty, it should be it in the TOC -->
504   <xsl:if test="* or $generate.index != 0">
505     <xsl:call-template name="subtoc">
506       <xsl:with-param name="toc-context" select="$toc-context"/>
507     </xsl:call-template>
508   </xsl:if>
509 </xsl:template>
510
511 <xsl:template match="refentry" mode="toc">
512   <xsl:param name="toc-context" select="."/>
513
514   <xsl:variable name="refmeta" select=".//refmeta"/>
515   <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
516   <xsl:variable name="refnamediv" select=".//refnamediv"/>
517   <xsl:variable name="refname" select="$refnamediv//refname"/>
518   <xsl:variable name="refdesc" select="$refnamediv//refdescriptor"/>
519   <xsl:variable name="title">
520     <xsl:choose>
521       <xsl:when test="$refentrytitle">
522         <xsl:apply-templates select="$refentrytitle[1]"
523                              mode="titleabbrev.markup"/>
524       </xsl:when>
525       <xsl:when test="$refdesc">
526         <xsl:apply-templates select="$refdesc"
527                              mode="titleabbrev.markup"/>
528       </xsl:when>
529       <xsl:when test="$refname">
530         <xsl:apply-templates select="$refname[1]"
531                              mode="titleabbrev.markup"/>
532       </xsl:when>
533     </xsl:choose>
534   </xsl:variable>
535
536   <xsl:element name="{$toc.listitem.type}">
537     <span class='refentrytitle'>
538       <a>
539         <xsl:attribute name="href">
540           <xsl:call-template name="href.target">
541             <xsl:with-param name="toc-context" select="$toc-context"/>
542           </xsl:call-template>
543         </xsl:attribute>
544         <xsl:copy-of select="$title"/>
545       </a>
546     </span>
547     <span class='refpurpose'>
548       <xsl:if test="$annotate.toc != 0">
549         <!-- * DocBook 5 says inlinemediaobject (among other things) -->
550         <!-- * is allowed in refpurpose; so we need to run -->
551         <!-- * apply-templates on refpurpose here, instead of value-of  -->
552         <xsl:apply-templates select="refnamediv/refpurpose"/>
553       </xsl:if>
554     </span>
555   </xsl:element>
556 </xsl:template>
557
558 <xsl:template match="title" mode="toc">
559   <xsl:param name="toc-context" select="."/>
560
561   <a>
562     <xsl:attribute name="href">
563       <xsl:call-template name="href.target">
564         <xsl:with-param name="object" select=".."/>
565         <xsl:with-param name="toc-context" select="$toc-context"/>
566       </xsl:call-template>
567     </xsl:attribute>
568     <xsl:apply-templates/>
569   </a>
570 </xsl:template>
571
572 <xsl:template name="manual-toc">
573   <xsl:param name="toc-context" select="."/>
574   <xsl:param name="tocentry"/>
575
576   <!-- be careful, we don't want to change the current document to the other tree! -->
577
578   <xsl:if test="$tocentry">
579     <xsl:variable name="node" select="key('id', $tocentry/@linkend)"/>
580
581     <xsl:element name="{$toc.listitem.type}">
582       <xsl:variable name="label">
583         <xsl:apply-templates select="$node" mode="label.markup"/>
584       </xsl:variable>
585       <xsl:copy-of select="$label"/>
586       <xsl:if test="$label != ''">
587         <xsl:value-of select="$autotoc.label.separator"/>
588       </xsl:if>
589       <a>
590         <xsl:attribute name="href">
591           <xsl:call-template name="href.target">
592             <xsl:with-param name="object" select="$node"/>
593             <xsl:with-param name="toc-context" select="$toc-context"/>
594           </xsl:call-template>
595         </xsl:attribute>
596         <xsl:apply-templates select="$node" mode="titleabbrev.markup"/>
597       </a>
598     </xsl:element>
599
600     <xsl:if test="$tocentry/*">
601       <xsl:element name="{$toc.list.type}">
602         <xsl:call-template name="manual-toc">
603           <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
604         </xsl:call-template>
605       </xsl:element>
606     </xsl:if>
607
608     <xsl:if test="$tocentry/following-sibling::*">
609       <xsl:call-template name="manual-toc">
610         <xsl:with-param name="tocentry" select="$tocentry/following-sibling::*[1]"/>
611       </xsl:call-template>
612     </xsl:if>
613   </xsl:if>
614 </xsl:template>
615
616 <!-- ==================================================================== -->
617
618 <xsl:template name="list.of.titles">
619   <xsl:param name="toc-context" select="."/>
620   <xsl:param name="titles" select="'table'"/>
621   <xsl:param name="nodes" select=".//table"/>
622
623   <xsl:if test="$nodes">
624     <div class="list-of-{$titles}s">
625       <xsl:choose>
626         <xsl:when test="$make.clean.html != 0">
627           <div class="toc-title">
628             <xsl:call-template name="gentext">
629               <xsl:with-param name="key">
630                 <xsl:choose>
631                   <xsl:when test="$titles='table'">ListofTables</xsl:when>
632                   <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
633                   <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
634                   <xsl:when test="$titles='example'">ListofExamples</xsl:when>
635                   <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
636                   <xsl:otherwise>ListofUnknown</xsl:otherwise>
637                 </xsl:choose>
638               </xsl:with-param>
639             </xsl:call-template>
640           </div>
641         </xsl:when>
642         <xsl:otherwise>
643           <p>
644             <b>
645               <xsl:call-template name="gentext">
646                 <xsl:with-param name="key">
647                   <xsl:choose>
648                     <xsl:when test="$titles='table'">ListofTables</xsl:when>
649                     <xsl:when test="$titles='figure'">ListofFigures</xsl:when>
650                     <xsl:when test="$titles='equation'">ListofEquations</xsl:when>
651                     <xsl:when test="$titles='example'">ListofExamples</xsl:when>
652                     <xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
653                     <xsl:otherwise>ListofUnknown</xsl:otherwise>
654                   </xsl:choose>
655                 </xsl:with-param>
656               </xsl:call-template>
657             </b>
658           </p>
659         </xsl:otherwise>
660       </xsl:choose>
661
662       <xsl:element name="{$toc.list.type}">
663         <xsl:apply-templates select="$nodes" mode="toc">
664           <xsl:with-param name="toc-context" select="$toc-context"/>
665         </xsl:apply-templates>
666       </xsl:element>
667     </div>
668   </xsl:if>
669 </xsl:template>
670
671 <xsl:template match="figure|table|example|equation|procedure" mode="toc">
672   <xsl:param name="toc-context" select="."/>
673
674   <xsl:element name="{$toc.listitem.type}">
675     <xsl:variable name="label">
676       <xsl:apply-templates select="." mode="label.markup"/>
677     </xsl:variable>
678     <xsl:copy-of select="$label"/>
679     <xsl:if test="$label != ''">
680       <xsl:value-of select="$autotoc.label.separator"/>
681     </xsl:if>
682     <a>
683       <xsl:attribute name="href">
684         <xsl:call-template name="href.target">
685           <xsl:with-param name="toc-context" select="$toc-context"/>
686         </xsl:call-template>
687       </xsl:attribute>
688       <xsl:apply-templates select="." mode="titleabbrev.markup"/>
689     </a>
690   </xsl:element>
691 </xsl:template>
692
693 <!-- Used only if qanda.in.toc parameter is non-zero -->
694 <xsl:template match="qandaset" mode="toc">
695   <xsl:param name="toc-context" select="."/>
696   <xsl:call-template name="subtoc">
697     <xsl:with-param name="toc-context" select="$toc-context"/>
698     <xsl:with-param name="nodes" select="qandadiv | qandaentry"/>
699   </xsl:call-template>
700 </xsl:template>
701
702 <xsl:template match="qandadiv|qandaentry" mode="toc">
703   <xsl:apply-templates select="." mode="qandatoc.mode"/>
704 </xsl:template>
705
706 </xsl:stylesheet>
707