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 8551 2009-12-07 06:03:50Z 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 <xsl:when test="$exsl.node.set.available != 0">
33 <xsl:message>Computing chunks...</xsl:message>
34 <xsl:apply-templates select="/*" mode="find.chunks"/>
38 <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
39 <xsl:text>Using "slow" chunking.</xsl:text>
46 <!-- ==================================================================== -->
48 <xsl:template name="process-chunk-element">
49 <xsl:param name="content">
54 <xsl:when test="$chunk.fast != 0 and $exsl.node.set.available != 0">
55 <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
56 <xsl:variable name="genid" select="generate-id()"/>
58 <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
60 <xsl:variable name="prevdiv"
61 select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
62 <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
64 <xsl:variable name="nextdiv"
65 select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
66 <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
69 <xsl:when test="$onechunk != 0 and parent::*">
70 <xsl:copy-of select="$content"/>
73 <xsl:call-template name="process-chunk">
74 <xsl:with-param name="prev" select="$prev"/>
75 <xsl:with-param name="next" select="$next"/>
76 <xsl:with-param name="content" select="$content"/>
83 <xsl:when test="$onechunk != 0 and not(parent::*)">
84 <xsl:call-template name="chunk-all-sections">
85 <xsl:with-param name="content" select="$content"/>
88 <xsl:when test="$onechunk != 0">
89 <xsl:copy-of select="$content"/>
91 <xsl:when test="$chunk.first.sections = 0">
92 <xsl:call-template name="chunk-first-section-with-parent">
93 <xsl:with-param name="content" select="$content"/>
97 <xsl:call-template name="chunk-all-sections">
98 <xsl:with-param name="content" select="$content"/>
106 <xsl:template name="process-chunk">
107 <xsl:param name="prev" select="."/>
108 <xsl:param name="next" select="."/>
109 <xsl:param name="content">
113 <xsl:variable name="ischunk">
114 <xsl:call-template name="chunk"/>
117 <xsl:variable name="chunkfn">
118 <xsl:if test="$ischunk='1'">
119 <xsl:apply-templates mode="chunk-filename" select="."/>
123 <xsl:if test="$ischunk='0'">
125 <xsl:text>Error </xsl:text>
126 <xsl:value-of select="name(.)"/>
127 <xsl:text> is not a chunk!</xsl:text>
131 <xsl:variable name="filename">
132 <xsl:call-template name="make-relative-filename">
133 <xsl:with-param name="base.dir" select="$base.dir"/>
134 <xsl:with-param name="base.name" select="$chunkfn"/>
138 <xsl:call-template name="write.chunk">
139 <xsl:with-param name="filename" select="$filename"/>
140 <xsl:with-param name="content">
141 <xsl:call-template name="chunk-element-content">
142 <xsl:with-param name="prev" select="$prev"/>
143 <xsl:with-param name="next" select="$next"/>
144 <xsl:with-param name="content" select="$content"/>
147 <xsl:with-param name="quiet" select="$chunk.quietly"/>
151 <xsl:template name="chunk-first-section-with-parent">
152 <xsl:param name="content">
156 <!-- These xpath expressions are really hairy. The trick is to pick sections -->
157 <!-- that are not first children and are not the children of first children -->
159 <!-- Break these variables into pieces to work around
160 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
162 <xsl:variable name="prev-v1"
163 select="(ancestor::sect1[$chunk.section.depth > 0
164 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
165 and preceding-sibling::sect1][1]
167 |ancestor::sect2[$chunk.section.depth > 1
168 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
169 and preceding-sibling::sect2
170 and parent::sect1[preceding-sibling::sect1]][1]
172 |ancestor::sect3[$chunk.section.depth > 2
173 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
174 and preceding-sibling::sect3
175 and parent::sect2[preceding-sibling::sect2]
176 and ancestor::sect1[preceding-sibling::sect1]][1]
178 |ancestor::sect4[$chunk.section.depth > 3
179 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
180 and preceding-sibling::sect4
181 and parent::sect3[preceding-sibling::sect3]
182 and ancestor::sect2[preceding-sibling::sect2]
183 and ancestor::sect1[preceding-sibling::sect1]][1]
185 |ancestor::sect5[$chunk.section.depth > 4
186 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
187 and preceding-sibling::sect5
188 and parent::sect4[preceding-sibling::sect4]
189 and ancestor::sect3[preceding-sibling::sect3]
190 and ancestor::sect2[preceding-sibling::sect2]
191 and ancestor::sect1[preceding-sibling::sect1]][1]
193 |ancestor::section[$chunk.section.depth > count(ancestor::section)
194 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
195 and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
197 <xsl:variable name="prev-v2"
198 select="(preceding::sect1[$chunk.section.depth > 0
199 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
200 and preceding-sibling::sect1][1]
202 |preceding::sect2[$chunk.section.depth > 1
203 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
204 and preceding-sibling::sect2
205 and parent::sect1[preceding-sibling::sect1]][1]
207 |preceding::sect3[$chunk.section.depth > 2
208 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
209 and preceding-sibling::sect3
210 and parent::sect2[preceding-sibling::sect2]
211 and ancestor::sect1[preceding-sibling::sect1]][1]
213 |preceding::sect4[$chunk.section.depth > 3
214 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
215 and preceding-sibling::sect4
216 and parent::sect3[preceding-sibling::sect3]
217 and ancestor::sect2[preceding-sibling::sect2]
218 and ancestor::sect1[preceding-sibling::sect1]][1]
220 |preceding::sect5[$chunk.section.depth > 4
221 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
222 and preceding-sibling::sect5
223 and parent::sect4[preceding-sibling::sect4]
224 and ancestor::sect3[preceding-sibling::sect3]
225 and ancestor::sect2[preceding-sibling::sect2]
226 and ancestor::sect1[preceding-sibling::sect1]][1]
228 |preceding::section[$chunk.section.depth > count(ancestor::section)
229 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
230 and preceding-sibling::section
231 and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
233 <xsl:variable name="prev"
234 select="(preceding::book[1]
235 |preceding::preface[1]
236 |preceding::chapter[1]
237 |preceding::appendix[1]
239 |preceding::reference[1]
240 |preceding::refentry[1]
241 |preceding::colophon[1]
242 |preceding::article[1]
243 |preceding::bibliography[parent::article or parent::book or parent::part][1]
244 |preceding::glossary[parent::article or parent::book or parent::part][1]
245 |preceding::index[$generate.index != 0]
246 [parent::article or parent::book or parent::part][1]
247 |preceding::setindex[$generate.index != 0][1]
250 |ancestor::preface[1]
251 |ancestor::chapter[1]
252 |ancestor::appendix[1]
254 |ancestor::reference[1]
255 |ancestor::article[1]
257 |$prev-v2)[last()]"/>
259 <xsl:variable name="next-v1"
260 select="(following::sect1[$chunk.section.depth > 0
261 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
262 and preceding-sibling::sect1][1]
264 |following::sect2[$chunk.section.depth > 1
265 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
266 and preceding-sibling::sect2
267 and parent::sect1[preceding-sibling::sect1]][1]
269 |following::sect3[$chunk.section.depth > 2
270 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
271 and preceding-sibling::sect3
272 and parent::sect2[preceding-sibling::sect2]
273 and ancestor::sect1[preceding-sibling::sect1]][1]
275 |following::sect4[$chunk.section.depth > 3
276 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
277 and preceding-sibling::sect4
278 and parent::sect3[preceding-sibling::sect3]
279 and ancestor::sect2[preceding-sibling::sect2]
280 and ancestor::sect1[preceding-sibling::sect1]][1]
282 |following::sect5[$chunk.section.depth > 4
283 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
284 and preceding-sibling::sect5
285 and parent::sect4[preceding-sibling::sect4]
286 and ancestor::sect3[preceding-sibling::sect3]
287 and ancestor::sect2[preceding-sibling::sect2]
288 and ancestor::sect1[preceding-sibling::sect1]][1]
290 |following::section[$chunk.section.depth > count(ancestor::section)
291 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
292 and preceding-sibling::section
293 and not(ancestor::section[not(preceding-sibling::section)])][1])[1]"/>
295 <xsl:variable name="next-v2"
296 select="(descendant::sect1[$chunk.section.depth > 0
297 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
298 and preceding-sibling::sect1][1]
300 |descendant::sect2[$chunk.section.depth > 1
301 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
302 and preceding-sibling::sect2
303 and parent::sect1[preceding-sibling::sect1]][1]
305 |descendant::sect3[$chunk.section.depth > 2
306 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
307 and preceding-sibling::sect3
308 and parent::sect2[preceding-sibling::sect2]
309 and ancestor::sect1[preceding-sibling::sect1]][1]
311 |descendant::sect4[$chunk.section.depth > 3
312 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
313 and preceding-sibling::sect4
314 and parent::sect3[preceding-sibling::sect3]
315 and ancestor::sect2[preceding-sibling::sect2]
316 and ancestor::sect1[preceding-sibling::sect1]][1]
318 |descendant::sect5[$chunk.section.depth > 4
319 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
320 and preceding-sibling::sect5
321 and parent::sect4[preceding-sibling::sect4]
322 and ancestor::sect3[preceding-sibling::sect3]
323 and ancestor::sect2[preceding-sibling::sect2]
324 and ancestor::sect1[preceding-sibling::sect1]][1]
326 |descendant::section[$chunk.section.depth > count(ancestor::section)
327 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
328 and preceding-sibling::section
329 and not(ancestor::section[not(preceding-sibling::section)])])[1]"/>
331 <xsl:variable name="next"
332 select="(following::book[1]
333 |following::preface[1]
334 |following::chapter[1]
335 |following::appendix[1]
337 |following::reference[1]
338 |following::refentry[1]
339 |following::colophon[1]
340 |following::bibliography[parent::article or parent::book or parent::part][1]
341 |following::glossary[parent::article or parent::book or parent::part][1]
342 |following::index[$generate.index != 0]
343 [parent::article or parent::book or parent::part][1]
344 |following::article[1]
345 |following::setindex[$generate.index != 0][1]
347 |descendant::preface[1]
348 |descendant::chapter[1]
349 |descendant::appendix[1]
350 |descendant::article[1]
351 |descendant::bibliography[parent::article or parent::book or parent::part][1]
352 |descendant::glossary[parent::article or parent::book or parent::part][1]
353 |descendant::index[$generate.index != 0]
354 [parent::article or parent::book or parent::part][1]
355 |descendant::colophon[1]
356 |descendant::setindex[$generate.index != 0][1]
358 |descendant::reference[1]
359 |descendant::refentry[1]
363 <xsl:call-template name="process-chunk">
364 <xsl:with-param name="prev" select="$prev"/>
365 <xsl:with-param name="next" select="$next"/>
366 <xsl:with-param name="content" select="$content"/>
370 <xsl:template name="chunk-all-sections">
371 <xsl:param name="content">
375 <xsl:variable name="prev-v1"
376 select="(preceding::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
377 |preceding::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
378 |preceding::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
379 |preceding::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
380 |preceding::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
381 |preceding::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
383 <xsl:variable name="prev-v2"
384 select="(ancestor::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
385 |ancestor::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
386 |ancestor::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
387 |ancestor::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
388 |ancestor::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
389 |ancestor::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
391 <xsl:variable name="prev"
392 select="(preceding::book[1]
393 |preceding::preface[1]
394 |preceding::chapter[1]
395 |preceding::appendix[1]
397 |preceding::reference[1]
398 |preceding::refentry[1]
399 |preceding::colophon[1]
400 |preceding::article[1]
401 |preceding::bibliography[parent::article or parent::book or parent::part][1]
402 |preceding::glossary[parent::article or parent::book or parent::part][1]
403 |preceding::index[$generate.index != 0]
404 [parent::article or parent::book or parent::part][1]
405 |preceding::setindex[$generate.index != 0][1]
408 |ancestor::preface[1]
409 |ancestor::chapter[1]
410 |ancestor::appendix[1]
412 |ancestor::reference[1]
413 |ancestor::article[1]
415 |$prev-v2)[last()]"/>
417 <xsl:variable name="next-v1"
418 select="(following::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
419 |following::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
420 |following::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
421 |following::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
422 |following::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
423 |following::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
425 <xsl:variable name="next-v2"
426 select="(descendant::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
427 |descendant::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
428 |descendant::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
429 |descendant::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
430 |descendant::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
431 |descendant::section[$chunk.section.depth
432 > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
434 <xsl:variable name="next"
435 select="(following::book[1]
436 |following::preface[1]
437 |following::chapter[1]
438 |following::appendix[1]
440 |following::reference[1]
441 |following::refentry[1]
442 |following::colophon[1]
443 |following::bibliography[parent::article or parent::book or parent::part][1]
444 |following::glossary[parent::article or parent::book or parent::part][1]
445 |following::index[$generate.index != 0]
446 [parent::article or parent::book][1]
447 |following::article[1]
448 |following::setindex[$generate.index != 0][1]
450 |descendant::preface[1]
451 |descendant::chapter[1]
452 |descendant::appendix[1]
453 |descendant::article[1]
454 |descendant::bibliography[parent::article or parent::book][1]
455 |descendant::glossary[parent::article or parent::book or parent::part][1]
456 |descendant::index[$generate.index != 0]
457 [parent::article or parent::book][1]
458 |descendant::colophon[1]
459 |descendant::setindex[$generate.index != 0][1]
461 |descendant::reference[1]
462 |descendant::refentry[1]
466 <xsl:call-template name="process-chunk">
467 <xsl:with-param name="prev" select="$prev"/>
468 <xsl:with-param name="next" select="$next"/>
469 <xsl:with-param name="content" select="$content"/>
473 <!-- ==================================================================== -->
475 <!-- ==================================================================== -->
477 <xsl:template name="make.lots">
478 <xsl:param name="toc.params" select="''"/>
479 <xsl:param name="toc"/>
481 <xsl:variable name="lots">
482 <xsl:if test="contains($toc.params, 'toc')">
483 <xsl:copy-of select="$toc"/>
486 <xsl:if test="contains($toc.params, 'figure')">
488 <xsl:when test="$chunk.separate.lots != '0'">
489 <xsl:call-template name="make.lot.chunk">
490 <xsl:with-param name="type" select="'figure'"/>
491 <xsl:with-param name="lot">
492 <xsl:call-template name="list.of.titles">
493 <xsl:with-param name="titles" select="'figure'"/>
494 <xsl:with-param name="nodes" select=".//figure"/>
500 <xsl:call-template name="list.of.titles">
501 <xsl:with-param name="titles" select="'figure'"/>
502 <xsl:with-param name="nodes" select=".//figure"/>
508 <xsl:if test="contains($toc.params, 'table')">
510 <xsl:when test="$chunk.separate.lots != '0'">
511 <xsl:call-template name="make.lot.chunk">
512 <xsl:with-param name="type" select="'table'"/>
513 <xsl:with-param name="lot">
514 <xsl:call-template name="list.of.titles">
515 <xsl:with-param name="titles" select="'table'"/>
516 <xsl:with-param name="nodes" select=".//table"/>
522 <xsl:call-template name="list.of.titles">
523 <xsl:with-param name="titles" select="'table'"/>
524 <xsl:with-param name="nodes" select=".//table"/>
530 <xsl:if test="contains($toc.params, 'example')">
532 <xsl:when test="$chunk.separate.lots != '0'">
533 <xsl:call-template name="make.lot.chunk">
534 <xsl:with-param name="type" select="'example'"/>
535 <xsl:with-param name="lot">
536 <xsl:call-template name="list.of.titles">
537 <xsl:with-param name="titles" select="'example'"/>
538 <xsl:with-param name="nodes" select=".//example"/>
544 <xsl:call-template name="list.of.titles">
545 <xsl:with-param name="titles" select="'example'"/>
546 <xsl:with-param name="nodes" select=".//example"/>
552 <xsl:if test="contains($toc.params, 'equation')">
554 <xsl:when test="$chunk.separate.lots != '0'">
555 <xsl:call-template name="make.lot.chunk">
556 <xsl:with-param name="type" select="'equation'"/>
557 <xsl:with-param name="lot">
558 <xsl:call-template name="list.of.titles">
559 <xsl:with-param name="titles" select="'equation'"/>
560 <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
566 <xsl:call-template name="list.of.titles">
567 <xsl:with-param name="titles" select="'equation'"/>
568 <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
574 <xsl:if test="contains($toc.params, 'procedure')">
576 <xsl:when test="$chunk.separate.lots != '0'">
577 <xsl:call-template name="make.lot.chunk">
578 <xsl:with-param name="type" select="'procedure'"/>
579 <xsl:with-param name="lot">
580 <xsl:call-template name="list.of.titles">
581 <xsl:with-param name="titles" select="'procedure'"/>
582 <xsl:with-param name="nodes" select=".//procedure[title]"/>
588 <xsl:call-template name="list.of.titles">
589 <xsl:with-param name="titles" select="'procedure'"/>
590 <xsl:with-param name="nodes" select=".//procedure[title]"/>
597 <xsl:if test="string($lots) != ''">
599 <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
600 <xsl:call-template name="write.chunk">
601 <xsl:with-param name="filename">
602 <xsl:call-template name="make-relative-filename">
603 <xsl:with-param name="base.dir" select="$base.dir"/>
604 <xsl:with-param name="base.name">
605 <xsl:call-template name="dbhtml-dir"/>
606 <xsl:apply-templates select="." mode="recursive-chunk-filename">
607 <xsl:with-param name="recursive" select="true()"/>
608 </xsl:apply-templates>
609 <xsl:text>-toc</xsl:text>
610 <xsl:value-of select="$html.ext"/>
614 <xsl:with-param name="content">
615 <xsl:call-template name="chunk-element-content">
616 <xsl:with-param name="prev" select="/foo"/>
617 <xsl:with-param name="next" select="/foo"/>
618 <xsl:with-param name="nav.context" select="'toc'"/>
619 <xsl:with-param name="content">
620 <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
622 <xsl:apply-templates select="." mode="object.title.markup"/>
625 <xsl:copy-of select="$lots"/>
629 <xsl:with-param name="quiet" select="$chunk.quietly"/>
633 <xsl:copy-of select="$lots"/>
639 <xsl:template name="make.lot.chunk">
640 <xsl:param name="type" select="''"/>
641 <xsl:param name="lot"/>
643 <xsl:if test="string($lot) != ''">
644 <xsl:variable name="filename">
645 <xsl:call-template name="make-relative-filename">
646 <xsl:with-param name="base.dir" select="$base.dir"/>
647 <xsl:with-param name="base.name">
648 <xsl:call-template name="dbhtml-dir"/>
649 <xsl:value-of select="$type"/>
650 <xsl:text>-toc</xsl:text>
651 <xsl:value-of select="$html.ext"/>
656 <xsl:variable name="href">
657 <xsl:call-template name="make-relative-filename">
658 <xsl:with-param name="base.name">
659 <xsl:call-template name="dbhtml-dir"/>
660 <xsl:value-of select="$type"/>
661 <xsl:text>-toc</xsl:text>
662 <xsl:value-of select="$html.ext"/>
667 <xsl:call-template name="write.chunk">
668 <xsl:with-param name="filename" select="$filename"/>
669 <xsl:with-param name="content">
670 <xsl:call-template name="chunk-element-content">
671 <xsl:with-param name="prev" select="/foo"/>
672 <xsl:with-param name="next" select="/foo"/>
673 <xsl:with-param name="nav.context" select="'toc'"/>
674 <xsl:with-param name="content">
675 <xsl:copy-of select="$lot"/>
679 <xsl:with-param name="quiet" select="$chunk.quietly"/>
681 <!-- And output a link to this file -->
683 <xsl:attribute name="class">
684 <xsl:text>ListofTitles</xsl:text>
687 <xsl:call-template name="gentext">
688 <xsl:with-param name="key">
690 <xsl:when test="$type='table'">ListofTables</xsl:when>
691 <xsl:when test="$type='figure'">ListofFigures</xsl:when>
692 <xsl:when test="$type='equation'">ListofEquations</xsl:when>
693 <xsl:when test="$type='example'">ListofExamples</xsl:when>
694 <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
695 <xsl:otherwise>ListofUnknown</xsl:otherwise>
704 <!-- ==================================================================== -->
706 <xsl:template name="in.other.chunk">
707 <xsl:param name="chunk" select="."/>
708 <xsl:param name="node" select="."/>
710 <xsl:variable name="is.chunk">
711 <xsl:call-template name="chunk">
712 <xsl:with-param name="node" select="$node"/>
718 <xsl:text>in.other.chunk: </xsl:text>
719 <xsl:value-of select="name($chunk)"/>
720 <xsl:text> </xsl:text>
721 <xsl:value-of select="name($node)"/>
722 <xsl:text> </xsl:text>
723 <xsl:value-of select="$chunk = $node"/>
724 <xsl:text> </xsl:text>
725 <xsl:value-of select="$is.chunk"/>
730 <xsl:when test="$chunk = $node">0</xsl:when>
731 <xsl:when test="$is.chunk = 1">1</xsl:when>
732 <xsl:when test="count($node) = 0">0</xsl:when>
734 <xsl:call-template name="in.other.chunk">
735 <xsl:with-param name="chunk" select="$chunk"/>
736 <xsl:with-param name="node" select="$node/parent::*"/>
742 <xsl:template name="count.footnotes.in.this.chunk">
743 <xsl:param name="node" select="."/>
744 <xsl:param name="footnotes" select="$node//footnote"/>
745 <xsl:param name="count" select="0"/>
749 <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
750 <xsl:value-of select="name($node)"/>
754 <xsl:variable name="in.other.chunk">
755 <xsl:call-template name="in.other.chunk">
756 <xsl:with-param name="chunk" select="$node"/>
757 <xsl:with-param name="node" select="$footnotes[1]"/>
762 <xsl:when test="count($footnotes) = 0">
763 <xsl:value-of select="$count"/>
767 <xsl:when test="$in.other.chunk != 0">
768 <xsl:call-template name="count.footnotes.in.this.chunk">
769 <xsl:with-param name="node" select="$node"/>
770 <xsl:with-param name="footnotes"
771 select="$footnotes[position() > 1]"/>
772 <xsl:with-param name="count" select="$count"/>
775 <xsl:when test="$footnotes[1]/ancestor::table
776 |$footnotes[1]/ancestor::informaltable">
777 <xsl:call-template name="count.footnotes.in.this.chunk">
778 <xsl:with-param name="node" select="$node"/>
779 <xsl:with-param name="footnotes"
780 select="$footnotes[position() > 1]"/>
781 <xsl:with-param name="count" select="$count"/>
785 <xsl:call-template name="count.footnotes.in.this.chunk">
786 <xsl:with-param name="node" select="$node"/>
787 <xsl:with-param name="footnotes"
788 select="$footnotes[position() > 1]"/>
789 <xsl:with-param name="count" select="$count + 1"/>
797 <xsl:template name="process.footnotes.in.this.chunk">
798 <xsl:param name="node" select="."/>
799 <xsl:param name="footnotes" select="$node//footnote"/>
802 <xsl:message>process.footnotes.in.this.chunk</xsl:message>
805 <xsl:variable name="in.other.chunk">
806 <xsl:call-template name="in.other.chunk">
807 <xsl:with-param name="chunk" select="$node"/>
808 <xsl:with-param name="node" select="$footnotes[1]"/>
813 <xsl:when test="count($footnotes) = 0">
818 <xsl:when test="$in.other.chunk != 0">
819 <xsl:call-template name="process.footnotes.in.this.chunk">
820 <xsl:with-param name="node" select="$node"/>
821 <xsl:with-param name="footnotes"
822 select="$footnotes[position() > 1]"/>
825 <xsl:when test="$footnotes[1]/ancestor::table
826 |$footnotes[1]/ancestor::informaltable">
827 <xsl:call-template name="process.footnotes.in.this.chunk">
828 <xsl:with-param name="node" select="$node"/>
829 <xsl:with-param name="footnotes"
830 select="$footnotes[position() > 1]"/>
834 <xsl:apply-templates select="$footnotes[1]"
835 mode="process.footnote.mode"/>
836 <xsl:call-template name="process.footnotes.in.this.chunk">
837 <xsl:with-param name="node" select="$node"/>
838 <xsl:with-param name="footnotes"
839 select="$footnotes[position() > 1]"/>
847 <xsl:template name="process.footnotes">
848 <xsl:variable name="footnotes" select=".//footnote"/>
849 <xsl:variable name="fcount">
850 <xsl:call-template name="count.footnotes.in.this.chunk">
851 <xsl:with-param name="node" select="."/>
852 <xsl:with-param name="footnotes" select="$footnotes"/>
858 <xsl:value-of select="name(.)"/>
859 <xsl:text> fcount: </xsl:text>
860 <xsl:value-of select="$fcount"/>
864 <!-- Only bother to do this if there's at least one non-table footnote -->
865 <xsl:if test="$fcount > 0">
866 <div class="footnotes">
868 <hr width="100" align="{$direction.align.start}"/>
869 <xsl:call-template name="process.footnotes.in.this.chunk">
870 <xsl:with-param name="node" select="."/>
871 <xsl:with-param name="footnotes" select="$footnotes"/>
876 <!-- FIXME: When chunking, only the annotations actually used
877 in this chunk should be referenced. I don't think it
878 does any harm to reference them all, but it adds
879 unnecessary bloat to each chunk. -->
880 <xsl:if test="$annotation.support != 0 and //annotation">
881 <div class="annotation-list">
882 <div class="annotation-nocss">
883 <p>The following annotations are from this essay. You are seeing
884 them here because your browser doesn’t support the user-interface
885 techniques used to make them appear as ‘popups’ on modern browsers.</p>
888 <xsl:apply-templates select="//annotation"
889 mode="annotation-popup"/>
894 <xsl:template name="process.chunk.footnotes">
895 <xsl:variable name="is.chunk">
896 <xsl:call-template name="chunk"/>
898 <xsl:if test="$is.chunk = 1">
899 <xsl:call-template name="process.footnotes"/>
903 <!-- ====================================================================== -->
905 <xsl:template name="chunk">
906 <xsl:param name="node" select="."/>
907 <!-- returns 1 if $node is a chunk -->
909 <!-- ==================================================================== -->
915 bibliography in article or part or book
919 glossary in article or part or book
920 index in article or part or book
925 sect{1,2,3,4,5} if position()>1 && depth < chunk.section.depth
926 section if position()>1 && depth < chunk.section.depth
930 <!-- ==================================================================== -->
934 <xsl:text>chunk: </xsl:text>
935 <xsl:value-of select="name($node)"/>
936 <xsl:text>(</xsl:text>
937 <xsl:value-of select="$node/@id"/>
938 <xsl:text>)</xsl:text>
939 <xsl:text> csd: </xsl:text>
940 <xsl:value-of select="$chunk.section.depth"/>
941 <xsl:text> cfs: </xsl:text>
942 <xsl:value-of select="$chunk.first.sections"/>
943 <xsl:text> ps: </xsl:text>
944 <xsl:value-of select="count($node/parent::section)"/>
945 <xsl:text> prs: </xsl:text>
946 <xsl:value-of select="count($node/preceding-sibling::section)"/>
951 <xsl:when test="$node/parent::*/processing-instruction('dbhtml')[normalize-space(.) = 'stop-chunking']">0</xsl:when>
952 <xsl:when test="not($node/parent::*)">1</xsl:when>
954 <xsl:when test="local-name($node) = 'sect1'
955 and $chunk.section.depth >= 1
956 and ($chunk.first.sections != 0
957 or count($node/preceding-sibling::sect1) > 0)">
958 <xsl:text>1</xsl:text>
960 <xsl:when test="local-name($node) = 'sect2'
961 and $chunk.section.depth >= 2
962 and ($chunk.first.sections != 0
963 or count($node/preceding-sibling::sect2) > 0)">
964 <xsl:call-template name="chunk">
965 <xsl:with-param name="node" select="$node/parent::*"/>
968 <xsl:when test="local-name($node) = 'sect3'
969 and $chunk.section.depth >= 3
970 and ($chunk.first.sections != 0
971 or count($node/preceding-sibling::sect3) > 0)">
972 <xsl:call-template name="chunk">
973 <xsl:with-param name="node" select="$node/parent::*"/>
976 <xsl:when test="local-name($node) = 'sect4'
977 and $chunk.section.depth >= 4
978 and ($chunk.first.sections != 0
979 or count($node/preceding-sibling::sect4) > 0)">
980 <xsl:call-template name="chunk">
981 <xsl:with-param name="node" select="$node/parent::*"/>
984 <xsl:when test="local-name($node) = 'sect5'
985 and $chunk.section.depth >= 5
986 and ($chunk.first.sections != 0
987 or count($node/preceding-sibling::sect5) > 0)">
988 <xsl:call-template name="chunk">
989 <xsl:with-param name="node" select="$node/parent::*"/>
992 <xsl:when test="local-name($node) = 'section'
993 and $chunk.section.depth >= count($node/ancestor::section)+1
994 and ($chunk.first.sections != 0
995 or count($node/preceding-sibling::section) > 0)">
996 <xsl:call-template name="chunk">
997 <xsl:with-param name="node" select="$node/parent::*"/>
1001 <xsl:when test="local-name($node)='preface'">1</xsl:when>
1002 <xsl:when test="local-name($node)='chapter'">1</xsl:when>
1003 <xsl:when test="local-name($node)='appendix'">1</xsl:when>
1004 <xsl:when test="local-name($node)='article'">1</xsl:when>
1005 <xsl:when test="local-name($node)='part'">1</xsl:when>
1006 <xsl:when test="local-name($node)='reference'">1</xsl:when>
1007 <xsl:when test="local-name($node)='refentry'">1</xsl:when>
1008 <xsl:when test="local-name($node)='index' and ($generate.index != 0 or count($node/*) > 0)
1009 and (local-name($node/parent::*) = 'article'
1010 or local-name($node/parent::*) = 'book'
1011 or local-name($node/parent::*) = 'part'
1013 <xsl:when test="local-name($node)='bibliography'
1014 and (local-name($node/parent::*) = 'article'
1015 or local-name($node/parent::*) = 'book'
1016 or local-name($node/parent::*) = 'part'
1018 <xsl:when test="local-name($node)='glossary'
1019 and (local-name($node/parent::*) = 'article'
1020 or local-name($node/parent::*) = 'book'
1021 or local-name($node/parent::*) = 'part'
1023 <xsl:when test="local-name($node)='colophon'">1</xsl:when>
1024 <xsl:when test="local-name($node)='book'">1</xsl:when>
1025 <xsl:when test="local-name($node)='set'">1</xsl:when>
1026 <xsl:when test="local-name($node)='setindex'">1</xsl:when>
1027 <xsl:when test="local-name($node)='legalnotice'
1028 and $generate.legalnotice.link != 0">1</xsl:when>
1029 <xsl:otherwise>0</xsl:otherwise>
1033 <!-- ==================================================================== -->
1034 <xsl:template name="href.target.uri">
1035 <xsl:param name="object" select="."/>
1036 <xsl:variable name="ischunk">
1037 <xsl:call-template name="chunk">
1038 <xsl:with-param name="node" select="$object"/>
1039 </xsl:call-template>
1042 <xsl:apply-templates mode="chunk-filename" select="$object"/>
1044 <xsl:if test="$ischunk='0'">
1045 <xsl:text>#</xsl:text>
1046 <xsl:call-template name="object.id">
1047 <xsl:with-param name="object" select="$object"/>
1048 </xsl:call-template>
1052 <xsl:template name="href.target">
1053 <xsl:param name="context" select="."/>
1054 <xsl:param name="object" select="."/>
1055 <xsl:param name="toc-context" select="."/>
1056 <!-- * If $toc-context contains some node other than the current node, -->
1057 <!-- * it means we're processing a link in a TOC. In that case, to -->
1058 <!-- * ensure the link will work correctly, we need to take a look at -->
1059 <!-- * where the file containing the TOC will get written, and where -->
1060 <!-- * the file that's being linked to will get written. -->
1061 <xsl:variable name="toc-output-dir">
1062 <xsl:if test="not($toc-context = .)">
1063 <!-- * Get the $toc-context node and all its ancestors, look down -->
1064 <!-- * through them to find the last/closest node to the -->
1065 <!-- * toc-context node that has a "dbhtml dir" PI, and get the -->
1066 <!-- * directory name from that. That's the name of the directory -->
1067 <!-- * to which the current toc output file will get written. -->
1068 <xsl:call-template name="dbhtml-dir">
1069 <xsl:with-param name="context"
1070 select="$toc-context/ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
1071 </xsl:call-template>
1074 <xsl:variable name="linked-file-output-dir">
1075 <xsl:if test="not($toc-context = .)">
1076 <!-- * Get the current node and all its ancestors, look down -->
1077 <!-- * through them to find the last/closest node to the current -->
1078 <!-- * node that has a "dbhtml dir" PI, and get the directory name -->
1079 <!-- * from that. That's the name of the directory to which the -->
1080 <!-- * file that's being linked to will get written. -->
1081 <xsl:call-template name="dbhtml-dir">
1082 <xsl:with-param name="context"
1083 select="ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
1084 </xsl:call-template>
1087 <xsl:variable name="href.to.uri">
1088 <xsl:call-template name="href.target.uri">
1089 <xsl:with-param name="object" select="$object"/>
1090 </xsl:call-template>
1092 <xsl:variable name="href.from.uri">
1094 <xsl:when test="not($toc-context = .)">
1095 <xsl:call-template name="href.target.uri">
1096 <xsl:with-param name="object" select="$toc-context"/>
1097 </xsl:call-template>
1100 <xsl:call-template name="href.target.uri">
1101 <xsl:with-param name="object" select="$context"/>
1102 </xsl:call-template>
1106 <!-- * <xsl:message>toc-context: <xsl:value-of select="local-name($toc-context)"/></xsl:message> -->
1107 <!-- * <xsl:message>node: <xsl:value-of select="local-name(.)"/></xsl:message> -->
1108 <!-- * <xsl:message>context: <xsl:value-of select="local-name($context)"/></xsl:message> -->
1109 <!-- * <xsl:message>object: <xsl:value-of select="local-name($object)"/></xsl:message> -->
1110 <!-- * <xsl:message>toc-output-dir: <xsl:value-of select="$toc-output-dir"/></xsl:message> -->
1111 <!-- * <xsl:message>linked-file-output-dir: <xsl:value-of select="$linked-file-output-dir"/></xsl:message> -->
1112 <!-- * <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> -->
1113 <!-- * <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> -->
1114 <xsl:variable name="href.to">
1116 <!-- * 2007-07-19, MikeSmith: Added the following conditional to -->
1117 <!-- * deal with a problem case for links in TOCs. It checks to see -->
1118 <!-- * if the output dir that a TOC will get written to is -->
1119 <!-- * different from the output dir of the file being linked to. -->
1120 <!-- * If it is different, we do not call trim.common.uri.paths. -->
1122 <!-- * Reason why I added that conditional is: I ran into a bug for -->
1123 <!-- * this case: -->
1125 <!-- * 1. we are chunking into separate dirs -->
1127 <!-- * 2. output for the TOC is written to current dir, but the file -->
1128 <!-- * being linked to is written to some subdir "foo". -->
1130 <!-- * For that case, links to that file in that TOC did not show -->
1131 <!-- * the correct path - they omitted the "foo". -->
1133 <!-- * The cause of that problem was that the trim.common.uri.paths -->
1134 <!-- * template[1] was being called under all conditions. But it's -->
1135 <!-- * apparent that we don't want to call trim.common.uri.paths in -->
1136 <!-- * the case where a linked file is being written to a different -->
1137 <!-- * directory than the TOC that contains the link, because doing -->
1138 <!-- * so will cause a necessary (not redundant) directory-name -->
1139 <!-- * part of the link to get inadvertently trimmed, resulting in -->
1140 <!-- * a broken link to that file. Thus, added the conditional. -->
1142 <!-- * [1] The purpose of the trim.common.uri.paths template is to -->
1143 <!-- * prevent cases where, if we didn't call it, we end up with -->
1144 <!-- * unnecessary, redundant directory names getting output; for -->
1145 <!-- * example, "foo/foo/refname.html". -->
1146 <xsl:when test="not($toc-output-dir = $linked-file-output-dir)">
1147 <xsl:value-of select="$href.to.uri"/>
1150 <xsl:call-template name="trim.common.uri.paths">
1151 <xsl:with-param name="uriA" select="$href.to.uri"/>
1152 <xsl:with-param name="uriB" select="$href.from.uri"/>
1153 <xsl:with-param name="return" select="'A'"/>
1154 </xsl:call-template>
1158 <xsl:variable name="href.from">
1159 <xsl:call-template name="trim.common.uri.paths">
1160 <xsl:with-param name="uriA" select="$href.to.uri"/>
1161 <xsl:with-param name="uriB" select="$href.from.uri"/>
1162 <xsl:with-param name="return" select="'B'"/>
1163 </xsl:call-template>
1165 <xsl:variable name="depth">
1166 <xsl:call-template name="count.uri.path.depth">
1167 <xsl:with-param name="filename" select="$href.from"/>
1168 </xsl:call-template>
1170 <xsl:variable name="href">
1171 <xsl:call-template name="copy-string">
1172 <xsl:with-param name="string" select="'../'"/>
1173 <xsl:with-param name="count" select="$depth"/>
1174 </xsl:call-template>
1175 <xsl:value-of select="$href.to"/>
1179 <xsl:text>In </xsl:text>
1180 <xsl:value-of select="name(.)"/>
1181 <xsl:text> (</xsl:text>
1182 <xsl:value-of select="$href.from"/>
1183 <xsl:text>,</xsl:text>
1184 <xsl:value-of select="$depth"/>
1185 <xsl:text>) </xsl:text>
1186 <xsl:value-of select="name($object)"/>
1187 <xsl:text> href=</xsl:text>
1188 <xsl:value-of select="$href"/>
1191 <xsl:value-of select="$href"/>
1194 <!-- Returns the complete olink href value if found -->
1195 <!-- Must take into account any dbhtml dir of the chunk containing the olink -->
1196 <xsl:template name="make.olink.href">
1197 <xsl:param name="olink.key" select="''"/>
1198 <xsl:param name="target.database"/>
1200 <xsl:if test="$olink.key != ''">
1201 <xsl:variable name="target.href" >
1202 <xsl:for-each select="$target.database" >
1203 <xsl:value-of select="key('targetptr-key', $olink.key)[1]/@href" />
1207 <!-- an olink starting point may be in a subdirectory, so need
1208 the "from" reference point to compute a relative path -->
1210 <xsl:variable name="from.href">
1211 <xsl:call-template name="olink.from.uri">
1212 <xsl:with-param name="target.database" select="$target.database"/>
1213 <xsl:with-param name="object" select="."/>
1214 <xsl:with-param name="object.targetdoc" select="$current.docid"/>
1215 </xsl:call-template>
1218 <!-- If the from.href has directory path, then must "../" upward
1219 to document level -->
1220 <xsl:variable name="upward.from.path">
1221 <xsl:call-template name="upward.path">
1222 <xsl:with-param name="path" select="$from.href"/>
1223 </xsl:call-template>
1226 <xsl:variable name="targetdoc">
1227 <xsl:value-of select="substring-before($olink.key, '/')"/>
1230 <!-- Does the target database use a sitemap? -->
1231 <xsl:variable name="use.sitemap">
1233 <xsl:when test="$target.database//sitemap">1</xsl:when>
1234 <xsl:otherwise>0</xsl:otherwise>
1239 <!-- Get the baseuri for this targetptr -->
1240 <xsl:variable name="baseuri" >
1242 <!-- Does the database use a sitemap? -->
1243 <xsl:when test="$use.sitemap != 0" >
1245 <!-- Was current.docid parameter set? -->
1246 <xsl:when test="$current.docid != ''">
1247 <!-- Was it found in the database? -->
1248 <xsl:variable name="currentdoc.key" >
1249 <xsl:for-each select="$target.database" >
1250 <xsl:value-of select="key('targetdoc-key',
1251 $current.docid)/@targetdoc" />
1255 <xsl:when test="$currentdoc.key != ''">
1256 <xsl:for-each select="$target.database" >
1257 <xsl:call-template name="targetpath" >
1258 <xsl:with-param name="dirnode"
1259 select="key('targetdoc-key', $current.docid)/parent::dir"/>
1260 <xsl:with-param name="targetdoc" select="$targetdoc"/>
1261 </xsl:call-template>
1266 <xsl:text>Olink error: cannot compute relative </xsl:text>
1267 <xsl:text>sitemap path because $current.docid '</xsl:text>
1268 <xsl:value-of select="$current.docid"/>
1269 <xsl:text>' not found in target database.</xsl:text>
1276 <xsl:text>Olink warning: cannot compute relative </xsl:text>
1277 <xsl:text>sitemap path without $current.docid parameter</xsl:text>
1281 <!-- In either case, add baseuri from its document entry-->
1282 <xsl:variable name="docbaseuri">
1283 <xsl:for-each select="$target.database" >
1284 <xsl:value-of select="key('targetdoc-key', $targetdoc)/@baseuri" />
1287 <xsl:if test="$docbaseuri != ''" >
1288 <xsl:value-of select="$docbaseuri"/>
1291 <!-- No database sitemap in use -->
1293 <!-- Just use any baseuri from its document entry -->
1294 <xsl:variable name="docbaseuri">
1295 <xsl:for-each select="$target.database" >
1296 <xsl:value-of select="key('targetdoc-key', $targetdoc)/@baseuri" />
1299 <xsl:if test="$docbaseuri != ''" >
1300 <xsl:value-of select="$docbaseuri"/>
1306 <!-- Form the href information -->
1307 <xsl:if test="not(contains($baseuri, ':'))">
1308 <!-- if not an absolute uri, add upward path from olink chunk -->
1309 <xsl:value-of select="$upward.from.path"/>
1312 <xsl:if test="$baseuri != ''">
1313 <xsl:value-of select="$baseuri"/>
1314 <xsl:if test="substring($target.href,1,1) != '#'">
1315 <!--xsl:text>/</xsl:text-->
1318 <!-- optionally turn off frag for PDF references -->
1319 <xsl:if test="not($insert.olink.pdf.frag = 0 and
1320 translate(substring($baseuri, string-length($baseuri) - 3),
1321 'PDF', 'pdf') = '.pdf'
1322 and starts-with($target.href, '#') )">
1323 <xsl:value-of select="$target.href"/>
1328 <!-- Computes "../" to reach top -->
1329 <xsl:template name="upward.path">
1330 <xsl:param name="path" select="''"/>
1332 <!-- Don't bother with absolute uris -->
1333 <xsl:when test="contains($path, ':')"/>
1334 <xsl:when test="starts-with($path, '/')"/>
1335 <xsl:when test="contains($path, '/')">
1336 <xsl:text>../</xsl:text>
1337 <xsl:call-template name="upward.path">
1338 <xsl:with-param name="path" select="substring-after($path, '/')"/>
1339 </xsl:call-template>
1345 <!-- ==================================================================== -->
1347 <xsl:template name="html.head">
1348 <xsl:param name="prev" select="/foo"/>
1349 <xsl:param name="next" select="/foo"/>
1350 <xsl:variable name="this" select="."/>
1351 <xsl:variable name="home" select="/*[1]"/>
1352 <xsl:variable name="up" select="parent::*"/>
1355 <xsl:call-template name="system.head.content"/>
1356 <xsl:call-template name="head.content"/>
1358 <xsl:if test="$home">
1360 <xsl:attribute name="href">
1361 <xsl:call-template name="href.target">
1362 <xsl:with-param name="object" select="$home"/>
1363 </xsl:call-template>
1365 <xsl:attribute name="title">
1366 <xsl:apply-templates select="$home"
1367 mode="object.title.markup.textonly"/>
1374 <xsl:attribute name="href">
1375 <xsl:call-template name="href.target">
1376 <xsl:with-param name="object" select="$up"/>
1377 </xsl:call-template>
1379 <xsl:attribute name="title">
1380 <xsl:apply-templates select="$up" mode="object.title.markup.textonly"/>
1385 <xsl:if test="$prev">
1387 <xsl:attribute name="href">
1388 <xsl:call-template name="href.target">
1389 <xsl:with-param name="object" select="$prev"/>
1390 </xsl:call-template>
1392 <xsl:attribute name="title">
1393 <xsl:apply-templates select="$prev" mode="object.title.markup.textonly"/>
1398 <xsl:if test="$next">
1400 <xsl:attribute name="href">
1401 <xsl:call-template name="href.target">
1402 <xsl:with-param name="object" select="$next"/>
1403 </xsl:call-template>
1405 <xsl:attribute name="title">
1406 <xsl:apply-templates select="$next" mode="object.title.markup.textonly"/>
1411 <xsl:if test="$html.extra.head.links != 0">
1412 <xsl:for-each select="//part
1418 |//appendix[not(parent::article)]|appendix
1419 |//glossary[not(parent::article)]|glossary
1420 |//index[not(parent::article)]|index">
1421 <link rel="{local-name(.)}">
1422 <xsl:attribute name="href">
1423 <xsl:call-template name="href.target">
1424 <xsl:with-param name="context" select="$this"/>
1425 <xsl:with-param name="object" select="."/>
1426 </xsl:call-template>
1428 <xsl:attribute name="title">
1429 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1434 <xsl:for-each select="section|sect1|refsection|refsect1">
1436 <xsl:attribute name="rel">
1438 <xsl:when test="local-name($this) = 'section'
1439 or local-name($this) = 'refsection'">
1440 <xsl:value-of select="'subsection'"/>
1443 <xsl:value-of select="'section'"/>
1447 <xsl:attribute name="href">
1448 <xsl:call-template name="href.target">
1449 <xsl:with-param name="context" select="$this"/>
1450 <xsl:with-param name="object" select="."/>
1451 </xsl:call-template>
1453 <xsl:attribute name="title">
1454 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1459 <xsl:for-each select="sect2|sect3|sect4|sect5|refsect2|refsect3">
1460 <link rel="subsection">
1461 <xsl:attribute name="href">
1462 <xsl:call-template name="href.target">
1463 <xsl:with-param name="context" select="$this"/>
1464 <xsl:with-param name="object" select="."/>
1465 </xsl:call-template>
1467 <xsl:attribute name="title">
1468 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1474 <!-- * if we have a legalnotice and user wants it output as a -->
1475 <!-- * separate page and $html.head.legalnotice.link.types is -->
1476 <!-- * non-empty, we generate a link or links for each value in -->
1477 <!-- * $html.head.legalnotice.link.types -->
1478 <xsl:if test="//legalnotice
1479 and not($generate.legalnotice.link = 0)
1480 and not($html.head.legalnotice.link.types = '')">
1481 <xsl:call-template name="make.legalnotice.head.links"/>
1484 <xsl:call-template name="user.head.content"/>
1488 <!-- ==================================================================== -->
1490 <xsl:template name="header.navigation">
1491 <xsl:param name="prev" select="/foo"/>
1492 <xsl:param name="next" select="/foo"/>
1493 <xsl:param name="nav.context"/>
1495 <xsl:variable name="home" select="/*[1]"/>
1496 <xsl:variable name="up" select="parent::*"/>
1498 <xsl:variable name="row1" select="$navig.showtitles != 0"/>
1499 <xsl:variable name="row2" select="count($prev) > 0
1500 or (count($up) > 0
1501 and generate-id($up) != generate-id($home)
1502 and $navig.showtitles != 0)
1503 or count($next) > 0"/>
1505 <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'">
1506 <div class="navheader">
1507 <xsl:if test="$row1 or $row2">
1508 <table width="100%" summary="Navigation header">
1509 <xsl:if test="$row1">
1511 <th colspan="3" align="center">
1512 <xsl:apply-templates select="." mode="object.title.markup"/>
1517 <xsl:if test="$row2">
1519 <td width="20%" align="{$direction.align.start}">
1520 <xsl:if test="count($prev)>0">
1522 <xsl:attribute name="href">
1523 <xsl:call-template name="href.target">
1524 <xsl:with-param name="object" select="$prev"/>
1525 </xsl:call-template>
1527 <xsl:call-template name="navig.content">
1528 <xsl:with-param name="direction" select="'prev'"/>
1529 </xsl:call-template>
1532 <xsl:text> </xsl:text>
1534 <th width="60%" align="center">
1536 <xsl:when test="count($up) > 0
1537 and generate-id($up) != generate-id($home)
1538 and $navig.showtitles != 0">
1539 <xsl:apply-templates select="$up" mode="object.title.markup"/>
1541 <xsl:otherwise> </xsl:otherwise>
1544 <td width="20%" align="{$direction.align.end}">
1545 <xsl:text> </xsl:text>
1546 <xsl:if test="count($next)>0">
1548 <xsl:attribute name="href">
1549 <xsl:call-template name="href.target">
1550 <xsl:with-param name="object" select="$next"/>
1551 </xsl:call-template>
1553 <xsl:call-template name="navig.content">
1554 <xsl:with-param name="direction" select="'next'"/>
1555 </xsl:call-template>
1563 <xsl:if test="$header.rule != 0">
1570 <!-- ==================================================================== -->
1572 <xsl:template name="footer.navigation">
1573 <xsl:param name="prev" select="/foo"/>
1574 <xsl:param name="next" select="/foo"/>
1575 <xsl:param name="nav.context"/>
1577 <xsl:variable name="home" select="/*[1]"/>
1578 <xsl:variable name="up" select="parent::*"/>
1580 <xsl:variable name="row1" select="count($prev) > 0
1581 or count($up) > 0
1582 or count($next) > 0"/>
1584 <xsl:variable name="row2" select="($prev and $navig.showtitles != 0)
1585 or (generate-id($home) != generate-id(.)
1586 or $nav.context = 'toc')
1587 or ($chunk.tocs.and.lots != 0
1588 and $nav.context != 'toc')
1589 or ($next and $navig.showtitles != 0)"/>
1591 <xsl:if test="$suppress.navigation = '0' and $suppress.footer.navigation = '0'">
1592 <div class="navfooter">
1593 <xsl:if test="$footer.rule != 0">
1597 <xsl:if test="$row1 or $row2">
1598 <table width="100%" summary="Navigation footer">
1599 <xsl:if test="$row1">
1601 <td width="40%" align="{$direction.align.start}">
1602 <xsl:if test="count($prev)>0">
1604 <xsl:attribute name="href">
1605 <xsl:call-template name="href.target">
1606 <xsl:with-param name="object" select="$prev"/>
1607 </xsl:call-template>
1609 <xsl:call-template name="navig.content">
1610 <xsl:with-param name="direction" select="'prev'"/>
1611 </xsl:call-template>
1614 <xsl:text> </xsl:text>
1616 <td width="20%" align="center">
1618 <xsl:when test="count($up)>0
1619 and generate-id($up) != generate-id($home)">
1621 <xsl:attribute name="href">
1622 <xsl:call-template name="href.target">
1623 <xsl:with-param name="object" select="$up"/>
1624 </xsl:call-template>
1626 <xsl:call-template name="navig.content">
1627 <xsl:with-param name="direction" select="'up'"/>
1628 </xsl:call-template>
1631 <xsl:otherwise> </xsl:otherwise>
1634 <td width="40%" align="{$direction.align.end}">
1635 <xsl:text> </xsl:text>
1636 <xsl:if test="count($next)>0">
1638 <xsl:attribute name="href">
1639 <xsl:call-template name="href.target">
1640 <xsl:with-param name="object" select="$next"/>
1641 </xsl:call-template>
1643 <xsl:call-template name="navig.content">
1644 <xsl:with-param name="direction" select="'next'"/>
1645 </xsl:call-template>
1652 <xsl:if test="$row2">
1654 <td width="40%" align="{$direction.align.start}" valign="top">
1655 <xsl:if test="$navig.showtitles != 0">
1656 <xsl:apply-templates select="$prev" mode="object.title.markup"/>
1658 <xsl:text> </xsl:text>
1660 <td width="20%" align="center">
1662 <xsl:when test="$home != . or $nav.context = 'toc'">
1664 <xsl:attribute name="href">
1665 <xsl:call-template name="href.target">
1666 <xsl:with-param name="object" select="$home"/>
1667 </xsl:call-template>
1669 <xsl:call-template name="navig.content">
1670 <xsl:with-param name="direction" select="'home'"/>
1671 </xsl:call-template>
1673 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1674 <xsl:text> | </xsl:text>
1677 <xsl:otherwise> </xsl:otherwise>
1680 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1682 <xsl:attribute name="href">
1683 <xsl:apply-templates select="/*[1]"
1684 mode="recursive-chunk-filename">
1685 <xsl:with-param name="recursive" select="true()"/>
1686 </xsl:apply-templates>
1687 <xsl:text>-toc</xsl:text>
1688 <xsl:value-of select="$html.ext"/>
1690 <xsl:call-template name="gentext">
1691 <xsl:with-param name="key" select="'nav-toc'"/>
1692 </xsl:call-template>
1696 <td width="40%" align="{$direction.align.end}" valign="top">
1697 <xsl:text> </xsl:text>
1698 <xsl:if test="$navig.showtitles != 0">
1699 <xsl:apply-templates select="$next" mode="object.title.markup"/>
1710 <!-- ==================================================================== -->
1712 <xsl:template name="navig.content">
1713 <xsl:param name="direction" select="next"/>
1714 <xsl:variable name="navtext">
1716 <xsl:when test="$direction = 'prev'">
1717 <xsl:call-template name="gentext.nav.prev"/>
1719 <xsl:when test="$direction = 'next'">
1720 <xsl:call-template name="gentext.nav.next"/>
1722 <xsl:when test="$direction = 'up'">
1723 <xsl:call-template name="gentext.nav.up"/>
1725 <xsl:when test="$direction = 'home'">
1726 <xsl:call-template name="gentext.nav.home"/>
1729 <xsl:text>xxx</xsl:text>
1735 <xsl:when test="$navig.graphics != 0">
1737 <xsl:attribute name="src">
1738 <xsl:value-of select="$navig.graphics.path"/>
1739 <xsl:value-of select="$direction"/>
1740 <xsl:value-of select="$navig.graphics.extension"/>
1742 <xsl:attribute name="alt">
1743 <xsl:value-of select="$navtext"/>
1748 <xsl:value-of select="$navtext"/>
1753 <!-- ==================================================================== -->
1755 <!-- * The following template assumes that the first legalnotice -->
1756 <!-- * instance found in a document applies to the contents of the -->
1757 <!-- * entire document. It generates an HTML link in each chunk, back -->
1758 <!-- * to the file containing the contents of the first legalnotice. -->
1760 <!-- * Actually, it may generate multiple link instances in each chunk, -->
1761 <!-- * because it walks through the space-separated list of link -->
1762 <!-- * types specified in the $html.head.legalnotice.link.types param, -->
1763 <!-- * popping off link types and generating links for them until it -->
1764 <!-- * depletes the list. -->
1766 <xsl:template name="make.legalnotice.head.links">
1767 <!-- * the following ID is used as part of the legalnotice filename; -->
1768 <!-- * we need it in order to construct the filename for use in the -->
1769 <!-- * value of the href attribute on the link -->
1771 <xsl:param name="ln-node" select="(//legalnotice)[1]"/>
1773 <xsl:param name="linktype">
1775 <xsl:when test="contains($html.head.legalnotice.link.types, ' ')">
1777 select="normalize-space(
1778 substring-before($html.head.legalnotice.link.types, ' '))"/>
1781 <xsl:value-of select="$html.head.legalnotice.link.types"/>
1786 name="remaining.linktypes"
1789 substring-after($html.head.legalnotice.link.types, ' ')),' ')"/>
1790 <xsl:if test="not($linktype = '')">
1792 <!-- Compute name of legalnotice file (see titlepage.xsl) -->
1793 <xsl:variable name="file">
1794 <xsl:call-template name="ln.or.rh.filename">
1795 <xsl:with-param name="node" select="$ln-node"/>
1796 </xsl:call-template>
1799 <link rel="{$linktype}">
1800 <xsl:attribute name="href">
1801 <xsl:value-of select="$file"/>
1803 <xsl:attribute name="title">
1804 <xsl:apply-templates select="(//legalnotice)[1]"
1805 mode="object.title.markup.textonly"/>
1808 <xsl:call-template name="make.legalnotice.head.links">
1809 <!-- * pop the next value off the list of link types -->
1812 select="substring-before($remaining.linktypes, ' ')"/>
1813 <!-- * remove the link type from the list of remaining link types -->
1815 name="remaining.linktypes"
1816 select="substring-after($remaining.linktypes, ' ')"/>
1817 </xsl:call-template>
1821 <!-- ==================================================================== -->
1822 <xsl:template name="chunk-element-content">
1823 <xsl:param name="prev"/>
1824 <xsl:param name="next"/>
1825 <xsl:param name="nav.context"/>
1826 <xsl:param name="content">
1827 <xsl:apply-imports/>
1830 <xsl:call-template name="user.preroot"/>
1833 <xsl:call-template name="html.head">
1834 <xsl:with-param name="prev" select="$prev"/>
1835 <xsl:with-param name="next" select="$next"/>
1836 </xsl:call-template>
1839 <xsl:call-template name="body.attributes"/>
1840 <xsl:call-template name="user.header.navigation"/>
1842 <xsl:call-template name="header.navigation">
1843 <xsl:with-param name="prev" select="$prev"/>
1844 <xsl:with-param name="next" select="$next"/>
1845 <xsl:with-param name="nav.context" select="$nav.context"/>
1846 </xsl:call-template>
1848 <xsl:call-template name="user.header.content"/>
1850 <xsl:copy-of select="$content"/>
1852 <xsl:call-template name="user.footer.content"/>
1854 <xsl:call-template name="footer.navigation">
1855 <xsl:with-param name="prev" select="$prev"/>
1856 <xsl:with-param name="next" select="$next"/>
1857 <xsl:with-param name="nav.context" select="$nav.context"/>
1858 </xsl:call-template>
1860 <xsl:call-template name="user.footer.navigation"/>
1863 <xsl:value-of select="$chunk.append"/>
1866 <!-- ==================================================================== -->
1867 <xsl:template name="generate.manifest">
1868 <xsl:param name="node" select="/"/>
1869 <xsl:call-template name="write.text.chunk">
1870 <xsl:with-param name="filename">
1871 <xsl:if test="$manifest.in.base.dir != 0">
1872 <xsl:value-of select="$base.dir"/>
1874 <xsl:value-of select="$manifest"/>
1876 <xsl:with-param name="method" select="'text'"/>
1877 <xsl:with-param name="content">
1878 <xsl:apply-templates select="$node" mode="enumerate-files"/>
1880 <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
1881 </xsl:call-template>
1884 <!-- ==================================================================== -->
1886 <xsl:template name="dbhtml-dir">
1887 <xsl:param name="context" select="."/>
1888 <!-- directories are now inherited from previous levels -->
1889 <xsl:variable name="ppath">
1890 <xsl:if test="$context/parent::*">
1891 <xsl:call-template name="dbhtml-dir">
1892 <xsl:with-param name="context" select="$context/parent::*"/>
1893 </xsl:call-template>
1896 <xsl:variable name="path">
1897 <xsl:call-template name="pi.dbhtml_dir">
1898 <xsl:with-param name="node" select="$context"/>
1899 </xsl:call-template>
1902 <xsl:when test="$path = ''">
1903 <xsl:if test="$ppath != ''">
1904 <xsl:value-of select="$ppath"/>
1908 <xsl:if test="$ppath != ''">
1909 <xsl:value-of select="$ppath"/>
1910 <xsl:if test="substring($ppath, string-length($ppath), 1) != '/'">
1911 <xsl:text>/</xsl:text>
1914 <xsl:value-of select="$path"/>
1915 <xsl:text>/</xsl:text>