1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2 xmlns:exsl="http://exslt.org/common"
3 xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
4 xmlns:ng="http://docbook.org/docbook-ng"
5 xmlns:db="http://docbook.org/ns/docbook"
7 exclude-result-prefixes="exsl cf ng db">
9 <!-- ********************************************************************
10 $Id: chunk-common.xsl 9717 2013-01-25 18:13:36Z bobstayton $
11 ********************************************************************
13 This file is part of the XSL DocBook Stylesheet distribution.
14 See ../README or http://docbook.sf.net/release/xsl/current/ for
15 copyright and other information.
17 ******************************************************************** -->
19 <!-- ==================================================================== -->
21 <xsl:param name="onechunk" select="0"/>
22 <xsl:param name="refentry.separator" select="0"/>
23 <xsl:param name="chunk.fast" select="0"/>
25 <xsl:key name="genid" match="*" use="generate-id()"/>
27 <!-- ==================================================================== -->
29 <xsl:variable name="chunk.hierarchy">
30 <xsl:if test="$chunk.fast != 0">
32 <!-- Are we handling a docbook5 document? -->
33 <xsl:when test="$exsl.node.set.available != 0
34 and (*/self::ng:* or */self::db:*)">
35 <xsl:if test="$chunk.quietly = 0">
36 <xsl:message>Computing stripped namespace chunks...</xsl:message>
38 <xsl:apply-templates mode="find.chunks" select="exsl:node-set($no.namespace)"/>
40 <xsl:when test="$exsl.node.set.available != 0">
41 <xsl:if test="$chunk.quietly = 0">
42 <xsl:message>Computing chunks...</xsl:message>
45 <xsl:apply-templates select="/*" mode="find.chunks"/>
48 <xsl:if test="$chunk.quietly = 0">
50 <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
51 <xsl:text>Using "slow" chunking.</xsl:text>
59 <!-- ==================================================================== -->
61 <xsl:template name="process-chunk-element">
62 <xsl:param name="content">
67 <xsl:when test="$chunk.fast != 0 and $exsl.node.set.available != 0">
68 <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
69 <xsl:variable name="genid" select="generate-id()"/>
71 <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
73 <xsl:variable name="prevdiv"
74 select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
75 <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
77 <xsl:variable name="nextdiv"
78 select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
79 <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
82 <xsl:when test="$onechunk != 0 and parent::*">
83 <xsl:copy-of select="$content"/>
86 <xsl:call-template name="process-chunk">
87 <xsl:with-param name="prev" select="$prev"/>
88 <xsl:with-param name="next" select="$next"/>
89 <xsl:with-param name="content" select="$content"/>
96 <xsl:when test="$onechunk != 0 and not(parent::*)">
97 <xsl:call-template name="chunk-all-sections">
98 <xsl:with-param name="content" select="$content"/>
101 <xsl:when test="$onechunk != 0">
102 <xsl:copy-of select="$content"/>
104 <xsl:when test="$chunk.first.sections = 0">
105 <xsl:call-template name="chunk-first-section-with-parent">
106 <xsl:with-param name="content" select="$content"/>
110 <xsl:call-template name="chunk-all-sections">
111 <xsl:with-param name="content" select="$content"/>
119 <xsl:template name="process-chunk">
120 <xsl:param name="prev" select="."/>
121 <xsl:param name="next" select="."/>
122 <xsl:param name="content">
126 <xsl:variable name="ischunk">
127 <xsl:call-template name="chunk"/>
130 <xsl:variable name="chunkfn">
131 <xsl:if test="$ischunk='1'">
132 <xsl:apply-templates mode="chunk-filename" select="."/>
136 <xsl:if test="$ischunk='0'">
138 <xsl:text>Error </xsl:text>
139 <xsl:value-of select="name(.)"/>
140 <xsl:text> is not a chunk!</xsl:text>
144 <xsl:variable name="filename">
145 <xsl:call-template name="make-relative-filename">
146 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
147 <xsl:with-param name="base.name" select="$chunkfn"/>
151 <xsl:call-template name="write.chunk">
152 <xsl:with-param name="filename" select="$filename"/>
153 <xsl:with-param name="content">
154 <xsl:call-template name="chunk-element-content">
155 <xsl:with-param name="prev" select="$prev"/>
156 <xsl:with-param name="next" select="$next"/>
157 <xsl:with-param name="content" select="$content"/>
160 <xsl:with-param name="quiet" select="$chunk.quietly"/>
164 <xsl:template name="chunk-first-section-with-parent">
165 <xsl:param name="content">
169 <!-- These xpath expressions are really hairy. The trick is to pick sections -->
170 <!-- that are not first children and are not the children of first children -->
172 <!-- Break these variables into pieces to work around
173 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
175 <xsl:variable name="prev-v1"
176 select="(ancestor::sect1[$chunk.section.depth > 0
177 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
178 and preceding-sibling::sect1][1]
180 |ancestor::sect2[$chunk.section.depth > 1
181 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
182 and preceding-sibling::sect2
183 and parent::sect1[preceding-sibling::sect1]][1]
185 |ancestor::sect3[$chunk.section.depth > 2
186 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
187 and preceding-sibling::sect3
188 and parent::sect2[preceding-sibling::sect2]
189 and ancestor::sect1[preceding-sibling::sect1]][1]
191 |ancestor::sect4[$chunk.section.depth > 3
192 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
193 and preceding-sibling::sect4
194 and parent::sect3[preceding-sibling::sect3]
195 and ancestor::sect2[preceding-sibling::sect2]
196 and ancestor::sect1[preceding-sibling::sect1]][1]
198 |ancestor::sect5[$chunk.section.depth > 4
199 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
200 and preceding-sibling::sect5
201 and parent::sect4[preceding-sibling::sect4]
202 and ancestor::sect3[preceding-sibling::sect3]
203 and ancestor::sect2[preceding-sibling::sect2]
204 and ancestor::sect1[preceding-sibling::sect1]][1]
206 |ancestor::section[$chunk.section.depth > count(ancestor::section)
207 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
208 and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
210 <xsl:variable name="prev-v2"
211 select="(preceding::sect1[$chunk.section.depth > 0
212 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
213 and preceding-sibling::sect1][1]
215 |preceding::sect2[$chunk.section.depth > 1
216 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
217 and preceding-sibling::sect2
218 and parent::sect1[preceding-sibling::sect1]][1]
220 |preceding::sect3[$chunk.section.depth > 2
221 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
222 and preceding-sibling::sect3
223 and parent::sect2[preceding-sibling::sect2]
224 and ancestor::sect1[preceding-sibling::sect1]][1]
226 |preceding::sect4[$chunk.section.depth > 3
227 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
228 and preceding-sibling::sect4
229 and parent::sect3[preceding-sibling::sect3]
230 and ancestor::sect2[preceding-sibling::sect2]
231 and ancestor::sect1[preceding-sibling::sect1]][1]
233 |preceding::sect5[$chunk.section.depth > 4
234 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
235 and preceding-sibling::sect5
236 and parent::sect4[preceding-sibling::sect4]
237 and ancestor::sect3[preceding-sibling::sect3]
238 and ancestor::sect2[preceding-sibling::sect2]
239 and ancestor::sect1[preceding-sibling::sect1]][1]
241 |preceding::section[$chunk.section.depth > count(ancestor::section)
242 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
243 and preceding-sibling::section
244 and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
246 <xsl:variable name="prev"
247 select="(preceding::book[1]
248 |preceding::preface[1]
249 |preceding::chapter[1]
250 |preceding::appendix[1]
252 |preceding::reference[1]
253 |preceding::refentry[1]
254 |preceding::colophon[1]
255 |preceding::article[1]
257 |preceding::bibliography[parent::article or parent::book or parent::part][1]
258 |preceding::glossary[parent::article or parent::book or parent::part][1]
259 |preceding::index[$generate.index != 0]
260 [parent::article or parent::book or parent::part][1]
261 |preceding::setindex[$generate.index != 0][1]
264 |ancestor::preface[1]
265 |ancestor::chapter[1]
266 |ancestor::appendix[1]
268 |ancestor::reference[1]
269 |ancestor::article[1]
272 |$prev-v2)[last()]"/>
274 <xsl:variable name="next-v1"
275 select="(following::sect1[$chunk.section.depth > 0
276 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
277 and preceding-sibling::sect1][1]
279 |following::sect2[$chunk.section.depth > 1
280 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
281 and preceding-sibling::sect2
282 and parent::sect1[preceding-sibling::sect1]][1]
284 |following::sect3[$chunk.section.depth > 2
285 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
286 and preceding-sibling::sect3
287 and parent::sect2[preceding-sibling::sect2]
288 and ancestor::sect1[preceding-sibling::sect1]][1]
290 |following::sect4[$chunk.section.depth > 3
291 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
292 and preceding-sibling::sect4
293 and parent::sect3[preceding-sibling::sect3]
294 and ancestor::sect2[preceding-sibling::sect2]
295 and ancestor::sect1[preceding-sibling::sect1]][1]
297 |following::sect5[$chunk.section.depth > 4
298 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
299 and preceding-sibling::sect5
300 and parent::sect4[preceding-sibling::sect4]
301 and ancestor::sect3[preceding-sibling::sect3]
302 and ancestor::sect2[preceding-sibling::sect2]
303 and ancestor::sect1[preceding-sibling::sect1]][1]
305 |following::section[$chunk.section.depth > count(ancestor::section)
306 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
307 and preceding-sibling::section
308 and not(ancestor::section[not(preceding-sibling::section)])][1])[1]"/>
310 <xsl:variable name="next-v2"
311 select="(descendant::sect1[$chunk.section.depth > 0
312 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
313 and preceding-sibling::sect1][1]
315 |descendant::sect2[$chunk.section.depth > 1
316 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
317 and preceding-sibling::sect2
318 and parent::sect1[preceding-sibling::sect1]][1]
320 |descendant::sect3[$chunk.section.depth > 2
321 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
322 and preceding-sibling::sect3
323 and parent::sect2[preceding-sibling::sect2]
324 and ancestor::sect1[preceding-sibling::sect1]][1]
326 |descendant::sect4[$chunk.section.depth > 3
327 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
328 and preceding-sibling::sect4
329 and parent::sect3[preceding-sibling::sect3]
330 and ancestor::sect2[preceding-sibling::sect2]
331 and ancestor::sect1[preceding-sibling::sect1]][1]
333 |descendant::sect5[$chunk.section.depth > 4
334 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
335 and preceding-sibling::sect5
336 and parent::sect4[preceding-sibling::sect4]
337 and ancestor::sect3[preceding-sibling::sect3]
338 and ancestor::sect2[preceding-sibling::sect2]
339 and ancestor::sect1[preceding-sibling::sect1]][1]
341 |descendant::section[$chunk.section.depth > count(ancestor::section)
342 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
343 and preceding-sibling::section
344 and not(ancestor::section[not(preceding-sibling::section)])])[1]"/>
346 <xsl:variable name="next"
347 select="(following::book[1]
348 |following::preface[1]
349 |following::chapter[1]
350 |following::appendix[1]
352 |following::reference[1]
353 |following::refentry[1]
354 |following::colophon[1]
355 |following::bibliography[parent::article or parent::book or parent::part][1]
356 |following::glossary[parent::article or parent::book or parent::part][1]
357 |following::index[$generate.index != 0]
358 [parent::article or parent::book or parent::part][1]
359 |following::article[1]
361 |following::setindex[$generate.index != 0][1]
363 |descendant::preface[1]
364 |descendant::chapter[1]
365 |descendant::appendix[1]
366 |descendant::article[1]
367 |descendant::topic[1]
368 |descendant::bibliography[parent::article or parent::book or parent::part][1]
369 |descendant::glossary[parent::article or parent::book or parent::part][1]
370 |descendant::index[$generate.index != 0]
371 [parent::article or parent::book or parent::part][1]
372 |descendant::colophon[1]
373 |descendant::setindex[$generate.index != 0][1]
375 |descendant::reference[1]
376 |descendant::refentry[1]
380 <xsl:call-template name="process-chunk">
381 <xsl:with-param name="prev" select="$prev"/>
382 <xsl:with-param name="next" select="$next"/>
383 <xsl:with-param name="content" select="$content"/>
387 <xsl:template name="chunk-all-sections">
388 <xsl:param name="content">
392 <xsl:variable name="prev-v1"
393 select="(preceding::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
394 |preceding::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
395 |preceding::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
396 |preceding::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
397 |preceding::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
398 |preceding::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
400 <xsl:variable name="prev-v2"
401 select="(ancestor::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
402 |ancestor::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
403 |ancestor::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
404 |ancestor::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
405 |ancestor::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
406 |ancestor::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
408 <xsl:variable name="prev"
409 select="(preceding::book[1]
410 |preceding::preface[1]
411 |preceding::chapter[1]
412 |preceding::appendix[1]
414 |preceding::reference[1]
415 |preceding::refentry[1]
416 |preceding::colophon[1]
417 |preceding::article[1]
419 |preceding::bibliography[parent::article or parent::book or parent::part][1]
420 |preceding::glossary[parent::article or parent::book or parent::part][1]
421 |preceding::index[$generate.index != 0]
422 [parent::article or parent::book or parent::part][1]
423 |preceding::setindex[$generate.index != 0][1]
426 |ancestor::preface[1]
427 |ancestor::chapter[1]
428 |ancestor::appendix[1]
430 |ancestor::reference[1]
431 |ancestor::article[1]
434 |$prev-v2)[last()]"/>
436 <xsl:variable name="next-v1"
437 select="(following::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
438 |following::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
439 |following::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
440 |following::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
441 |following::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
442 |following::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
444 <xsl:variable name="next-v2"
445 select="(descendant::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
446 |descendant::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
447 |descendant::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
448 |descendant::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
449 |descendant::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
450 |descendant::section[$chunk.section.depth
451 > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
453 <xsl:variable name="next"
454 select="(following::book[1]
455 |following::preface[1]
456 |following::chapter[1]
457 |following::appendix[1]
459 |following::reference[1]
460 |following::refentry[1]
461 |following::colophon[1]
462 |following::bibliography[parent::article or parent::book or parent::part][1]
463 |following::glossary[parent::article or parent::book or parent::part][1]
464 |following::index[$generate.index != 0]
465 [parent::article or parent::book][1]
466 |following::article[1]
468 |following::setindex[$generate.index != 0][1]
470 |descendant::preface[1]
471 |descendant::chapter[1]
472 |descendant::appendix[1]
473 |descendant::article[1]
474 |descendant::topic[1]
475 |descendant::bibliography[parent::article or parent::book][1]
476 |descendant::glossary[parent::article or parent::book or parent::part][1]
477 |descendant::index[$generate.index != 0]
478 [parent::article or parent::book][1]
479 |descendant::colophon[1]
480 |descendant::setindex[$generate.index != 0][1]
482 |descendant::reference[1]
483 |descendant::refentry[1]
487 <xsl:call-template name="process-chunk">
488 <xsl:with-param name="prev" select="$prev"/>
489 <xsl:with-param name="next" select="$next"/>
490 <xsl:with-param name="content" select="$content"/>
494 <!-- ==================================================================== -->
496 <!-- ==================================================================== -->
498 <xsl:template name="make.lots">
499 <xsl:param name="toc.params" select="''"/>
500 <xsl:param name="toc"/>
502 <xsl:variable name="lots">
503 <xsl:if test="contains($toc.params, 'toc')">
504 <xsl:copy-of select="$toc"/>
507 <xsl:if test="contains($toc.params, 'figure')">
509 <xsl:when test="$chunk.separate.lots != '0'">
510 <xsl:call-template name="make.lot.chunk">
511 <xsl:with-param name="type" select="'figure'"/>
512 <xsl:with-param name="lot">
513 <xsl:call-template name="list.of.titles">
514 <xsl:with-param name="titles" select="'figure'"/>
515 <xsl:with-param name="nodes" select=".//figure"/>
521 <xsl:call-template name="list.of.titles">
522 <xsl:with-param name="titles" select="'figure'"/>
523 <xsl:with-param name="nodes" select=".//figure"/>
529 <xsl:if test="contains($toc.params, 'table')">
531 <xsl:when test="$chunk.separate.lots != '0'">
532 <xsl:call-template name="make.lot.chunk">
533 <xsl:with-param name="type" select="'table'"/>
534 <xsl:with-param name="lot">
535 <xsl:call-template name="list.of.titles">
536 <xsl:with-param name="titles" select="'table'"/>
537 <xsl:with-param name="nodes" select=".//table[not(@tocentry = 0)]"/>
543 <xsl:call-template name="list.of.titles">
544 <xsl:with-param name="titles" select="'table'"/>
545 <xsl:with-param name="nodes" select=".//table[not(@tocentry = 0)]"/>
551 <xsl:if test="contains($toc.params, 'example')">
553 <xsl:when test="$chunk.separate.lots != '0'">
554 <xsl:call-template name="make.lot.chunk">
555 <xsl:with-param name="type" select="'example'"/>
556 <xsl:with-param name="lot">
557 <xsl:call-template name="list.of.titles">
558 <xsl:with-param name="titles" select="'example'"/>
559 <xsl:with-param name="nodes" select=".//example"/>
565 <xsl:call-template name="list.of.titles">
566 <xsl:with-param name="titles" select="'example'"/>
567 <xsl:with-param name="nodes" select=".//example"/>
573 <xsl:if test="contains($toc.params, 'equation')">
575 <xsl:when test="$chunk.separate.lots != '0'">
576 <xsl:call-template name="make.lot.chunk">
577 <xsl:with-param name="type" select="'equation'"/>
578 <xsl:with-param name="lot">
579 <xsl:call-template name="list.of.titles">
580 <xsl:with-param name="titles" select="'equation'"/>
581 <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
587 <xsl:call-template name="list.of.titles">
588 <xsl:with-param name="titles" select="'equation'"/>
589 <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
595 <xsl:if test="contains($toc.params, 'procedure')">
597 <xsl:when test="$chunk.separate.lots != '0'">
598 <xsl:call-template name="make.lot.chunk">
599 <xsl:with-param name="type" select="'procedure'"/>
600 <xsl:with-param name="lot">
601 <xsl:call-template name="list.of.titles">
602 <xsl:with-param name="titles" select="'procedure'"/>
603 <xsl:with-param name="nodes" select=".//procedure[title]"/>
609 <xsl:call-template name="list.of.titles">
610 <xsl:with-param name="titles" select="'procedure'"/>
611 <xsl:with-param name="nodes" select=".//procedure[title]"/>
618 <xsl:if test="string($lots) != ''">
620 <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
621 <xsl:call-template name="write.chunk">
622 <xsl:with-param name="filename">
623 <xsl:call-template name="make-relative-filename">
624 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
625 <xsl:with-param name="base.name">
626 <xsl:call-template name="dbhtml-dir"/>
627 <xsl:value-of select="$chunked.filename.prefix"/>
628 <xsl:apply-templates select="." mode="recursive-chunk-filename">
629 <xsl:with-param name="recursive" select="true()"/>
630 </xsl:apply-templates>
631 <xsl:text>-toc</xsl:text>
632 <xsl:value-of select="$html.ext"/>
636 <xsl:with-param name="content">
637 <xsl:call-template name="chunk-element-content">
638 <xsl:with-param name="prev" select="/foo"/>
639 <xsl:with-param name="next" select="/foo"/>
640 <xsl:with-param name="nav.context" select="'toc'"/>
641 <xsl:with-param name="content">
642 <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
644 <xsl:apply-templates select="." mode="object.title.markup"/>
647 <xsl:copy-of select="$lots"/>
651 <xsl:with-param name="quiet" select="$chunk.quietly"/>
655 <xsl:copy-of select="$lots"/>
661 <xsl:template name="make.lot.chunk">
662 <xsl:param name="type" select="''"/>
663 <xsl:param name="lot"/>
665 <xsl:if test="string($lot) != ''">
666 <xsl:variable name="filename">
667 <xsl:call-template name="make-relative-filename">
668 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
669 <xsl:with-param name="base.name">
670 <xsl:call-template name="dbhtml-dir"/>
671 <xsl:value-of select="$type"/>
672 <xsl:text>-toc</xsl:text>
673 <xsl:value-of select="$html.ext"/>
678 <xsl:variable name="href">
679 <xsl:call-template name="make-relative-filename">
680 <xsl:with-param name="base.dir" select="''"/>
681 <xsl:with-param name="base.name">
682 <xsl:call-template name="dbhtml-dir"/>
683 <xsl:value-of select="$type"/>
684 <xsl:text>-toc</xsl:text>
685 <xsl:value-of select="$html.ext"/>
690 <xsl:call-template name="write.chunk">
691 <xsl:with-param name="filename" select="$filename"/>
692 <xsl:with-param name="content">
693 <xsl:call-template name="chunk-element-content">
694 <xsl:with-param name="prev" select="/foo"/>
695 <xsl:with-param name="next" select="/foo"/>
696 <xsl:with-param name="nav.context" select="'toc'"/>
697 <xsl:with-param name="content">
698 <xsl:copy-of select="$lot"/>
702 <xsl:with-param name="quiet" select="$chunk.quietly"/>
704 <!-- And output a link to this file -->
706 <xsl:attribute name="class">
707 <xsl:text>ListofTitles</xsl:text>
710 <xsl:call-template name="gentext">
711 <xsl:with-param name="key">
713 <xsl:when test="$type='table'">ListofTables</xsl:when>
714 <xsl:when test="$type='figure'">ListofFigures</xsl:when>
715 <xsl:when test="$type='equation'">ListofEquations</xsl:when>
716 <xsl:when test="$type='example'">ListofExamples</xsl:when>
717 <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
718 <xsl:otherwise>ListofUnknown</xsl:otherwise>
727 <!-- ==================================================================== -->
729 <xsl:template name="in.other.chunk">
730 <xsl:param name="chunk" select="."/>
731 <xsl:param name="node" select="."/>
733 <xsl:variable name="is.chunk">
734 <xsl:call-template name="chunk">
735 <xsl:with-param name="node" select="$node"/>
741 <xsl:text>in.other.chunk: </xsl:text>
742 <xsl:value-of select="name($chunk)"/>
743 <xsl:text> </xsl:text>
744 <xsl:value-of select="name($node)"/>
745 <xsl:text> </xsl:text>
746 <xsl:value-of select="$chunk = $node"/>
747 <xsl:text> </xsl:text>
748 <xsl:value-of select="$is.chunk"/>
753 <xsl:when test="$chunk = $node">0</xsl:when>
754 <xsl:when test="$is.chunk = 1">1</xsl:when>
755 <xsl:when test="count($node) = 0">0</xsl:when>
757 <xsl:call-template name="in.other.chunk">
758 <xsl:with-param name="chunk" select="$chunk"/>
759 <xsl:with-param name="node" select="$node/parent::*"/>
765 <xsl:template name="count.footnotes.in.this.chunk">
766 <xsl:param name="node" select="."/>
767 <xsl:param name="footnotes" select="$node//footnote"/>
768 <xsl:param name="count" select="0"/>
772 <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
773 <xsl:value-of select="name($node)"/>
777 <xsl:variable name="in.other.chunk">
778 <xsl:call-template name="in.other.chunk">
779 <xsl:with-param name="chunk" select="$node"/>
780 <xsl:with-param name="node" select="$footnotes[1]"/>
785 <xsl:when test="count($footnotes) = 0">
786 <xsl:value-of select="$count"/>
790 <xsl:when test="$in.other.chunk != 0">
791 <xsl:call-template name="count.footnotes.in.this.chunk">
792 <xsl:with-param name="node" select="$node"/>
793 <xsl:with-param name="footnotes"
794 select="$footnotes[position() > 1]"/>
795 <xsl:with-param name="count" select="$count"/>
798 <xsl:when test="$footnotes[1]/ancestor::table
799 |$footnotes[1]/ancestor::informaltable">
800 <xsl:call-template name="count.footnotes.in.this.chunk">
801 <xsl:with-param name="node" select="$node"/>
802 <xsl:with-param name="footnotes"
803 select="$footnotes[position() > 1]"/>
804 <xsl:with-param name="count" select="$count"/>
808 <xsl:call-template name="count.footnotes.in.this.chunk">
809 <xsl:with-param name="node" select="$node"/>
810 <xsl:with-param name="footnotes"
811 select="$footnotes[position() > 1]"/>
812 <xsl:with-param name="count" select="$count + 1"/>
820 <xsl:template name="process.footnotes.in.this.chunk">
821 <xsl:param name="node" select="."/>
822 <xsl:param name="footnotes" select="$node//footnote"/>
825 <xsl:message>process.footnotes.in.this.chunk</xsl:message>
828 <xsl:variable name="in.other.chunk">
829 <xsl:call-template name="in.other.chunk">
830 <xsl:with-param name="chunk" select="$node"/>
831 <xsl:with-param name="node" select="$footnotes[1]"/>
836 <xsl:when test="count($footnotes) = 0">
841 <xsl:when test="$in.other.chunk != 0">
842 <xsl:call-template name="process.footnotes.in.this.chunk">
843 <xsl:with-param name="node" select="$node"/>
844 <xsl:with-param name="footnotes"
845 select="$footnotes[position() > 1]"/>
848 <xsl:when test="$footnotes[1]/ancestor::table
849 |$footnotes[1]/ancestor::informaltable">
850 <xsl:call-template name="process.footnotes.in.this.chunk">
851 <xsl:with-param name="node" select="$node"/>
852 <xsl:with-param name="footnotes"
853 select="$footnotes[position() > 1]"/>
857 <xsl:apply-templates select="$footnotes[1]"
858 mode="process.footnote.mode"/>
859 <xsl:call-template name="process.footnotes.in.this.chunk">
860 <xsl:with-param name="node" select="$node"/>
861 <xsl:with-param name="footnotes"
862 select="$footnotes[position() > 1]"/>
870 <xsl:template name="process.footnotes">
871 <xsl:variable name="footnotes" select=".//footnote"/>
872 <xsl:variable name="fcount">
873 <xsl:call-template name="count.footnotes.in.this.chunk">
874 <xsl:with-param name="node" select="."/>
875 <xsl:with-param name="footnotes" select="$footnotes"/>
881 <xsl:value-of select="name(.)"/>
882 <xsl:text> fcount: </xsl:text>
883 <xsl:value-of select="$fcount"/>
887 <!-- Only bother to do this if there's at least one non-table footnote -->
888 <xsl:if test="$fcount > 0">
889 <div class="footnotes">
890 <xsl:call-template name="footnotes.attributes"/>
894 <xsl:when test="$make.clean.html != 0">
895 <xsl:attribute name="class">footnote-hr</xsl:attribute>
897 <xsl:when test="$css.decoration != 0">
898 <xsl:attribute name="style">
899 <xsl:value-of select="concat('width:100; text-align:',
900 $direction.align.start,
902 'margin-', $direction.align.start, ': 0')"/>
906 <xsl:attribute name="width">100</xsl:attribute>
907 <xsl:attribute name="align"><xsl:value-of
908 select="$direction.align.start"/></xsl:attribute>
912 <xsl:call-template name="process.footnotes.in.this.chunk">
913 <xsl:with-param name="node" select="."/>
914 <xsl:with-param name="footnotes" select="$footnotes"/>
919 <!-- FIXME: When chunking, only the annotations actually used
920 in this chunk should be referenced. I don't think it
921 does any harm to reference them all, but it adds
922 unnecessary bloat to each chunk. -->
923 <xsl:if test="$annotation.support != 0 and //annotation">
924 <div class="annotation-list">
925 <div class="annotation-nocss">
926 <p>The following annotations are from this essay. You are seeing
927 them here because your browser doesn’t support the user-interface
928 techniques used to make them appear as ‘popups’ on modern browsers.</p>
931 <xsl:apply-templates select="//annotation"
932 mode="annotation-popup"/>
937 <xsl:template name="process.chunk.footnotes">
938 <xsl:variable name="is.chunk">
939 <xsl:call-template name="chunk"/>
941 <xsl:if test="$is.chunk = 1">
942 <xsl:call-template name="process.footnotes"/>
946 <!-- ====================================================================== -->
948 <xsl:template name="chunk">
949 <xsl:param name="node" select="."/>
950 <!-- returns 1 if $node is a chunk -->
952 <!-- ==================================================================== -->
958 bibliography in article or part or book
962 glossary in article or part or book
963 index in article or part or book
968 sect{1,2,3,4,5} if position()>1 && depth < chunk.section.depth
969 section if position()>1 && depth < chunk.section.depth
974 <!-- ==================================================================== -->
978 <xsl:text>chunk: </xsl:text>
979 <xsl:value-of select="name($node)"/>
980 <xsl:text>(</xsl:text>
981 <xsl:value-of select="$node/@id"/>
982 <xsl:text>)</xsl:text>
983 <xsl:text> csd: </xsl:text>
984 <xsl:value-of select="$chunk.section.depth"/>
985 <xsl:text> cfs: </xsl:text>
986 <xsl:value-of select="$chunk.first.sections"/>
987 <xsl:text> ps: </xsl:text>
988 <xsl:value-of select="count($node/parent::section)"/>
989 <xsl:text> prs: </xsl:text>
990 <xsl:value-of select="count($node/preceding-sibling::section)"/>
995 <xsl:when test="$node/parent::*/processing-instruction('dbhtml')[normalize-space(.) = 'stop-chunking']">0</xsl:when>
996 <xsl:when test="not($node/parent::*)">1</xsl:when>
998 <xsl:when test="local-name($node) = 'sect1'
999 and $chunk.section.depth >= 1
1000 and ($chunk.first.sections != 0
1001 or count($node/preceding-sibling::sect1) > 0)">
1002 <xsl:text>1</xsl:text>
1004 <xsl:when test="local-name($node) = 'sect2'
1005 and $chunk.section.depth >= 2
1006 and ($chunk.first.sections != 0
1007 or count($node/preceding-sibling::sect2) > 0)">
1008 <xsl:call-template name="chunk">
1009 <xsl:with-param name="node" select="$node/parent::*"/>
1010 </xsl:call-template>
1012 <xsl:when test="local-name($node) = 'sect3'
1013 and $chunk.section.depth >= 3
1014 and ($chunk.first.sections != 0
1015 or count($node/preceding-sibling::sect3) > 0)">
1016 <xsl:call-template name="chunk">
1017 <xsl:with-param name="node" select="$node/parent::*"/>
1018 </xsl:call-template>
1020 <xsl:when test="local-name($node) = 'sect4'
1021 and $chunk.section.depth >= 4
1022 and ($chunk.first.sections != 0
1023 or count($node/preceding-sibling::sect4) > 0)">
1024 <xsl:call-template name="chunk">
1025 <xsl:with-param name="node" select="$node/parent::*"/>
1026 </xsl:call-template>
1028 <xsl:when test="local-name($node) = 'sect5'
1029 and $chunk.section.depth >= 5
1030 and ($chunk.first.sections != 0
1031 or count($node/preceding-sibling::sect5) > 0)">
1032 <xsl:call-template name="chunk">
1033 <xsl:with-param name="node" select="$node/parent::*"/>
1034 </xsl:call-template>
1036 <xsl:when test="local-name($node) = 'section'
1037 and $chunk.section.depth >= count($node/ancestor::section)+1
1038 and ($chunk.first.sections != 0
1039 or count($node/preceding-sibling::section) > 0)">
1040 <xsl:call-template name="chunk">
1041 <xsl:with-param name="node" select="$node/parent::*"/>
1042 </xsl:call-template>
1045 <xsl:when test="local-name($node)='preface'">1</xsl:when>
1046 <xsl:when test="local-name($node)='chapter'">1</xsl:when>
1047 <xsl:when test="local-name($node)='appendix'">1</xsl:when>
1048 <xsl:when test="local-name($node)='article'">1</xsl:when>
1049 <xsl:when test="local-name($node)='topic'">1</xsl:when>
1050 <xsl:when test="local-name($node)='part'">1</xsl:when>
1051 <xsl:when test="local-name($node)='reference'">1</xsl:when>
1052 <xsl:when test="local-name($node)='refentry'">1</xsl:when>
1053 <xsl:when test="local-name($node)='index' and ($generate.index != 0 or count($node/*) > 0)
1054 and (local-name($node/parent::*) = 'article'
1055 or local-name($node/parent::*) = 'book'
1056 or local-name($node/parent::*) = 'part'
1058 <xsl:when test="local-name($node)='bibliography'
1059 and (local-name($node/parent::*) = 'article'
1060 or local-name($node/parent::*) = 'book'
1061 or local-name($node/parent::*) = 'part'
1063 <xsl:when test="local-name($node)='glossary'
1064 and (local-name($node/parent::*) = 'article'
1065 or local-name($node/parent::*) = 'book'
1066 or local-name($node/parent::*) = 'part'
1068 <xsl:when test="local-name($node)='colophon'">1</xsl:when>
1069 <xsl:when test="local-name($node)='book'">1</xsl:when>
1070 <xsl:when test="local-name($node)='set'">1</xsl:when>
1071 <xsl:when test="local-name($node)='setindex'">1</xsl:when>
1072 <xsl:when test="local-name($node)='legalnotice'
1073 and $generate.legalnotice.link != 0">1</xsl:when>
1074 <xsl:otherwise>0</xsl:otherwise>
1078 <!-- ==================================================================== -->
1079 <xsl:template name="href.target.uri">
1080 <xsl:param name="object" select="."/>
1081 <xsl:variable name="ischunk">
1082 <xsl:call-template name="chunk">
1083 <xsl:with-param name="node" select="$object"/>
1084 </xsl:call-template>
1087 <xsl:apply-templates mode="chunk-filename" select="$object"/>
1089 <xsl:if test="$ischunk='0'">
1090 <xsl:text>#</xsl:text>
1091 <xsl:call-template name="object.id">
1092 <xsl:with-param name="object" select="$object"/>
1093 </xsl:call-template>
1097 <xsl:template name="href.target">
1098 <xsl:param name="context" select="."/>
1099 <xsl:param name="object" select="."/>
1100 <xsl:param name="toc-context" select="."/>
1101 <!-- * If $toc-context contains some node other than the current node, -->
1102 <!-- * it means we're processing a link in a TOC. In that case, to -->
1103 <!-- * ensure the link will work correctly, we need to take a look at -->
1104 <!-- * where the file containing the TOC will get written, and where -->
1105 <!-- * the file that's being linked to will get written. -->
1106 <xsl:variable name="toc-output-dir">
1107 <xsl:if test="not($toc-context = .)">
1108 <!-- * Get the $toc-context node and all its ancestors, look down -->
1109 <!-- * through them to find the last/closest node to the -->
1110 <!-- * toc-context node that has a "dbhtml dir" PI, and get the -->
1111 <!-- * directory name from that. That's the name of the directory -->
1112 <!-- * to which the current toc output file will get written. -->
1113 <xsl:call-template name="dbhtml-dir">
1114 <xsl:with-param name="context"
1115 select="$toc-context/ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
1116 </xsl:call-template>
1119 <xsl:variable name="linked-file-output-dir">
1120 <xsl:if test="not($toc-context = .)">
1121 <!-- * Get the current node and all its ancestors, look down -->
1122 <!-- * through them to find the last/closest node to the current -->
1123 <!-- * node that has a "dbhtml dir" PI, and get the directory name -->
1124 <!-- * from that. That's the name of the directory to which the -->
1125 <!-- * file that's being linked to will get written. -->
1126 <xsl:call-template name="dbhtml-dir">
1127 <xsl:with-param name="context"
1128 select="ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
1129 </xsl:call-template>
1132 <xsl:variable name="href.to.uri">
1133 <xsl:call-template name="href.target.uri">
1134 <xsl:with-param name="object" select="$object"/>
1135 </xsl:call-template>
1137 <xsl:variable name="href.from.uri">
1139 <xsl:when test="not($toc-context = .)">
1140 <xsl:call-template name="href.target.uri">
1141 <xsl:with-param name="object" select="$toc-context"/>
1142 </xsl:call-template>
1145 <xsl:call-template name="href.target.uri">
1146 <xsl:with-param name="object" select="$context"/>
1147 </xsl:call-template>
1151 <!-- * <xsl:message>toc-context: <xsl:value-of select="local-name($toc-context)"/></xsl:message> -->
1152 <!-- * <xsl:message>node: <xsl:value-of select="local-name(.)"/></xsl:message> -->
1153 <!-- * <xsl:message>context: <xsl:value-of select="local-name($context)"/></xsl:message> -->
1154 <!-- * <xsl:message>object: <xsl:value-of select="local-name($object)"/></xsl:message> -->
1155 <!-- * <xsl:message>toc-output-dir: <xsl:value-of select="$toc-output-dir"/></xsl:message> -->
1156 <!-- * <xsl:message>linked-file-output-dir: <xsl:value-of select="$linked-file-output-dir"/></xsl:message> -->
1157 <!-- * <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> -->
1158 <!-- * <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> -->
1159 <xsl:variable name="href.to">
1161 <!-- * 2007-07-19, MikeSmith: Added the following conditional to -->
1162 <!-- * deal with a problem case for links in TOCs. It checks to see -->
1163 <!-- * if the output dir that a TOC will get written to is -->
1164 <!-- * different from the output dir of the file being linked to. -->
1165 <!-- * If it is different, we do not call trim.common.uri.paths. -->
1167 <!-- * Reason why I added that conditional is: I ran into a bug for -->
1168 <!-- * this case: -->
1170 <!-- * 1. we are chunking into separate dirs -->
1172 <!-- * 2. output for the TOC is written to current dir, but the file -->
1173 <!-- * being linked to is written to some subdir "foo". -->
1175 <!-- * For that case, links to that file in that TOC did not show -->
1176 <!-- * the correct path - they omitted the "foo". -->
1178 <!-- * The cause of that problem was that the trim.common.uri.paths -->
1179 <!-- * template[1] was being called under all conditions. But it's -->
1180 <!-- * apparent that we don't want to call trim.common.uri.paths in -->
1181 <!-- * the case where a linked file is being written to a different -->
1182 <!-- * directory than the TOC that contains the link, because doing -->
1183 <!-- * so will cause a necessary (not redundant) directory-name -->
1184 <!-- * part of the link to get inadvertently trimmed, resulting in -->
1185 <!-- * a broken link to that file. Thus, added the conditional. -->
1187 <!-- * [1] The purpose of the trim.common.uri.paths template is to -->
1188 <!-- * prevent cases where, if we didn't call it, we end up with -->
1189 <!-- * unnecessary, redundant directory names getting output; for -->
1190 <!-- * example, "foo/foo/refname.html". -->
1191 <xsl:when test="not($toc-output-dir = $linked-file-output-dir)">
1192 <xsl:value-of select="$href.to.uri"/>
1195 <xsl:call-template name="trim.common.uri.paths">
1196 <xsl:with-param name="uriA" select="$href.to.uri"/>
1197 <xsl:with-param name="uriB" select="$href.from.uri"/>
1198 <xsl:with-param name="return" select="'A'"/>
1199 </xsl:call-template>
1203 <xsl:variable name="href.from">
1204 <xsl:call-template name="trim.common.uri.paths">
1205 <xsl:with-param name="uriA" select="$href.to.uri"/>
1206 <xsl:with-param name="uriB" select="$href.from.uri"/>
1207 <xsl:with-param name="return" select="'B'"/>
1208 </xsl:call-template>
1210 <xsl:variable name="depth">
1211 <xsl:call-template name="count.uri.path.depth">
1212 <xsl:with-param name="filename" select="$href.from"/>
1213 </xsl:call-template>
1215 <xsl:variable name="href">
1216 <xsl:call-template name="copy-string">
1217 <xsl:with-param name="string" select="'../'"/>
1218 <xsl:with-param name="count" select="$depth"/>
1219 </xsl:call-template>
1220 <xsl:value-of select="$href.to"/>
1224 <xsl:text>In </xsl:text>
1225 <xsl:value-of select="name(.)"/>
1226 <xsl:text> (</xsl:text>
1227 <xsl:value-of select="$href.from"/>
1228 <xsl:text>,</xsl:text>
1229 <xsl:value-of select="$depth"/>
1230 <xsl:text>) </xsl:text>
1231 <xsl:value-of select="name($object)"/>
1232 <xsl:text> href=</xsl:text>
1233 <xsl:value-of select="$href"/>
1236 <xsl:value-of select="$href"/>
1239 <!-- Returns the complete olink href value if found -->
1240 <!-- Must take into account any dbhtml dir of the chunk containing the olink -->
1241 <xsl:template name="make.olink.href">
1242 <xsl:param name="olink.key" select="''"/>
1243 <xsl:param name="target.database"/>
1245 <xsl:if test="$olink.key != ''">
1246 <xsl:variable name="target.href" >
1247 <xsl:for-each select="$target.database" >
1248 <xsl:value-of select="key('targetptr-key', $olink.key)[1]/@href" />
1252 <!-- an olink starting point may be in a subdirectory, so need
1253 the "from" reference point to compute a relative path -->
1255 <xsl:variable name="from.href">
1256 <xsl:call-template name="olink.from.uri">
1257 <xsl:with-param name="target.database" select="$target.database"/>
1258 <xsl:with-param name="object" select="."/>
1259 <xsl:with-param name="object.targetdoc" select="$current.docid"/>
1260 </xsl:call-template>
1263 <!-- If the from.href has directory path, then must "../" upward
1264 to document level -->
1265 <xsl:variable name="upward.from.path">
1266 <xsl:call-template name="upward.path">
1267 <xsl:with-param name="path" select="$from.href"/>
1268 </xsl:call-template>
1271 <xsl:variable name="targetdoc">
1272 <xsl:value-of select="substring-before($olink.key, '/')"/>
1275 <!-- Does the target database use a sitemap? -->
1276 <xsl:variable name="use.sitemap">
1278 <xsl:when test="$target.database//sitemap">1</xsl:when>
1279 <xsl:otherwise>0</xsl:otherwise>
1284 <!-- Get the baseuri for this targetptr -->
1285 <xsl:variable name="baseuri" >
1287 <!-- Does the database use a sitemap? -->
1288 <xsl:when test="$use.sitemap != 0" >
1290 <!-- Was current.docid parameter set? -->
1291 <xsl:when test="$current.docid != ''">
1292 <!-- Was it found in the database? -->
1293 <xsl:variable name="currentdoc.key" >
1294 <xsl:for-each select="$target.database" >
1295 <xsl:value-of select="key('targetdoc-key',
1296 $current.docid)[1]/@targetdoc" />
1300 <xsl:when test="$currentdoc.key != ''">
1301 <xsl:for-each select="$target.database" >
1302 <xsl:call-template name="targetpath" >
1303 <xsl:with-param name="dirnode"
1304 select="key('targetdoc-key', $current.docid)[1]/parent::dir"/>
1305 <xsl:with-param name="targetdoc" select="$targetdoc"/>
1306 </xsl:call-template>
1311 <xsl:text>Olink error: cannot compute relative </xsl:text>
1312 <xsl:text>sitemap path because $current.docid '</xsl:text>
1313 <xsl:value-of select="$current.docid"/>
1314 <xsl:text>' not found in target database.</xsl:text>
1321 <xsl:text>Olink warning: cannot compute relative </xsl:text>
1322 <xsl:text>sitemap path without $current.docid parameter</xsl:text>
1326 <!-- In either case, add baseuri from its document entry-->
1327 <xsl:variable name="docbaseuri">
1328 <xsl:for-each select="$target.database" >
1329 <xsl:value-of select="key('targetdoc-key', $targetdoc)[1]/@baseuri" />
1332 <xsl:if test="$docbaseuri != ''" >
1333 <xsl:value-of select="$docbaseuri"/>
1336 <!-- No database sitemap in use -->
1338 <!-- Just use any baseuri from its document entry -->
1339 <xsl:variable name="docbaseuri">
1340 <xsl:for-each select="$target.database" >
1341 <xsl:value-of select="key('targetdoc-key', $targetdoc)[1]/@baseuri" />
1344 <xsl:if test="$docbaseuri != ''" >
1345 <xsl:value-of select="$docbaseuri"/>
1351 <!-- Is this olink to be active? -->
1352 <xsl:variable name="active.olink">
1354 <xsl:when test="$activate.external.olinks = 0">
1356 <xsl:when test="$current.docid = ''">1</xsl:when>
1357 <xsl:when test="$targetdoc = ''">1</xsl:when>
1358 <xsl:when test="$targetdoc = $current.docid">1</xsl:when>
1359 <xsl:otherwise>0</xsl:otherwise>
1362 <xsl:otherwise>1</xsl:otherwise>
1366 <xsl:if test="$active.olink != 0">
1367 <!-- Form the href information -->
1368 <xsl:if test="not(contains($baseuri, ':'))">
1369 <!-- if not an absolute uri, add upward path from olink chunk -->
1370 <xsl:value-of select="$upward.from.path"/>
1373 <xsl:if test="$baseuri != ''">
1374 <xsl:value-of select="$baseuri"/>
1375 <xsl:if test="substring($target.href,1,1) != '#'">
1376 <!--xsl:text>/</xsl:text-->
1379 <!-- optionally turn off frag for PDF references -->
1380 <xsl:if test="not($insert.olink.pdf.frag = 0 and
1381 translate(substring($baseuri, string-length($baseuri) - 3),
1382 'PDF', 'pdf') = '.pdf'
1383 and starts-with($target.href, '#') )">
1384 <xsl:value-of select="$target.href"/>
1390 <!-- Computes "../" to reach top -->
1391 <xsl:template name="upward.path">
1392 <xsl:param name="path" select="''"/>
1394 <!-- Don't bother with absolute uris -->
1395 <xsl:when test="contains($path, ':')"/>
1396 <xsl:when test="starts-with($path, '/')"/>
1397 <xsl:when test="contains($path, '/')">
1398 <xsl:text>../</xsl:text>
1399 <xsl:call-template name="upward.path">
1400 <xsl:with-param name="path" select="substring-after($path, '/')"/>
1401 </xsl:call-template>
1407 <!-- ==================================================================== -->
1409 <xsl:template name="html.head">
1410 <xsl:param name="prev" select="/foo"/>
1411 <xsl:param name="next" select="/foo"/>
1412 <xsl:variable name="this" select="."/>
1413 <xsl:variable name="home" select="/*[1]"/>
1414 <xsl:variable name="up" select="parent::*"/>
1417 <xsl:call-template name="system.head.content"/>
1418 <xsl:call-template name="head.content"/>
1420 <!-- home link not valid in HTML5 -->
1421 <xsl:if test="$home and $div.element != 'section'">
1423 <xsl:attribute name="href">
1424 <xsl:call-template name="href.target">
1425 <xsl:with-param name="object" select="$home"/>
1426 </xsl:call-template>
1428 <xsl:attribute name="title">
1429 <xsl:apply-templates select="$home"
1430 mode="object.title.markup.textonly"/>
1435 <!-- up link not valid in HTML5 -->
1436 <xsl:if test="$up and $div.element != 'section'">
1438 <xsl:attribute name="href">
1439 <xsl:call-template name="href.target">
1440 <xsl:with-param name="object" select="$up"/>
1441 </xsl:call-template>
1443 <xsl:attribute name="title">
1444 <xsl:apply-templates select="$up" mode="object.title.markup.textonly"/>
1449 <xsl:if test="$prev">
1451 <xsl:attribute name="href">
1452 <xsl:call-template name="href.target">
1453 <xsl:with-param name="object" select="$prev"/>
1454 </xsl:call-template>
1456 <xsl:attribute name="title">
1457 <xsl:apply-templates select="$prev" mode="object.title.markup.textonly"/>
1462 <xsl:if test="$next">
1464 <xsl:attribute name="href">
1465 <xsl:call-template name="href.target">
1466 <xsl:with-param name="object" select="$next"/>
1467 </xsl:call-template>
1469 <xsl:attribute name="title">
1470 <xsl:apply-templates select="$next" mode="object.title.markup.textonly"/>
1475 <xsl:if test="$html.extra.head.links != 0">
1476 <xsl:for-each select="//part
1482 |//appendix[not(parent::article)]|appendix
1483 |//glossary[not(parent::article)]|glossary
1484 |//index[not(parent::article)]|index">
1485 <link rel="{local-name(.)}">
1486 <xsl:attribute name="href">
1487 <xsl:call-template name="href.target">
1488 <xsl:with-param name="context" select="$this"/>
1489 <xsl:with-param name="object" select="."/>
1490 </xsl:call-template>
1492 <xsl:attribute name="title">
1493 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1498 <xsl:for-each select="section|sect1|refsection|refsect1">
1500 <xsl:attribute name="rel">
1502 <xsl:when test="local-name($this) = 'section'
1503 or local-name($this) = 'refsection'">
1504 <xsl:value-of select="'subsection'"/>
1507 <xsl:value-of select="'section'"/>
1511 <xsl:attribute name="href">
1512 <xsl:call-template name="href.target">
1513 <xsl:with-param name="context" select="$this"/>
1514 <xsl:with-param name="object" select="."/>
1515 </xsl:call-template>
1517 <xsl:attribute name="title">
1518 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1523 <xsl:for-each select="sect2|sect3|sect4|sect5|refsect2|refsect3">
1524 <link rel="subsection">
1525 <xsl:attribute name="href">
1526 <xsl:call-template name="href.target">
1527 <xsl:with-param name="context" select="$this"/>
1528 <xsl:with-param name="object" select="."/>
1529 </xsl:call-template>
1531 <xsl:attribute name="title">
1532 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1538 <!-- * if we have a legalnotice and user wants it output as a -->
1539 <!-- * separate page and $html.head.legalnotice.link.types is -->
1540 <!-- * non-empty, we generate a link or links for each value in -->
1541 <!-- * $html.head.legalnotice.link.types -->
1542 <xsl:if test="//legalnotice
1543 and not($generate.legalnotice.link = 0)
1544 and not($html.head.legalnotice.link.types = '')">
1545 <xsl:call-template name="make.legalnotice.head.links"/>
1548 <xsl:call-template name="user.head.content"/>
1552 <!-- ==================================================================== -->
1554 <xsl:template name="header.navigation">
1555 <xsl:param name="prev" select="/foo"/>
1556 <xsl:param name="next" select="/foo"/>
1557 <xsl:param name="nav.context"/>
1559 <xsl:variable name="home" select="/*[1]"/>
1560 <xsl:variable name="up" select="parent::*"/>
1562 <xsl:variable name="row1" select="$navig.showtitles != 0"/>
1563 <xsl:variable name="row2" select="count($prev) > 0
1564 or (count($up) > 0
1565 and generate-id($up) != generate-id($home)
1566 and $navig.showtitles != 0)
1567 or count($next) > 0"/>
1569 <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'">
1570 <div class="navheader">
1571 <xsl:if test="$row1 or $row2">
1572 <table width="100%" summary="Navigation header">
1573 <xsl:if test="$row1">
1575 <th colspan="3" align="center">
1576 <xsl:apply-templates select="." mode="object.title.markup"/>
1581 <xsl:if test="$row2">
1583 <td width="20%" align="{$direction.align.start}">
1584 <xsl:if test="count($prev)>0">
1586 <xsl:attribute name="href">
1587 <xsl:call-template name="href.target">
1588 <xsl:with-param name="object" select="$prev"/>
1589 </xsl:call-template>
1591 <xsl:call-template name="navig.content">
1592 <xsl:with-param name="direction" select="'prev'"/>
1593 </xsl:call-template>
1596 <xsl:text> </xsl:text>
1598 <th width="60%" align="center">
1600 <xsl:when test="count($up) > 0
1601 and generate-id($up) != generate-id($home)
1602 and $navig.showtitles != 0">
1603 <xsl:apply-templates select="$up" mode="object.title.markup"/>
1605 <xsl:otherwise> </xsl:otherwise>
1608 <td width="20%" align="{$direction.align.end}">
1609 <xsl:text> </xsl:text>
1610 <xsl:if test="count($next)>0">
1612 <xsl:attribute name="href">
1613 <xsl:call-template name="href.target">
1614 <xsl:with-param name="object" select="$next"/>
1615 </xsl:call-template>
1617 <xsl:call-template name="navig.content">
1618 <xsl:with-param name="direction" select="'next'"/>
1619 </xsl:call-template>
1627 <xsl:if test="$header.rule != 0">
1634 <!-- ==================================================================== -->
1636 <xsl:template name="footer.navigation">
1637 <xsl:param name="prev" select="/foo"/>
1638 <xsl:param name="next" select="/foo"/>
1639 <xsl:param name="nav.context"/>
1641 <xsl:variable name="home" select="/*[1]"/>
1642 <xsl:variable name="up" select="parent::*"/>
1644 <xsl:variable name="row1" select="count($prev) > 0
1645 or count($up) > 0
1646 or count($next) > 0"/>
1648 <xsl:variable name="row2" select="($prev and $navig.showtitles != 0)
1649 or (generate-id($home) != generate-id(.)
1650 or $nav.context = 'toc')
1651 or ($chunk.tocs.and.lots != 0
1652 and $nav.context != 'toc')
1653 or ($next and $navig.showtitles != 0)"/>
1655 <xsl:if test="$suppress.navigation = '0' and $suppress.footer.navigation = '0'">
1656 <div class="navfooter">
1657 <xsl:if test="$footer.rule != 0">
1661 <xsl:if test="$row1 or $row2">
1662 <table width="100%" summary="Navigation footer">
1663 <xsl:if test="$row1">
1665 <td width="40%" align="{$direction.align.start}">
1666 <xsl:if test="count($prev)>0">
1668 <xsl:attribute name="href">
1669 <xsl:call-template name="href.target">
1670 <xsl:with-param name="object" select="$prev"/>
1671 </xsl:call-template>
1673 <xsl:call-template name="navig.content">
1674 <xsl:with-param name="direction" select="'prev'"/>
1675 </xsl:call-template>
1678 <xsl:text> </xsl:text>
1680 <td width="20%" align="center">
1682 <xsl:when test="count($up)>0
1683 and generate-id($up) != generate-id($home)">
1685 <xsl:attribute name="href">
1686 <xsl:call-template name="href.target">
1687 <xsl:with-param name="object" select="$up"/>
1688 </xsl:call-template>
1690 <xsl:call-template name="navig.content">
1691 <xsl:with-param name="direction" select="'up'"/>
1692 </xsl:call-template>
1695 <xsl:otherwise> </xsl:otherwise>
1698 <td width="40%" align="{$direction.align.end}">
1699 <xsl:text> </xsl:text>
1700 <xsl:if test="count($next)>0">
1702 <xsl:attribute name="href">
1703 <xsl:call-template name="href.target">
1704 <xsl:with-param name="object" select="$next"/>
1705 </xsl:call-template>
1707 <xsl:call-template name="navig.content">
1708 <xsl:with-param name="direction" select="'next'"/>
1709 </xsl:call-template>
1716 <xsl:if test="$row2">
1718 <td width="40%" align="{$direction.align.start}" valign="top">
1719 <xsl:if test="$navig.showtitles != 0">
1720 <xsl:apply-templates select="$prev" mode="object.title.markup"/>
1722 <xsl:text> </xsl:text>
1724 <td width="20%" align="center">
1726 <xsl:when test="$home != . or $nav.context = 'toc'">
1728 <xsl:attribute name="href">
1729 <xsl:call-template name="href.target">
1730 <xsl:with-param name="object" select="$home"/>
1731 </xsl:call-template>
1733 <xsl:call-template name="navig.content">
1734 <xsl:with-param name="direction" select="'home'"/>
1735 </xsl:call-template>
1737 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1738 <xsl:text> | </xsl:text>
1741 <xsl:otherwise> </xsl:otherwise>
1744 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1746 <xsl:attribute name="href">
1747 <xsl:value-of select="$chunked.filename.prefix"/>
1748 <xsl:apply-templates select="/*[1]"
1749 mode="recursive-chunk-filename">
1750 <xsl:with-param name="recursive" select="true()"/>
1751 </xsl:apply-templates>
1752 <xsl:text>-toc</xsl:text>
1753 <xsl:value-of select="$html.ext"/>
1755 <xsl:call-template name="gentext">
1756 <xsl:with-param name="key" select="'nav-toc'"/>
1757 </xsl:call-template>
1761 <td width="40%" align="{$direction.align.end}" valign="top">
1762 <xsl:text> </xsl:text>
1763 <xsl:if test="$navig.showtitles != 0">
1764 <xsl:apply-templates select="$next" mode="object.title.markup"/>
1775 <!-- ==================================================================== -->
1777 <xsl:template name="navig.content">
1778 <xsl:param name="direction" select="next"/>
1779 <xsl:variable name="navtext">
1781 <xsl:when test="$direction = 'prev'">
1782 <xsl:call-template name="gentext.nav.prev"/>
1784 <xsl:when test="$direction = 'next'">
1785 <xsl:call-template name="gentext.nav.next"/>
1787 <xsl:when test="$direction = 'up'">
1788 <xsl:call-template name="gentext.nav.up"/>
1790 <xsl:when test="$direction = 'home'">
1791 <xsl:call-template name="gentext.nav.home"/>
1794 <xsl:text>xxx</xsl:text>
1800 <xsl:when test="$navig.graphics != 0">
1802 <xsl:attribute name="src">
1803 <xsl:value-of select="$navig.graphics.path"/>
1804 <xsl:value-of select="$direction"/>
1805 <xsl:value-of select="$navig.graphics.extension"/>
1807 <xsl:attribute name="alt">
1808 <xsl:value-of select="$navtext"/>
1813 <xsl:value-of select="$navtext"/>
1818 <!-- ==================================================================== -->
1820 <!-- * The following template assumes that the first legalnotice -->
1821 <!-- * instance found in a document applies to the contents of the -->
1822 <!-- * entire document. It generates an HTML link in each chunk, back -->
1823 <!-- * to the file containing the contents of the first legalnotice. -->
1825 <!-- * Actually, it may generate multiple link instances in each chunk, -->
1826 <!-- * because it walks through the space-separated list of link -->
1827 <!-- * types specified in the $html.head.legalnotice.link.types param, -->
1828 <!-- * popping off link types and generating links for them until it -->
1829 <!-- * depletes the list. -->
1831 <xsl:template name="make.legalnotice.head.links">
1832 <!-- * the following ID is used as part of the legalnotice filename; -->
1833 <!-- * we need it in order to construct the filename for use in the -->
1834 <!-- * value of the href attribute on the link -->
1836 <xsl:param name="ln-node" select="(//legalnotice)[1]"/>
1838 <xsl:param name="linktype">
1840 <xsl:when test="contains($html.head.legalnotice.link.types, ' ')">
1842 select="normalize-space(
1843 substring-before($html.head.legalnotice.link.types, ' '))"/>
1846 <xsl:value-of select="$html.head.legalnotice.link.types"/>
1851 name="remaining.linktypes"
1854 substring-after($html.head.legalnotice.link.types, ' ')),' ')"/>
1855 <xsl:if test="not($linktype = '')">
1857 <!-- Compute name of legalnotice file (see titlepage.xsl) -->
1858 <xsl:variable name="file">
1859 <xsl:call-template name="ln.or.rh.filename">
1860 <xsl:with-param name="node" select="$ln-node"/>
1861 </xsl:call-template>
1864 <link rel="{$linktype}">
1865 <xsl:attribute name="href">
1866 <xsl:value-of select="$file"/>
1868 <xsl:attribute name="title">
1869 <xsl:apply-templates select="(//legalnotice)[1]"
1870 mode="object.title.markup.textonly"/>
1873 <xsl:call-template name="make.legalnotice.head.links">
1874 <!-- * pop the next value off the list of link types -->
1877 select="substring-before($remaining.linktypes, ' ')"/>
1878 <!-- * remove the link type from the list of remaining link types -->
1880 name="remaining.linktypes"
1881 select="substring-after($remaining.linktypes, ' ')"/>
1882 </xsl:call-template>
1886 <!-- ==================================================================== -->
1887 <xsl:template name="chunk-element-content">
1888 <xsl:param name="prev"/>
1889 <xsl:param name="next"/>
1890 <xsl:param name="nav.context"/>
1891 <xsl:param name="content">
1892 <xsl:apply-imports/>
1895 <xsl:call-template name="user.preroot"/>
1898 <xsl:call-template name="root.attributes"/>
1899 <xsl:call-template name="html.head">
1900 <xsl:with-param name="prev" select="$prev"/>
1901 <xsl:with-param name="next" select="$next"/>
1902 </xsl:call-template>
1905 <xsl:call-template name="body.attributes"/>
1907 <xsl:call-template name="user.header.navigation">
1908 <xsl:with-param name="prev" select="$prev"/>
1909 <xsl:with-param name="next" select="$next"/>
1910 <xsl:with-param name="nav.context" select="$nav.context"/>
1911 </xsl:call-template>
1913 <xsl:call-template name="header.navigation">
1914 <xsl:with-param name="prev" select="$prev"/>
1915 <xsl:with-param name="next" select="$next"/>
1916 <xsl:with-param name="nav.context" select="$nav.context"/>
1917 </xsl:call-template>
1919 <xsl:call-template name="user.header.content"/>
1921 <xsl:copy-of select="$content"/>
1923 <xsl:call-template name="user.footer.content"/>
1925 <xsl:call-template name="footer.navigation">
1926 <xsl:with-param name="prev" select="$prev"/>
1927 <xsl:with-param name="next" select="$next"/>
1928 <xsl:with-param name="nav.context" select="$nav.context"/>
1929 </xsl:call-template>
1931 <xsl:call-template name="user.footer.navigation">
1932 <xsl:with-param name="prev" select="$prev"/>
1933 <xsl:with-param name="next" select="$next"/>
1934 <xsl:with-param name="nav.context" select="$nav.context"/>
1935 </xsl:call-template>
1938 <xsl:value-of select="$chunk.append"/>
1941 <!-- ==================================================================== -->
1942 <xsl:template name="generate.manifest">
1943 <xsl:param name="node" select="/"/>
1944 <xsl:call-template name="write.text.chunk">
1945 <xsl:with-param name="filename">
1946 <xsl:if test="$manifest.in.base.dir != 0">
1947 <xsl:value-of select="$chunk.base.dir"/>
1949 <xsl:value-of select="$manifest"/>
1951 <xsl:with-param name="method" select="'text'"/>
1952 <xsl:with-param name="content">
1953 <xsl:apply-templates select="$node" mode="enumerate-files"/>
1955 <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
1956 </xsl:call-template>
1959 <!-- ==================================================================== -->
1961 <xsl:template name="dbhtml-dir">
1962 <xsl:param name="context" select="."/>
1963 <!-- directories are now inherited from previous levels -->
1964 <xsl:variable name="ppath">
1965 <xsl:if test="$context/parent::*">
1966 <xsl:call-template name="dbhtml-dir">
1967 <xsl:with-param name="context" select="$context/parent::*"/>
1968 </xsl:call-template>
1971 <xsl:variable name="path">
1972 <xsl:call-template name="pi.dbhtml_dir">
1973 <xsl:with-param name="node" select="$context"/>
1974 </xsl:call-template>
1977 <xsl:when test="$path = ''">
1978 <xsl:if test="$ppath != ''">
1979 <xsl:value-of select="$ppath"/>
1983 <xsl:if test="$ppath != ''">
1984 <xsl:value-of select="$ppath"/>
1985 <xsl:if test="substring($ppath, string-length($ppath), 1) != '/'">
1986 <xsl:text>/</xsl:text>
1989 <xsl:value-of select="$path"/>
1990 <xsl:text>/</xsl:text>