Debian Codegraph @

docbook-xsl-ns/xhtml/autotoc.xsl

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