source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/xhtml/chunktoc.xsl@ 15c7d39

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 15c7d39 was 15c7d39, checked in by Matthew Burgess <matthew@…>, 11 years ago

Update stylesheets to docbook-xsl-1.78.1.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 19.4 KB
Line 
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:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="doc">
5
6<!-- ********************************************************************
7 $Id: chunktoc.xsl 9286 2012-04-19 10:10:58Z 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<!-- ==================================================================== -->
17
18<xsl:import href="docbook.xsl"/>
19<xsl:import href="chunk-common.xsl"/>
20
21<xsl:template name="chunk">
22 <xsl:param name="node" select="."/>
23 <!-- returns 1 if $node is a chunk -->
24
25 <xsl:variable name="id">
26 <xsl:call-template name="object.id">
27 <xsl:with-param name="object" select="$node"/>
28 </xsl:call-template>
29 </xsl:variable>
30
31 <xsl:variable name="chunks" select="document($chunk.toc,/)"/>
32
33 <xsl:choose>
34 <xsl:when test="$chunks//tocentry[@linkend=$id]">1</xsl:when>
35 <xsl:otherwise>0</xsl:otherwise>
36 </xsl:choose>
37</xsl:template>
38
39<!-- ==================================================================== -->
40
41<xsl:template match="*" mode="chunk-filename">
42 <!-- returns the filename of a chunk -->
43
44 <xsl:variable name="id">
45 <xsl:call-template name="object.id"/>
46 </xsl:variable>
47
48 <xsl:variable name="chunks" select="document($chunk.toc,/)"/>
49
50 <xsl:variable name="chunk" select="$chunks//tocentry[@linkend=$id]"/>
51 <xsl:variable name="filename">
52 <xsl:call-template name="pi.dbhtml_filename">
53 <xsl:with-param name="node" select="$chunk"/>
54 </xsl:call-template>
55 </xsl:variable>
56
57 <xsl:choose>
58 <xsl:when test="$chunk">
59 <xsl:value-of select="$filename"/>
60 </xsl:when>
61 <xsl:otherwise>
62 <xsl:apply-templates select="parent::*" mode="chunk-filename"/>
63 </xsl:otherwise>
64 </xsl:choose>
65</xsl:template>
66
67<!-- ==================================================================== -->
68
69<xsl:template name="process-chunk">
70 <xsl:variable name="id">
71 <xsl:call-template name="object.id"/>
72 </xsl:variable>
73
74 <xsl:variable name="chunks" select="document($chunk.toc,/)"/>
75
76 <xsl:variable name="chunk" select="$chunks//tocentry[@linkend=$id]"/>
77 <xsl:variable name="prev-id" select="($chunk/preceding::tocentry |$chunk/ancestor::tocentry)[last()]/@linkend"/>
78 <xsl:variable name="next-id" select="($chunk/following::tocentry |$chunk/child::tocentry)[1]/@linkend"/>
79
80 <xsl:variable name="prev" select="key('id',$prev-id)"/>
81 <xsl:variable name="next" select="key('id',$next-id)"/>
82
83 <xsl:variable name="ischunk">
84 <xsl:call-template name="chunk"/>
85 </xsl:variable>
86
87 <xsl:variable name="chunkfn">
88 <xsl:if test="$ischunk='1'">
89 <xsl:apply-templates mode="chunk-filename" select="."/>
90 </xsl:if>
91 </xsl:variable>
92
93 <xsl:variable name="filename">
94 <xsl:call-template name="make-relative-filename">
95 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
96 <xsl:with-param name="base.name" select="$chunkfn"/>
97 </xsl:call-template>
98 </xsl:variable>
99
100 <xsl:choose>
101 <xsl:when test="$ischunk = 0">
102 <xsl:apply-imports/>
103 </xsl:when>
104
105 <xsl:otherwise>
106 <xsl:call-template name="write.chunk">
107 <xsl:with-param name="filename" select="$filename"/>
108 <xsl:with-param name="content">
109 <xsl:call-template name="chunk-element-content">
110 <xsl:with-param name="prev" select="$prev"/>
111 <xsl:with-param name="next" select="$next"/>
112 </xsl:call-template>
113 </xsl:with-param>
114 <xsl:with-param name="quiet" select="$chunk.quietly"/>
115 </xsl:call-template>
116 </xsl:otherwise>
117 </xsl:choose>
118</xsl:template>
119
120<!-- ==================================================================== -->
121
122<xsl:template match="set">
123 <xsl:call-template name="process-chunk"/>
124</xsl:template>
125
126<xsl:template match="book">
127 <xsl:call-template name="process-chunk"/>
128</xsl:template>
129
130<xsl:template match="book/appendix">
131 <xsl:call-template name="process-chunk"/>
132</xsl:template>
133
134<xsl:template match="book/glossary">
135 <xsl:call-template name="process-chunk"/>
136</xsl:template>
137
138<xsl:template match="book/bibliography">
139 <xsl:call-template name="process-chunk"/>
140</xsl:template>
141
142<xsl:template match="dedication" mode="dedication">
143 <xsl:call-template name="process-chunk"/>
144</xsl:template>
145
146<xsl:template match="preface|chapter">
147 <xsl:call-template name="process-chunk"/>
148</xsl:template>
149
150<xsl:template match="part|reference">
151 <xsl:call-template name="process-chunk"/>
152</xsl:template>
153
154<xsl:template match="refentry">
155 <xsl:call-template name="process-chunk"/>
156</xsl:template>
157
158<xsl:template match="colophon">
159 <xsl:call-template name="process-chunk"/>
160</xsl:template>
161
162<xsl:template match="article">
163 <xsl:call-template name="process-chunk"/>
164</xsl:template>
165
166<xsl:template match="topic">
167 <xsl:call-template name="process-chunk"/>
168</xsl:template>
169
170<xsl:template match="article/appendix">
171 <xsl:call-template name="process-chunk"/>
172</xsl:template>
173
174<xsl:template match="article/glossary">
175 <xsl:call-template name="process-chunk"/>
176</xsl:template>
177
178<xsl:template match="article/bibliography">
179 <xsl:call-template name="process-chunk"/>
180</xsl:template>
181
182<xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
183 <xsl:variable name="ischunk">
184 <xsl:call-template name="chunk"/>
185 </xsl:variable>
186
187 <xsl:choose>
188 <xsl:when test="$ischunk != 0">
189 <xsl:call-template name="process-chunk"/>
190 </xsl:when>
191 <xsl:otherwise>
192 <xsl:apply-imports/>
193 </xsl:otherwise>
194 </xsl:choose>
195</xsl:template>
196
197<xsl:template match="setindex |book/index |article/index">
198 <!-- some implementations use completely empty index tags to indicate -->
199 <!-- where an automatically generated index should be inserted. so -->
200 <!-- if the index is completely empty, skip it. -->
201 <xsl:if test="count(*)&gt;0 or $generate.index != '0'">
202 <xsl:call-template name="process-chunk"/>
203 </xsl:if>
204</xsl:template>
205
206<!-- ==================================================================== -->
207
208<xsl:template match="/">
209 <!-- * Get a title for current doc so that we let the user -->
210 <!-- * know what document we are processing at this point. -->
211 <xsl:variable name="doc.title">
212 <xsl:call-template name="get.doc.title"/>
213 </xsl:variable>
214 <xsl:choose>
215 <xsl:when test="$chunk.toc = ''">
216 <xsl:message terminate="yes">
217 <xsl:text>The chunk.toc file is not set.</xsl:text>
218 </xsl:message>
219 </xsl:when>
220 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
221 toss the namespace and continue. Use the docbook5 namespaced
222 stylesheets for DocBook5 if you don't want to use this feature.-->
223 <!-- include extra test for Xalan quirk -->
224 <xsl:when test="$exsl.node.set.available != 0 and (*/self::ng:* or */self::db:*)">
225 <xsl:call-template name="log.message">
226 <xsl:with-param name="level">Note</xsl:with-param>
227 <xsl:with-param name="source" select="$doc.title"/>
228 <xsl:with-param name="context-desc">
229 <xsl:text>namesp. cut</xsl:text>
230 </xsl:with-param>
231 <xsl:with-param name="message">
232 <xsl:text>stripped namespace before processing</xsl:text>
233 </xsl:with-param>
234 </xsl:call-template>
235 <xsl:variable name="nons">
236 <xsl:apply-templates mode="stripNS"/>
237 </xsl:variable>
238 <xsl:call-template name="log.message">
239 <xsl:with-param name="level">Note</xsl:with-param>
240 <xsl:with-param name="source" select="$doc.title"/>
241 <xsl:with-param name="context-desc">
242 <xsl:text>namesp. cut</xsl:text>
243 </xsl:with-param>
244 <xsl:with-param name="message">
245 <xsl:text>processing stripped document</xsl:text>
246 </xsl:with-param>
247 </xsl:call-template>
248 <xsl:apply-templates select="exsl:node-set($nons)"/>
249 </xsl:when>
250 <!-- Can't process unless namespace removed -->
251 <xsl:when test="*/self::ng:* or */self::db:*">
252 <xsl:message terminate="yes">
253 <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
254 <xsl:text> cannot proceed.</xsl:text>
255 </xsl:message>
256 </xsl:when>
257 <xsl:otherwise>
258 <xsl:choose>
259 <xsl:when test="$rootid != ''">
260 <xsl:choose>
261 <xsl:when test="count(key('id',$rootid)) = 0">
262 <xsl:message terminate="yes">
263 <xsl:text>ID '</xsl:text>
264 <xsl:value-of select="$rootid"/>
265 <xsl:text>' not found in document.</xsl:text>
266 </xsl:message>
267 </xsl:when>
268 <xsl:otherwise>
269 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
270 <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
271 </xsl:if>
272 <xsl:if test="$collect.xref.targets != 'only'">
273 <xsl:apply-templates select="key('id',$rootid)" mode="process.root"/>
274 <xsl:if test="$tex.math.in.alt != ''">
275 <xsl:apply-templates select="key('id',$rootid)" mode="collect.tex.math"/>
276 </xsl:if>
277 <xsl:if test="$generate.manifest != 0">
278 <xsl:call-template name="generate.manifest">
279 <xsl:with-param name="node" select="key('id',$rootid)"/>
280 </xsl:call-template>
281 </xsl:if>
282 </xsl:if>
283 </xsl:otherwise>
284 </xsl:choose>
285 </xsl:when>
286 <xsl:otherwise>
287 <xsl:if test="$collect.xref.targets = 'yes' or $collect.xref.targets = 'only'">
288 <xsl:apply-templates select="/" mode="collect.targets"/>
289 </xsl:if>
290 <xsl:if test="$collect.xref.targets != 'only'">
291 <xsl:apply-templates select="/" mode="process.root"/>
292 <xsl:if test="$tex.math.in.alt != ''">
293 <xsl:apply-templates select="/" mode="collect.tex.math"/>
294 </xsl:if>
295 <xsl:if test="$generate.manifest != 0">
296 <xsl:call-template name="generate.manifest">
297 <xsl:with-param name="node" select="/"/>
298 </xsl:call-template>
299 </xsl:if>
300 </xsl:if>
301 </xsl:otherwise>
302 </xsl:choose>
303 </xsl:otherwise>
304 </xsl:choose>
305</xsl:template>
306
307<xsl:template match="*" mode="process.root">
308 <xsl:apply-templates select="."/>
309 <xsl:call-template name="generate.css"/>
310</xsl:template>
311
312<xsl:template name="make.lots">
313 <xsl:param name="toc.params" select="''"/>
314 <xsl:param name="toc"/>
315
316 <xsl:variable name="lots">
317 <xsl:if test="contains($toc.params, 'toc')">
318 <xsl:copy-of select="$toc"/>
319 </xsl:if>
320
321 <xsl:if test="contains($toc.params, 'figure')">
322 <xsl:choose>
323 <xsl:when test="$chunk.separate.lots != '0'">
324 <xsl:call-template name="make.lot.chunk">
325 <xsl:with-param name="type" select="'figure'"/>
326 <xsl:with-param name="lot">
327 <xsl:call-template name="list.of.titles">
328 <xsl:with-param name="titles" select="'figure'"/>
329 <xsl:with-param name="nodes" select=".//figure"/>
330 </xsl:call-template>
331 </xsl:with-param>
332 </xsl:call-template>
333 </xsl:when>
334 <xsl:otherwise>
335 <xsl:call-template name="list.of.titles">
336 <xsl:with-param name="titles" select="'figure'"/>
337 <xsl:with-param name="nodes" select=".//figure"/>
338 </xsl:call-template>
339 </xsl:otherwise>
340 </xsl:choose>
341 </xsl:if>
342
343 <xsl:if test="contains($toc.params, 'table')">
344 <xsl:choose>
345 <xsl:when test="$chunk.separate.lots != '0'">
346 <xsl:call-template name="make.lot.chunk">
347 <xsl:with-param name="type" select="'table'"/>
348 <xsl:with-param name="lot">
349 <xsl:call-template name="list.of.titles">
350 <xsl:with-param name="titles" select="'table'"/>
351 <xsl:with-param name="nodes" select=".//table"/>
352 </xsl:call-template>
353 </xsl:with-param>
354 </xsl:call-template>
355 </xsl:when>
356 <xsl:otherwise>
357 <xsl:call-template name="list.of.titles">
358 <xsl:with-param name="titles" select="'table'"/>
359 <xsl:with-param name="nodes" select=".//table"/>
360 </xsl:call-template>
361 </xsl:otherwise>
362 </xsl:choose>
363 </xsl:if>
364
365 <xsl:if test="contains($toc.params, 'example')">
366 <xsl:choose>
367 <xsl:when test="$chunk.separate.lots != '0'">
368 <xsl:call-template name="make.lot.chunk">
369 <xsl:with-param name="type" select="'example'"/>
370 <xsl:with-param name="lot">
371 <xsl:call-template name="list.of.titles">
372 <xsl:with-param name="titles" select="'example'"/>
373 <xsl:with-param name="nodes" select=".//example"/>
374 </xsl:call-template>
375 </xsl:with-param>
376 </xsl:call-template>
377 </xsl:when>
378 <xsl:otherwise>
379 <xsl:call-template name="list.of.titles">
380 <xsl:with-param name="titles" select="'example'"/>
381 <xsl:with-param name="nodes" select=".//example"/>
382 </xsl:call-template>
383 </xsl:otherwise>
384 </xsl:choose>
385 </xsl:if>
386
387 <xsl:if test="contains($toc.params, 'equation')">
388 <xsl:choose>
389 <xsl:when test="$chunk.separate.lots != '0'">
390 <xsl:call-template name="make.lot.chunk">
391 <xsl:with-param name="type" select="'equation'"/>
392 <xsl:with-param name="lot">
393 <xsl:call-template name="list.of.titles">
394 <xsl:with-param name="titles" select="'equation'"/>
395 <xsl:with-param name="nodes" select=".//equation"/>
396 </xsl:call-template>
397 </xsl:with-param>
398 </xsl:call-template>
399 </xsl:when>
400 <xsl:otherwise>
401 <xsl:call-template name="list.of.titles">
402 <xsl:with-param name="titles" select="'equation'"/>
403 <xsl:with-param name="nodes" select=".//equation"/>
404 </xsl:call-template>
405 </xsl:otherwise>
406 </xsl:choose>
407 </xsl:if>
408
409 <xsl:if test="contains($toc.params, 'procedure')">
410 <xsl:choose>
411 <xsl:when test="$chunk.separate.lots != '0'">
412 <xsl:call-template name="make.lot.chunk">
413 <xsl:with-param name="type" select="'procedure'"/>
414 <xsl:with-param name="lot">
415 <xsl:call-template name="list.of.titles">
416 <xsl:with-param name="titles" select="'procedure'"/>
417 <xsl:with-param name="nodes" select=".//procedure[title]"/>
418 </xsl:call-template>
419 </xsl:with-param>
420 </xsl:call-template>
421 </xsl:when>
422 <xsl:otherwise>
423 <xsl:call-template name="list.of.titles">
424 <xsl:with-param name="titles" select="'procedure'"/>
425 <xsl:with-param name="nodes" select=".//procedure[title]"/>
426 </xsl:call-template>
427 </xsl:otherwise>
428 </xsl:choose>
429 </xsl:if>
430 </xsl:variable>
431
432 <xsl:if test="string($lots) != ''">
433 <xsl:choose>
434 <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
435 <xsl:call-template name="write.chunk">
436 <xsl:with-param name="filename">
437 <xsl:call-template name="make-relative-filename">
438 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
439 <xsl:with-param name="base.name">
440 <xsl:call-template name="dbhtml-dir"/>
441 <xsl:apply-templates select="." mode="recursive-chunk-filename">
442 <xsl:with-param name="recursive" select="true()"/>
443 </xsl:apply-templates>
444 <xsl:text>-toc</xsl:text>
445 <xsl:value-of select="$html.ext"/>
446 </xsl:with-param>
447 </xsl:call-template>
448 </xsl:with-param>
449 <xsl:with-param name="content">
450 <xsl:call-template name="chunk-element-content">
451 <xsl:with-param name="prev" select="/foo"/>
452 <xsl:with-param name="next" select="/foo"/>
453 <xsl:with-param name="nav.context" select="'toc'"/>
454 <xsl:with-param name="content">
455 <h1>
456 <xsl:apply-templates select="." mode="object.title.markup"/>
457 </h1>
458 <xsl:copy-of select="$lots"/>
459 </xsl:with-param>
460 </xsl:call-template>
461 </xsl:with-param>
462 <xsl:with-param name="quiet" select="$chunk.quietly"/>
463 </xsl:call-template>
464 </xsl:when>
465 <xsl:otherwise>
466 <xsl:copy-of select="$lots"/>
467 </xsl:otherwise>
468 </xsl:choose>
469 </xsl:if>
470</xsl:template>
471
472<xsl:template name="make.lot.chunk">
473 <xsl:param name="type" select="''"/>
474 <xsl:param name="lot"/>
475
476 <xsl:if test="string($lot) != ''">
477 <xsl:variable name="filename">
478 <xsl:call-template name="make-relative-filename">
479 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
480 <xsl:with-param name="base.name">
481 <xsl:call-template name="dbhtml-dir"/>
482 <xsl:value-of select="$type"/>
483 <xsl:text>-toc</xsl:text>
484 <xsl:value-of select="$html.ext"/>
485 </xsl:with-param>
486 </xsl:call-template>
487 </xsl:variable>
488
489 <xsl:variable name="href">
490 <xsl:call-template name="make-relative-filename">
491 <xsl:with-param name="base.dir" select="''"/>
492 <xsl:with-param name="base.name">
493 <xsl:call-template name="dbhtml-dir"/>
494 <xsl:value-of select="$type"/>
495 <xsl:text>-toc</xsl:text>
496 <xsl:value-of select="$html.ext"/>
497 </xsl:with-param>
498 </xsl:call-template>
499 </xsl:variable>
500
501 <xsl:call-template name="write.chunk">
502 <xsl:with-param name="filename" select="$filename"/>
503 <xsl:with-param name="content">
504 <xsl:call-template name="chunk-element-content">
505 <xsl:with-param name="prev" select="/foo"/>
506 <xsl:with-param name="next" select="/foo"/>
507 <xsl:with-param name="nav.context" select="'toc'"/>
508 <xsl:with-param name="content">
509 <xsl:copy-of select="$lot"/>
510 </xsl:with-param>
511 </xsl:call-template>
512 </xsl:with-param>
513 <xsl:with-param name="quiet" select="$chunk.quietly"/>
514 </xsl:call-template>
515 <!-- And output a link to this file -->
516 <div>
517 <xsl:attribute name="class">
518 <xsl:text>ListofTitles</xsl:text>
519 </xsl:attribute>
520 <a href="{$href}">
521 <xsl:call-template name="gentext">
522 <xsl:with-param name="key">
523 <xsl:choose>
524 <xsl:when test="$type='table'">ListofTables</xsl:when>
525 <xsl:when test="$type='figure'">ListofFigures</xsl:when>
526 <xsl:when test="$type='equation'">ListofEquations</xsl:when>
527 <xsl:when test="$type='example'">ListofExamples</xsl:when>
528 <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
529 <xsl:otherwise>ListofUnknown</xsl:otherwise>
530 </xsl:choose>
531 </xsl:with-param>
532 </xsl:call-template>
533 </a>
534 </div>
535 </xsl:if>
536</xsl:template>
537
538</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.