]> git.stg.codes - stg.git/blob - doc/xslt/xhtml/autotoc.xsl
Set output encoding to utf-8.
[stg.git] / doc / xslt / xhtml / autotoc.xsl
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">
5
6 <!-- ********************************************************************
7      $Id: autotoc.xsl 8558 2009-12-11 00:33:17Z bobstayton $
8      ********************************************************************
9
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.
13
14      ******************************************************************** -->
15
16 <xsl:variable name="toc.listitem.type">
17   <xsl:choose>
18     <xsl:when test="$toc.list.type = 'dl'">dt</xsl:when>
19     <xsl:otherwise>li</xsl:otherwise>
20   </xsl:choose>
21 </xsl:variable>
22
23 <!-- this is just hack because dl and ul aren't completely isomorphic -->
24 <xsl:variable name="toc.dd.type">
25   <xsl:choose>
26     <xsl:when test="$toc.list.type = 'dl'">dd</xsl:when>
27     <xsl:otherwise/>
28   </xsl:choose>
29 </xsl:variable>
30
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"/>
35
36   <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
37
38   <xsl:variable name="toc.title">
39     <xsl:if test="$toc.title.p">
40       <xsl:choose>
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>
45             </xsl:call-template>
46           </div>
47         </xsl:when>
48         <xsl:otherwise>
49           <p>
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>
53               </xsl:call-template>
54             </strong>
55           </p>
56         </xsl:otherwise>
57       </xsl:choose>
58     </xsl:if>
59   </xsl:variable>
60
61   <xsl:choose>
62     <xsl:when test="$manual.toc != ''">
63       <xsl:variable name="id">
64         <xsl:call-template name="object.id"/>
65       </xsl:variable>
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/*">
69         <div class="toc">
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]"/>
74             </xsl:call-template>
75           </xsl:element>
76         </div>
77       </xsl:if>
78     </xsl:when>
79     <xsl:otherwise>
80       <xsl:choose>
81         <xsl:when test="$qanda.in.toc != 0">
82           <xsl:if test="$nodes.plus">
83             <div class="toc">
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>
89               </xsl:element>
90             </div>
91           </xsl:if>
92         </xsl:when>
93         <xsl:otherwise>
94           <xsl:if test="$nodes">
95             <div class="toc">
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>
101               </xsl:element>
102             </div>
103           </xsl:if>
104         </xsl:otherwise>
105       </xsl:choose>
106
107     </xsl:otherwise>
108   </xsl:choose>
109 </xsl:template>
110
111 <xsl:template name="make.lots">
112   <xsl:param name="toc.params" select="''"/>
113   <xsl:param name="toc"/>
114
115   <xsl:if test="contains($toc.params, 'toc')">
116     <xsl:copy-of select="$toc"/>
117   </xsl:if>
118
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"/>
123     </xsl:call-template>
124   </xsl:if>
125
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"/>
130     </xsl:call-template>
131   </xsl:if>
132
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"/>
137     </xsl:call-template>
138   </xsl:if>
139
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]"/>
144     </xsl:call-template>
145   </xsl:if>
146
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]"/>
151     </xsl:call-template>
152   </xsl:if>
153 </xsl:template>
154
155 <!-- ====================================================================== -->
156
157 <xsl:template name="set.toc">
158   <xsl:param name="toc-context" select="."/>
159   <xsl:param name="toc.title.p" select="true()"/>
160
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"/>
165   </xsl:call-template>
166 </xsl:template>
167
168 <xsl:template name="division.toc">
169   <xsl:param name="toc-context" select="."/>
170   <xsl:param name="toc.title.p" select="true()"/>
171
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]"/>
176
177   </xsl:call-template>
178 </xsl:template>
179
180 <xsl:template name="component.toc">
181   <xsl:param name="toc-context" select="."/>
182   <xsl:param name="toc.title.p" select="true()"/>
183
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]"/>
188   </xsl:call-template>
189 </xsl:template>
190
191 <xsl:template name="component.toc.separator">
192   <!-- Customize to output something between
193        component.toc and first output -->
194 </xsl:template>
195
196 <xsl:template name="section.toc">
197   <xsl:param name="toc-context" select="."/>
198   <xsl:param name="toc.title.p" select="true()"/>
199
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]"/>
204
205   </xsl:call-template>
206 </xsl:template>
207
208 <xsl:template name="section.toc.separator">
209   <!-- Customize to output something between
210        section.toc and first output -->
211 </xsl:template>
212 <!-- ==================================================================== -->
213
214 <xsl:template name="subtoc">
215   <xsl:param name="toc-context" select="."/>
216   <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
217
218   <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
219
220   <xsl:variable name="subtoc">
221     <xsl:element name="{$toc.list.type}" namespace="http://www.w3.org/1999/xhtml">
222       <xsl:choose>
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>
227         </xsl:when>
228         <xsl:otherwise>
229           <xsl:apply-templates mode="toc" select="$nodes">
230             <xsl:with-param name="toc-context" select="$toc-context"/>
231           </xsl:apply-templates>
232         </xsl:otherwise>
233       </xsl:choose>
234     </xsl:element>
235   </xsl:variable>
236
237   <xsl:variable name="depth">
238     <xsl:choose>
239       <xsl:when test="local-name(.) = 'section'">
240         <xsl:value-of select="count(ancestor::section) + 1"/>
241       </xsl:when>
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'">
251         <!-- sigh... -->
252         <xsl:choose>
253           <xsl:when test="local-name(..) = 'section'">
254             <xsl:value-of select="count(ancestor::section)"/>
255           </xsl:when>
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>
265         </xsl:choose>
266       </xsl:when>
267       <xsl:otherwise>0</xsl:otherwise>
268     </xsl:choose>
269   </xsl:variable>
270
271   <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
272
273   <xsl:variable name="subtoc.list">
274     <xsl:choose>
275       <xsl:when test="$toc.dd.type = ''">
276         <xsl:copy-of select="$subtoc"/>
277       </xsl:when>
278       <xsl:otherwise>
279         <xsl:element name="{$toc.dd.type}" namespace="http://www.w3.org/1999/xhtml">
280           <xsl:copy-of select="$subtoc"/>
281         </xsl:element>
282       </xsl:otherwise>
283     </xsl:choose>
284   </xsl:variable>
285
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"/>
289     </xsl:call-template>
290     <xsl:if test="$toc.listitem.type = 'li'                   and $toc.section.depth &gt; $depth and                    ( ($qanda.in.toc = 0 and count($nodes)&gt;0) or                     ($qanda.in.toc != 0 and count($nodes.plus)&gt;0) )                   and $toc.max.depth &gt; $depth.from.context">
291       <xsl:copy-of select="$subtoc.list"/>
292     </xsl:if>
293   </xsl:element>
294   <xsl:if test="$toc.listitem.type != 'li'                 and $toc.section.depth &gt; $depth and                  ( ($qanda.in.toc = 0 and count($nodes)&gt;0) or                   ($qanda.in.toc != 0 and count($nodes.plus)&gt;0) )                 and $toc.max.depth &gt; $depth.from.context">
295     <xsl:copy-of select="$subtoc.list"/>
296   </xsl:if>
297 </xsl:template>
298
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"/>
303
304  <span>
305   <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
306
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"/>
312     </xsl:variable>
313     <xsl:copy-of select="$label"/>
314     <xsl:if test="$label != ''">
315       <xsl:value-of select="$autotoc.label.separator"/>
316     </xsl:if>
317   </xsl:if>
318
319   <a>
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"/>
324       </xsl:call-template>
325     </xsl:attribute>
326     
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"/>
332     </xsl:variable>
333     <xsl:copy-of select="$label"/>
334     <xsl:if test="$label != ''">
335       <xsl:value-of select="$autotoc.label.separator"/>
336     </xsl:if>
337   </xsl:if>
338
339     <xsl:apply-templates select="." mode="titleabbrev.markup"/>
340   </a>
341   </span>
342 </xsl:template>
343
344 <xsl:template match="book" mode="toc">
345   <xsl:param name="toc-context" select="."/>
346
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]"/>
350   </xsl:call-template>
351 </xsl:template>
352
353 <xsl:template match="setindex" mode="toc">
354   <xsl:param name="toc-context" select="."/>
355
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"/>
360     </xsl:call-template>
361   </xsl:if>
362 </xsl:template>
363
364 <xsl:template match="part|reference" mode="toc">
365   <xsl:param name="toc-context" select="."/>
366
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]"/>
370   </xsl:call-template>
371 </xsl:template>
372
373 <xsl:template match="preface|chapter|appendix|article" mode="toc">
374   <xsl:param name="toc-context" select="."/>
375
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]"/>
379   </xsl:call-template>
380 </xsl:template>
381
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]"/>
387   </xsl:call-template>
388 </xsl:template>
389
390 <xsl:template match="sect2" mode="toc">
391   <xsl:param name="toc-context" select="."/>
392
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]"/>
396   </xsl:call-template>
397 </xsl:template>
398
399 <xsl:template match="sect3" mode="toc">
400   <xsl:param name="toc-context" select="."/>
401
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]"/>
405   </xsl:call-template>
406 </xsl:template>
407
408 <xsl:template match="sect4" mode="toc">
409   <xsl:param name="toc-context" select="."/>
410
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]"/>
414   </xsl:call-template>
415 </xsl:template>
416
417 <xsl:template match="sect5" mode="toc">
418   <xsl:param name="toc-context" select="."/>
419
420   <xsl:call-template name="subtoc">
421     <xsl:with-param name="toc-context" select="$toc-context"/>
422   </xsl:call-template>
423 </xsl:template>
424
425 <xsl:template match="simplesect" 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:call-template>
431 </xsl:template>
432
433 <xsl:template match="section" mode="toc">
434   <xsl:param name="toc-context" select="."/>
435
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]"/>
439   </xsl:call-template>
440 </xsl:template>
441
442 <xsl:template match="bridgehead" mode="toc">
443   <xsl:param name="toc-context" select="."/>
444
445   <xsl:if test="$bridgehead.in.toc != 0">
446     <xsl:call-template name="subtoc">
447       <xsl:with-param name="toc-context" select="$toc-context"/>
448     </xsl:call-template>
449   </xsl:if>
450 </xsl:template>
451
452 <xsl:template match="bibliography|glossary" mode="toc">
453   <xsl:param name="toc-context" select="."/>
454
455   <xsl:call-template name="subtoc">
456     <xsl:with-param name="toc-context" select="$toc-context"/>
457   </xsl:call-template>
458 </xsl:template>
459
460 <xsl:template match="index" mode="toc">
461   <xsl:param name="toc-context" select="."/>
462
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"/>
467     </xsl:call-template>
468   </xsl:if>
469 </xsl:template>
470
471 <xsl:template match="refentry" mode="toc">
472   <xsl:param name="toc-context" select="."/>
473
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">
480     <xsl:choose>
481       <xsl:when test="$refentrytitle">
482         <xsl:apply-templates select="$refentrytitle[1]" mode="titleabbrev.markup"/>
483       </xsl:when>
484       <xsl:when test="$refdesc">
485         <xsl:apply-templates select="$refdesc" mode="titleabbrev.markup"/>
486       </xsl:when>
487       <xsl:when test="$refname">
488         <xsl:apply-templates select="$refname[1]" mode="titleabbrev.markup"/>
489       </xsl:when>
490     </xsl:choose>
491   </xsl:variable>
492
493   <xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
494     <span class="refentrytitle">
495       <a>
496         <xsl:attribute name="href">
497           <xsl:call-template name="href.target">
498             <xsl:with-param name="toc-context" select="$toc-context"/>
499           </xsl:call-template>
500         </xsl:attribute>
501         <xsl:copy-of select="$title"/>
502       </a>
503     </span>
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"/>
510       </xsl:if>
511     </span>
512   </xsl:element>
513 </xsl:template>
514
515 <xsl:template match="title" mode="toc">
516   <xsl:param name="toc-context" select="."/>
517
518   <a>
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"/>
523       </xsl:call-template>
524     </xsl:attribute>
525     <xsl:apply-templates/>
526   </a>
527 </xsl:template>
528
529 <xsl:template name="manual-toc">
530   <xsl:param name="toc-context" select="."/>
531   <xsl:param name="tocentry"/>
532
533   <!-- be careful, we don't want to change the current document to the other tree! -->
534
535   <xsl:if test="$tocentry">
536     <xsl:variable name="node" select="key('id', $tocentry/@linkend)"/>
537
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"/>
541       </xsl:variable>
542       <xsl:copy-of select="$label"/>
543       <xsl:if test="$label != ''">
544         <xsl:value-of select="$autotoc.label.separator"/>
545       </xsl:if>
546       <a>
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"/>
551           </xsl:call-template>
552         </xsl:attribute>
553         <xsl:apply-templates select="$node" mode="titleabbrev.markup"/>
554       </a>
555     </xsl:element>
556
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]"/>
561         </xsl:call-template>
562       </xsl:element>
563     </xsl:if>
564
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]"/>
568       </xsl:call-template>
569     </xsl:if>
570   </xsl:if>
571 </xsl:template>
572
573 <!-- ==================================================================== -->
574
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"/>
579
580   <xsl:if test="$nodes">
581     <div class="list-of-{$titles}s">
582       <xsl:choose>
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">
587                 <xsl:choose>
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>
594                 </xsl:choose>
595               </xsl:with-param>
596             </xsl:call-template>
597           </div>
598         </xsl:when>
599         <xsl:otherwise>
600           <p>
601             <strong xmlns:xslo="http://www.w3.org/1999/XSL/Transform">
602               <xsl:call-template name="gentext">
603                 <xsl:with-param name="key">
604                   <xsl:choose>
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>
611                   </xsl:choose>
612                 </xsl:with-param>
613               </xsl:call-template>
614             </strong>
615           </p>
616         </xsl:otherwise>
617       </xsl:choose>
618
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>
623       </xsl:element>
624     </div>
625   </xsl:if>
626 </xsl:template>
627
628 <xsl:template match="figure|table|example|equation|procedure" mode="toc">
629   <xsl:param name="toc-context" select="."/>
630
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"/>
634     </xsl:variable>
635     <xsl:copy-of select="$label"/>
636     <xsl:if test="$label != ''">
637       <xsl:value-of select="$autotoc.label.separator"/>
638     </xsl:if>
639     <a>
640       <xsl:attribute name="href">
641         <xsl:call-template name="href.target">
642           <xsl:with-param name="toc-context" select="$toc-context"/>
643         </xsl:call-template>
644       </xsl:attribute>
645       <xsl:apply-templates select="." mode="titleabbrev.markup"/>
646     </a>
647   </xsl:element>
648 </xsl:template>
649
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"/>
656   </xsl:call-template>
657 </xsl:template>
658
659 <xsl:template match="qandadiv|qandaentry" mode="toc">
660   <xsl:apply-templates select="." mode="qandatoc.mode"/>
661 </xsl:template>
662
663 </xsl:stylesheet>