1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2 xmlns:d="http://docbook.org/ns/docbook"
3 xmlns:exsl="http://exslt.org/common"
4 xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
6 exclude-result-prefixes="exsl cf d">
8 <!-- ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://cdn.docbook.org/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
18 <xsl:param name="onechunk" select="0"/>
19 <xsl:param name="refentry.separator" select="0"/>
20 <xsl:param name="chunk.fast" select="0"/>
22 <xsl:key name="genid" match="*" use="generate-id()"/>
24 <!-- ==================================================================== -->
26 <xsl:variable name="chunk.hierarchy">
27 <xsl:if test="$chunk.fast != 0">
29 <!-- Do we need to fix namespace? -->
30 <xsl:when test="$exsl.node.set.available != 0 and
31 namespace-uri(/*) != 'http://docbook.org/ns/docbook'">
32 <xsl:if test="$chunk.quietly = 0">
33 <xsl:message>Computing chunks...</xsl:message>
35 <xsl:apply-templates mode="find.chunks" select="exsl:node-set($with.namespace)"/>
37 <xsl:when test="$exsl.node.set.available != 0">
38 <xsl:if test="$chunk.quietly = 0">
39 <xsl:message>Computing chunks...</xsl:message>
41 <xsl:apply-templates select="/*" mode="find.chunks"/>
44 <xsl:if test="$chunk.quietly = 0">
46 <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
47 <xsl:text>Using "slow" chunking.</xsl:text>
55 <!-- ==================================================================== -->
57 <xsl:template name="process-chunk-element">
58 <xsl:param name="content">
63 <xsl:when test="$chunk.fast != 0 and $exsl.node.set.available != 0">
64 <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
65 <xsl:variable name="genid" select="generate-id()"/>
67 <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
69 <xsl:variable name="prevdiv"
70 select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
71 <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
73 <xsl:variable name="nextdiv"
74 select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
75 <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
78 <xsl:when test="$onechunk != 0 and parent::*">
79 <xsl:copy-of select="$content"/>
82 <xsl:call-template name="process-chunk">
83 <xsl:with-param name="prev" select="$prev"/>
84 <xsl:with-param name="next" select="$next"/>
85 <xsl:with-param name="content" select="$content"/>
92 <xsl:when test="$onechunk != 0 and not(parent::*)">
93 <xsl:call-template name="chunk-all-sections">
94 <xsl:with-param name="content" select="$content"/>
97 <xsl:when test="$onechunk != 0">
98 <xsl:copy-of select="$content"/>
100 <xsl:when test="$chunk.first.sections = 0">
101 <xsl:call-template name="chunk-first-section-with-parent">
102 <xsl:with-param name="content" select="$content"/>
106 <xsl:call-template name="chunk-all-sections">
107 <xsl:with-param name="content" select="$content"/>
115 <xsl:template name="process-chunk">
116 <xsl:param name="prev" select="."/>
117 <xsl:param name="next" select="."/>
118 <xsl:param name="content">
122 <xsl:variable name="ischunk">
123 <xsl:call-template name="chunk"/>
126 <xsl:variable name="chunkfn">
127 <xsl:if test="$ischunk='1'">
128 <xsl:apply-templates mode="chunk-filename" select="."/>
132 <xsl:if test="$ischunk='0'">
134 <xsl:text>Error </xsl:text>
135 <xsl:value-of select="name(.)"/>
136 <xsl:text> is not a chunk!</xsl:text>
140 <xsl:variable name="filename">
141 <xsl:call-template name="make-relative-filename">
142 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
143 <xsl:with-param name="base.name" select="$chunkfn"/>
147 <xsl:call-template name="write.chunk">
148 <xsl:with-param name="filename" select="$filename"/>
149 <xsl:with-param name="content">
150 <xsl:call-template name="chunk-element-content">
151 <xsl:with-param name="prev" select="$prev"/>
152 <xsl:with-param name="next" select="$next"/>
153 <xsl:with-param name="content" select="$content"/>
156 <xsl:with-param name="quiet" select="$chunk.quietly"/>
160 <xsl:template name="chunk-first-section-with-parent">
161 <xsl:param name="content">
165 <!-- These xpath expressions are really hairy. The trick is to pick sections -->
166 <!-- that are not first children and are not the children of first children -->
168 <!-- Break these variables into pieces to work around
169 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
171 <xsl:variable name="prev-v1"
172 select="(ancestor::d:sect1[$chunk.section.depth > 0
173 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
174 and preceding-sibling::d:sect1][1]
176 |ancestor::d:sect2[$chunk.section.depth > 1
177 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
178 and preceding-sibling::d:sect2
179 and parent::d:sect1[preceding-sibling::d:sect1]][1]
181 |ancestor::d:sect3[$chunk.section.depth > 2
182 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
183 and preceding-sibling::d:sect3
184 and parent::d:sect2[preceding-sibling::d:sect2]
185 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
187 |ancestor::d:sect4[$chunk.section.depth > 3
188 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
189 and preceding-sibling::d:sect4
190 and parent::d:sect3[preceding-sibling::d:sect3]
191 and ancestor::d:sect2[preceding-sibling::d:sect2]
192 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
194 |ancestor::d:sect5[$chunk.section.depth > 4
195 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
196 and preceding-sibling::d:sect5
197 and parent::d:sect4[preceding-sibling::d:sect4]
198 and ancestor::d:sect3[preceding-sibling::d:sect3]
199 and ancestor::d:sect2[preceding-sibling::d:sect2]
200 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
202 |ancestor::d:section[$chunk.section.depth > count(ancestor::d:section)
203 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
204 and not(ancestor::d:section[not(preceding-sibling::d:section)])][1])[last()]"/>
206 <xsl:variable name="prev-v2"
207 select="(preceding::d:sect1[$chunk.section.depth > 0
208 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
209 and preceding-sibling::d:sect1][1]
211 |preceding::d:sect2[$chunk.section.depth > 1
212 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
213 and preceding-sibling::d:sect2
214 and parent::d:sect1[preceding-sibling::d:sect1]][1]
216 |preceding::d:sect3[$chunk.section.depth > 2
217 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
218 and preceding-sibling::d:sect3
219 and parent::d:sect2[preceding-sibling::d:sect2]
220 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
222 |preceding::d:sect4[$chunk.section.depth > 3
223 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
224 and preceding-sibling::d:sect4
225 and parent::d:sect3[preceding-sibling::d:sect3]
226 and ancestor::d:sect2[preceding-sibling::d:sect2]
227 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
229 |preceding::d:sect5[$chunk.section.depth > 4
230 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
231 and preceding-sibling::d:sect5
232 and parent::d:sect4[preceding-sibling::d:sect4]
233 and ancestor::d:sect3[preceding-sibling::d:sect3]
234 and ancestor::d:sect2[preceding-sibling::d:sect2]
235 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
237 |preceding::d:section[$chunk.section.depth > count(ancestor::d:section)
238 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
239 and preceding-sibling::d:section
240 and not(ancestor::d:section[not(preceding-sibling::d:section)])][1])[last()]"/>
242 <xsl:variable name="prev"
243 select="(preceding::d:book[1]
244 |preceding::d:preface[1]
245 |preceding::d:chapter[1]
246 |preceding::d:appendix[1]
247 |preceding::d:part[1]
248 |preceding::d:reference[1]
249 |preceding::d:refentry[1]
250 |preceding::d:colophon[1]
251 |preceding::d:article[1]
252 |preceding::d:topic[1]
253 |preceding::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1]
254 |preceding::d:glossary[parent::d:article or parent::d:book or parent::d:part][1]
255 |preceding::d:index[$generate.index != 0]
256 [parent::d:article or parent::d:book or parent::d:part][1]
257 |preceding::d:setindex[$generate.index != 0][1]
260 |ancestor::d:preface[1]
261 |ancestor::d:chapter[1]
262 |ancestor::d:appendix[1]
264 |ancestor::d:reference[1]
265 |ancestor::d:article[1]
266 |ancestor::d:topic[1]
268 |$prev-v2)[last()]"/>
270 <xsl:variable name="next-v1"
271 select="(following::d:sect1[$chunk.section.depth > 0
272 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
273 and preceding-sibling::d:sect1][1]
275 |following::d:sect2[$chunk.section.depth > 1
276 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
277 and preceding-sibling::d:sect2
278 and parent::d:sect1[preceding-sibling::d:sect1]][1]
280 |following::d:sect3[$chunk.section.depth > 2
281 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
282 and preceding-sibling::d:sect3
283 and parent::d:sect2[preceding-sibling::d:sect2]
284 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
286 |following::d:sect4[$chunk.section.depth > 3
287 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
288 and preceding-sibling::d:sect4
289 and parent::d:sect3[preceding-sibling::d:sect3]
290 and ancestor::d:sect2[preceding-sibling::d:sect2]
291 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
293 |following::d:sect5[$chunk.section.depth > 4
294 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
295 and preceding-sibling::d:sect5
296 and parent::d:sect4[preceding-sibling::d:sect4]
297 and ancestor::d:sect3[preceding-sibling::d:sect3]
298 and ancestor::d:sect2[preceding-sibling::d:sect2]
299 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
301 |following::d:section[$chunk.section.depth > count(ancestor::d:section)
302 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
303 and preceding-sibling::d:section
304 and not(ancestor::d:section[not(preceding-sibling::d:section)])][1])[1]"/>
306 <xsl:variable name="next-v2"
307 select="(descendant::d:sect1[$chunk.section.depth > 0
308 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
309 and preceding-sibling::d:sect1][1]
311 |descendant::d:sect2[$chunk.section.depth > 1
312 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
313 and preceding-sibling::d:sect2
314 and parent::d:sect1[preceding-sibling::d:sect1]][1]
316 |descendant::d:sect3[$chunk.section.depth > 2
317 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
318 and preceding-sibling::d:sect3
319 and parent::d:sect2[preceding-sibling::d:sect2]
320 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
322 |descendant::d:sect4[$chunk.section.depth > 3
323 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
324 and preceding-sibling::d:sect4
325 and parent::d:sect3[preceding-sibling::d:sect3]
326 and ancestor::d:sect2[preceding-sibling::d:sect2]
327 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
329 |descendant::d:sect5[$chunk.section.depth > 4
330 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
331 and preceding-sibling::d:sect5
332 and parent::d:sect4[preceding-sibling::d:sect4]
333 and ancestor::d:sect3[preceding-sibling::d:sect3]
334 and ancestor::d:sect2[preceding-sibling::d:sect2]
335 and ancestor::d:sect1[preceding-sibling::d:sect1]][1]
337 |descendant::d:section[$chunk.section.depth > count(ancestor::d:section)
338 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])
339 and preceding-sibling::d:section
340 and not(ancestor::d:section[not(preceding-sibling::d:section)])])[1]"/>
342 <xsl:variable name="next"
343 select="(following::d:book[1]
344 |following::d:preface[1]
345 |following::d:chapter[1]
346 |following::d:appendix[1]
347 |following::d:part[1]
348 |following::d:reference[1]
349 |following::d:refentry[1]
350 |following::d:colophon[1]
351 |following::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1]
352 |following::d:glossary[parent::d:article or parent::d:book or parent::d:part][1]
353 |following::d:index[$generate.index != 0]
354 [parent::d:article or parent::d:book or parent::d:part][1]
355 |following::d:article[1]
356 |following::d:topic[1]
357 |following::d:setindex[$generate.index != 0][1]
358 |descendant::d:book[1]
359 |descendant::d:preface[1]
360 |descendant::d:chapter[1]
361 |descendant::d:appendix[1]
362 |descendant::d:article[1]
363 |descendant::d:topic[1]
364 |descendant::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1]
365 |descendant::d:glossary[parent::d:article or parent::d:book or parent::d:part][1]
366 |descendant::d:index[$generate.index != 0]
367 [parent::d:article or parent::d:book or parent::d:part][1]
368 |descendant::d:colophon[1]
369 |descendant::d:setindex[$generate.index != 0][1]
370 |descendant::d:part[1]
371 |descendant::d:reference[1]
372 |descendant::d:refentry[1]
376 <xsl:call-template name="process-chunk">
377 <xsl:with-param name="prev" select="$prev"/>
378 <xsl:with-param name="next" select="$next"/>
379 <xsl:with-param name="content" select="$content"/>
383 <xsl:template name="chunk-all-sections">
384 <xsl:param name="content">
388 <xsl:variable name="prev-v1"
389 select="(preceding::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
390 |preceding::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
391 |preceding::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
392 |preceding::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
393 |preceding::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
394 |preceding::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
396 <xsl:variable name="prev-v2"
397 select="(ancestor::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
398 |ancestor::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
399 |ancestor::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
400 |ancestor::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
401 |ancestor::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
402 |ancestor::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
404 <xsl:variable name="prev"
405 select="(preceding::d:book[1]
406 |preceding::d:preface[1]
407 |preceding::d:chapter[1]
408 |preceding::d:appendix[1]
409 |preceding::d:part[1]
410 |preceding::d:reference[1]
411 |preceding::d:refentry[1]
412 |preceding::d:colophon[1]
413 |preceding::d:article[1]
414 |preceding::d:topic[1]
415 |preceding::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1]
416 |preceding::d:glossary[parent::d:article or parent::d:book or parent::d:part][1]
417 |preceding::d:index[$generate.index != 0]
418 [parent::d:article or parent::d:book or parent::d:part][1]
419 |preceding::d:setindex[$generate.index != 0][1]
422 |ancestor::d:preface[1]
423 |ancestor::d:chapter[1]
424 |ancestor::d:appendix[1]
426 |ancestor::d:reference[1]
427 |ancestor::d:article[1]
428 |ancestor::d:topic[1]
430 |$prev-v2)[last()]"/>
432 <xsl:variable name="next-v1"
433 select="(following::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
434 |following::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
435 |following::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
436 |following::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
437 |following::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
438 |following::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
440 <xsl:variable name="next-v2"
441 select="(descendant::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
442 |descendant::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
443 |descendant::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
444 |descendant::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
445 |descendant::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1]
446 |descendant::d:section[$chunk.section.depth
447 > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
449 <xsl:variable name="next"
450 select="(following::d:book[1]
451 |following::d:preface[1]
452 |following::d:chapter[1]
453 |following::d:appendix[1]
454 |following::d:part[1]
455 |following::d:reference[1]
456 |following::d:refentry[1]
457 |following::d:colophon[1]
458 |following::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1]
459 |following::d:glossary[parent::d:article or parent::d:book or parent::d:part][1]
460 |following::d:index[$generate.index != 0]
461 [parent::d:article or parent::d:book][1]
462 |following::d:article[1]
463 |following::d:topic[1]
464 |following::d:setindex[$generate.index != 0][1]
465 |descendant::d:book[1]
466 |descendant::d:preface[1]
467 |descendant::d:chapter[1]
468 |descendant::d:appendix[1]
469 |descendant::d:article[1]
470 |descendant::d:topic[1]
471 |descendant::d:bibliography[parent::d:article or parent::d:book][1]
472 |descendant::d:glossary[parent::d:article or parent::d:book or parent::d:part][1]
473 |descendant::d:index[$generate.index != 0]
474 [parent::d:article or parent::d:book][1]
475 |descendant::d:colophon[1]
476 |descendant::d:setindex[$generate.index != 0][1]
477 |descendant::d:part[1]
478 |descendant::d:reference[1]
479 |descendant::d:refentry[1]
483 <xsl:call-template name="process-chunk">
484 <xsl:with-param name="prev" select="$prev"/>
485 <xsl:with-param name="next" select="$next"/>
486 <xsl:with-param name="content" select="$content"/>
490 <!-- ==================================================================== -->
492 <!-- ==================================================================== -->
494 <xsl:template name="make.lots">
495 <xsl:param name="toc.params" select="''"/>
496 <xsl:param name="toc"/>
498 <xsl:variable name="lots">
499 <xsl:if test="contains($toc.params, 'toc')">
500 <xsl:copy-of select="$toc"/>
503 <xsl:if test="contains($toc.params, 'figure')">
505 <xsl:when test="$chunk.separate.lots != '0'">
506 <xsl:call-template name="make.lot.chunk">
507 <xsl:with-param name="type" select="'figure'"/>
508 <xsl:with-param name="lot">
509 <xsl:call-template name="list.of.titles">
510 <xsl:with-param name="titles" select="'figure'"/>
511 <xsl:with-param name="nodes" select=".//d:figure"/>
517 <xsl:call-template name="list.of.titles">
518 <xsl:with-param name="titles" select="'figure'"/>
519 <xsl:with-param name="nodes" select=".//d:figure"/>
525 <xsl:if test="contains($toc.params, 'table')">
527 <xsl:when test="$chunk.separate.lots != '0'">
528 <xsl:call-template name="make.lot.chunk">
529 <xsl:with-param name="type" select="'table'"/>
530 <xsl:with-param name="lot">
531 <xsl:call-template name="list.of.titles">
532 <xsl:with-param name="titles" select="'table'"/>
533 <xsl:with-param name="nodes" select=".//d:table[not(@tocentry = 0)]"/>
539 <xsl:call-template name="list.of.titles">
540 <xsl:with-param name="titles" select="'table'"/>
541 <xsl:with-param name="nodes" select=".//d:table[not(@tocentry = 0)]"/>
547 <xsl:if test="contains($toc.params, 'example')">
549 <xsl:when test="$chunk.separate.lots != '0'">
550 <xsl:call-template name="make.lot.chunk">
551 <xsl:with-param name="type" select="'example'"/>
552 <xsl:with-param name="lot">
553 <xsl:call-template name="list.of.titles">
554 <xsl:with-param name="titles" select="'example'"/>
555 <xsl:with-param name="nodes" select=".//d:example"/>
561 <xsl:call-template name="list.of.titles">
562 <xsl:with-param name="titles" select="'example'"/>
563 <xsl:with-param name="nodes" select=".//d:example"/>
569 <xsl:if test="contains($toc.params, 'equation')">
571 <xsl:when test="$chunk.separate.lots != '0'">
572 <xsl:call-template name="make.lot.chunk">
573 <xsl:with-param name="type" select="'equation'"/>
574 <xsl:with-param name="lot">
575 <xsl:call-template name="list.of.titles">
576 <xsl:with-param name="titles" select="'equation'"/>
577 <xsl:with-param name="nodes" select=".//d:equation[d:title or d:info/d:title]"/>
583 <xsl:call-template name="list.of.titles">
584 <xsl:with-param name="titles" select="'equation'"/>
585 <xsl:with-param name="nodes" select=".//d:equation[d:title or d:info/d:title]"/>
591 <xsl:if test="contains($toc.params, 'procedure')">
593 <xsl:when test="$chunk.separate.lots != '0'">
594 <xsl:call-template name="make.lot.chunk">
595 <xsl:with-param name="type" select="'procedure'"/>
596 <xsl:with-param name="lot">
597 <xsl:call-template name="list.of.titles">
598 <xsl:with-param name="titles" select="'procedure'"/>
599 <xsl:with-param name="nodes" select=".//d:procedure[d:title]"/>
605 <xsl:call-template name="list.of.titles">
606 <xsl:with-param name="titles" select="'procedure'"/>
607 <xsl:with-param name="nodes" select=".//d:procedure[d:title]"/>
614 <xsl:if test="string($lots) != ''">
616 <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
617 <xsl:call-template name="write.chunk">
618 <xsl:with-param name="filename">
619 <xsl:call-template name="make-relative-filename">
620 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
621 <xsl:with-param name="base.name">
622 <xsl:call-template name="dbhtml-dir"/>
623 <xsl:value-of select="$chunked.filename.prefix"/>
624 <xsl:apply-templates select="." mode="recursive-chunk-filename">
625 <xsl:with-param name="recursive" select="true()"/>
626 </xsl:apply-templates>
627 <xsl:text>-toc</xsl:text>
628 <xsl:value-of select="$html.ext"/>
632 <xsl:with-param name="content">
633 <xsl:call-template name="chunk-element-content">
634 <xsl:with-param name="prev" select="/d:foo"/>
635 <xsl:with-param name="next" select="/d:foo"/>
636 <xsl:with-param name="nav.context" select="'toc'"/>
637 <xsl:with-param name="content">
638 <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
640 <xsl:apply-templates select="." mode="object.title.markup"/>
643 <xsl:copy-of select="$lots"/>
647 <xsl:with-param name="quiet" select="$chunk.quietly"/>
651 <xsl:copy-of select="$lots"/>
657 <xsl:template name="make.lot.chunk">
658 <xsl:param name="type" select="''"/>
659 <xsl:param name="lot"/>
661 <xsl:if test="string($lot) != ''">
662 <xsl:variable name="filename">
663 <xsl:call-template name="make-relative-filename">
664 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
665 <xsl:with-param name="base.name">
666 <xsl:call-template name="dbhtml-dir"/>
667 <xsl:value-of select="$type"/>
668 <xsl:text>-toc</xsl:text>
669 <xsl:value-of select="$html.ext"/>
674 <xsl:variable name="href">
675 <xsl:call-template name="make-relative-filename">
676 <xsl:with-param name="base.dir" select="''"/>
677 <xsl:with-param name="base.name">
678 <xsl:call-template name="dbhtml-dir"/>
679 <xsl:value-of select="$type"/>
680 <xsl:text>-toc</xsl:text>
681 <xsl:value-of select="$html.ext"/>
686 <xsl:call-template name="write.chunk">
687 <xsl:with-param name="filename" select="$filename"/>
688 <xsl:with-param name="content">
689 <xsl:call-template name="chunk-element-content">
690 <xsl:with-param name="prev" select="/d:foo"/>
691 <xsl:with-param name="next" select="/d:foo"/>
692 <xsl:with-param name="nav.context" select="'toc'"/>
693 <xsl:with-param name="content">
694 <xsl:copy-of select="$lot"/>
698 <xsl:with-param name="quiet" select="$chunk.quietly"/>
700 <!-- And output a link to this file -->
702 <xsl:attribute name="class">
703 <xsl:text>ListofTitles</xsl:text>
706 <xsl:call-template name="gentext">
707 <xsl:with-param name="key">
709 <xsl:when test="$type='table'">ListofTables</xsl:when>
710 <xsl:when test="$type='figure'">ListofFigures</xsl:when>
711 <xsl:when test="$type='equation'">ListofEquations</xsl:when>
712 <xsl:when test="$type='example'">ListofExamples</xsl:when>
713 <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
714 <xsl:otherwise>ListofUnknown</xsl:otherwise>
723 <!-- ==================================================================== -->
725 <xsl:template name="in.other.chunk">
726 <xsl:param name="chunk" select="."/>
727 <xsl:param name="node" select="."/>
729 <xsl:variable name="is.chunk">
730 <xsl:call-template name="chunk">
731 <xsl:with-param name="node" select="$node"/>
737 <xsl:text>in.other.chunk: </xsl:text>
738 <xsl:value-of select="name($chunk)"/>
739 <xsl:text> </xsl:text>
740 <xsl:value-of select="name($node)"/>
741 <xsl:text> </xsl:text>
742 <xsl:value-of select="$chunk = $node"/>
743 <xsl:text> </xsl:text>
744 <xsl:value-of select="$is.chunk"/>
749 <xsl:when test="$chunk = $node">0</xsl:when>
750 <xsl:when test="$is.chunk = 1">1</xsl:when>
751 <xsl:when test="count($node) = 0">0</xsl:when>
753 <xsl:call-template name="in.other.chunk">
754 <xsl:with-param name="chunk" select="$chunk"/>
755 <xsl:with-param name="node" select="$node/parent::*"/>
761 <xsl:template name="count.footnotes.in.this.chunk">
762 <xsl:param name="node" select="."/>
763 <xsl:param name="footnotes" select="$node//d:footnote"/>
764 <xsl:param name="count" select="0"/>
768 <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
769 <xsl:value-of select="name($node)"/>
773 <xsl:variable name="in.other.chunk">
774 <xsl:call-template name="in.other.chunk">
775 <xsl:with-param name="chunk" select="$node"/>
776 <xsl:with-param name="node" select="$footnotes[1]"/>
781 <xsl:when test="count($footnotes) = 0">
782 <xsl:value-of select="$count"/>
786 <xsl:when test="$in.other.chunk != 0">
787 <xsl:call-template name="count.footnotes.in.this.chunk">
788 <xsl:with-param name="node" select="$node"/>
789 <xsl:with-param name="footnotes"
790 select="$footnotes[position() > 1]"/>
791 <xsl:with-param name="count" select="$count"/>
794 <xsl:when test="$footnotes[1]/ancestor::d:table
795 |$footnotes[1]/ancestor::d:informaltable">
796 <xsl:call-template name="count.footnotes.in.this.chunk">
797 <xsl:with-param name="node" select="$node"/>
798 <xsl:with-param name="footnotes"
799 select="$footnotes[position() > 1]"/>
800 <xsl:with-param name="count" select="$count"/>
804 <xsl:call-template name="count.footnotes.in.this.chunk">
805 <xsl:with-param name="node" select="$node"/>
806 <xsl:with-param name="footnotes"
807 select="$footnotes[position() > 1]"/>
808 <xsl:with-param name="count" select="$count + 1"/>
816 <xsl:template name="process.footnotes.in.this.chunk">
817 <xsl:param name="node" select="."/>
818 <xsl:param name="footnotes" select="$node//d:footnote"/>
821 <xsl:message>process.footnotes.in.this.chunk</xsl:message>
824 <xsl:variable name="in.other.chunk">
825 <xsl:call-template name="in.other.chunk">
826 <xsl:with-param name="chunk" select="$node"/>
827 <xsl:with-param name="node" select="$footnotes[1]"/>
832 <xsl:when test="count($footnotes) = 0">
837 <xsl:when test="$in.other.chunk != 0">
838 <xsl:call-template name="process.footnotes.in.this.chunk">
839 <xsl:with-param name="node" select="$node"/>
840 <xsl:with-param name="footnotes"
841 select="$footnotes[position() > 1]"/>
844 <xsl:when test="$footnotes[1]/ancestor::d:table
845 |$footnotes[1]/ancestor::d:informaltable">
846 <xsl:call-template name="process.footnotes.in.this.chunk">
847 <xsl:with-param name="node" select="$node"/>
848 <xsl:with-param name="footnotes"
849 select="$footnotes[position() > 1]"/>
853 <xsl:apply-templates select="$footnotes[1]"
854 mode="process.footnote.mode"/>
855 <xsl:call-template name="process.footnotes.in.this.chunk">
856 <xsl:with-param name="node" select="$node"/>
857 <xsl:with-param name="footnotes"
858 select="$footnotes[position() > 1]"/>
866 <xsl:template name="process.footnotes">
867 <xsl:variable name="footnotes" select=".//d:footnote"/>
868 <xsl:variable name="fcount">
869 <xsl:call-template name="count.footnotes.in.this.chunk">
870 <xsl:with-param name="node" select="."/>
871 <xsl:with-param name="footnotes" select="$footnotes"/>
877 <xsl:value-of select="name(.)"/>
878 <xsl:text> fcount: </xsl:text>
879 <xsl:value-of select="$fcount"/>
883 <!-- Only bother to do this if there's at least one non-table footnote -->
884 <xsl:if test="$fcount > 0">
885 <div class="footnotes">
886 <xsl:call-template name="footnotes.attributes"/>
890 <xsl:when test="$make.clean.html != 0">
891 <xsl:attribute name="class">footnote-hr</xsl:attribute>
893 <xsl:when test="$css.decoration != 0">
894 <xsl:attribute name="style">
895 <xsl:value-of select="concat('width:100; text-align:',
896 $direction.align.start,
898 'margin-', $direction.align.start, ': 0')"/>
902 <xsl:attribute name="width">100</xsl:attribute>
903 <xsl:attribute name="align"><xsl:value-of
904 select="$direction.align.start"/></xsl:attribute>
908 <xsl:call-template name="process.footnotes.in.this.chunk">
909 <xsl:with-param name="node" select="."/>
910 <xsl:with-param name="footnotes" select="$footnotes"/>
915 <!-- FIXME: When chunking, only the annotations actually used
916 in this chunk should be referenced. I don't think it
917 does any harm to reference them all, but it adds
918 unnecessary bloat to each chunk. -->
919 <xsl:if test="$annotation.support != 0 and //d:annotation">
920 <div class="annotation-list">
921 <div class="annotation-nocss">
922 <p>The following annotations are from this essay. You are seeing
923 them here because your browser doesn’t support the user-interface
924 techniques used to make them appear as ‘popups’ on modern browsers.</p>
927 <xsl:apply-templates select="//d:annotation"
928 mode="annotation-popup"/>
933 <xsl:template name="process.chunk.footnotes">
934 <xsl:variable name="is.chunk">
935 <xsl:call-template name="chunk"/>
937 <xsl:if test="$is.chunk = 1">
938 <xsl:call-template name="process.footnotes"/>
942 <!-- ====================================================================== -->
944 <xsl:template name="chunk">
945 <xsl:param name="node" select="."/>
946 <!-- returns 1 if $node is a chunk -->
948 <!-- ==================================================================== -->
954 bibliography in article or part or book
958 glossary in article or part or book
959 index in article or part or book
964 sect{1,2,3,4,5} if position()>1 && depth < chunk.section.depth
965 section if position()>1 && depth < chunk.section.depth
970 <!-- ==================================================================== -->
974 <xsl:text>chunk: </xsl:text>
975 <xsl:value-of select="name($node)"/>
976 <xsl:text>(</xsl:text>
977 <xsl:value-of select="$node/@id"/>
978 <xsl:text>)</xsl:text>
979 <xsl:text> csd: </xsl:text>
980 <xsl:value-of select="$chunk.section.depth"/>
981 <xsl:text> cfs: </xsl:text>
982 <xsl:value-of select="$chunk.first.sections"/>
983 <xsl:text> ps: </xsl:text>
984 <xsl:value-of select="count($node/parent::d:section)"/>
985 <xsl:text> prs: </xsl:text>
986 <xsl:value-of select="count($node/preceding-sibling::d:section)"/>
991 <xsl:when test="$node/parent::*/processing-instruction('dbhtml')[normalize-space(.) = 'stop-chunking']">0</xsl:when>
992 <xsl:when test="not($node/parent::*)">1</xsl:when>
994 <xsl:when test="local-name($node) = 'sect1'
995 and $chunk.section.depth >= 1
996 and ($chunk.first.sections != 0
997 or count($node/preceding-sibling::d:sect1) > 0)">
998 <xsl:text>1</xsl:text>
1000 <xsl:when test="local-name($node) = 'sect2'
1001 and $chunk.section.depth >= 2
1002 and ($chunk.first.sections != 0
1003 or count($node/preceding-sibling::d:sect2) > 0)">
1004 <xsl:call-template name="chunk">
1005 <xsl:with-param name="node" select="$node/parent::*"/>
1006 </xsl:call-template>
1008 <xsl:when test="local-name($node) = 'sect3'
1009 and $chunk.section.depth >= 3
1010 and ($chunk.first.sections != 0
1011 or count($node/preceding-sibling::d:sect3) > 0)">
1012 <xsl:call-template name="chunk">
1013 <xsl:with-param name="node" select="$node/parent::*"/>
1014 </xsl:call-template>
1016 <xsl:when test="local-name($node) = 'sect4'
1017 and $chunk.section.depth >= 4
1018 and ($chunk.first.sections != 0
1019 or count($node/preceding-sibling::d:sect4) > 0)">
1020 <xsl:call-template name="chunk">
1021 <xsl:with-param name="node" select="$node/parent::*"/>
1022 </xsl:call-template>
1024 <xsl:when test="local-name($node) = 'sect5'
1025 and $chunk.section.depth >= 5
1026 and ($chunk.first.sections != 0
1027 or count($node/preceding-sibling::d:sect5) > 0)">
1028 <xsl:call-template name="chunk">
1029 <xsl:with-param name="node" select="$node/parent::*"/>
1030 </xsl:call-template>
1032 <xsl:when test="local-name($node) = 'section'
1033 and $chunk.section.depth >= count($node/ancestor::d:section)+1
1034 and ($chunk.first.sections != 0
1035 or count($node/preceding-sibling::d:section) > 0)">
1036 <xsl:call-template name="chunk">
1037 <xsl:with-param name="node" select="$node/parent::*"/>
1038 </xsl:call-template>
1041 <xsl:when test="local-name($node)='preface'">1</xsl:when>
1042 <xsl:when test="local-name($node)='chapter'">1</xsl:when>
1043 <xsl:when test="local-name($node)='appendix'">1</xsl:when>
1044 <xsl:when test="local-name($node)='article'">1</xsl:when>
1045 <xsl:when test="local-name($node)='topic'">1</xsl:when>
1046 <xsl:when test="local-name($node)='part'">1</xsl:when>
1047 <xsl:when test="local-name($node)='reference'">1</xsl:when>
1048 <xsl:when test="local-name($node)='refentry'">1</xsl:when>
1049 <xsl:when test="local-name($node)='index' and ($generate.index != 0 or count($node/*) > 0)
1050 and (local-name($node/parent::*) = 'article'
1051 or local-name($node/parent::*) = 'book'
1052 or local-name($node/parent::*) = 'part'
1054 <xsl:when test="local-name($node)='bibliography'
1055 and (local-name($node/parent::*) = 'article'
1056 or local-name($node/parent::*) = 'book'
1057 or local-name($node/parent::*) = 'part'
1059 <xsl:when test="local-name($node)='glossary'
1060 and (local-name($node/parent::*) = 'article'
1061 or local-name($node/parent::*) = 'book'
1062 or local-name($node/parent::*) = 'part'
1064 <xsl:when test="local-name($node)='colophon'">1</xsl:when>
1065 <xsl:when test="local-name($node)='book'">1</xsl:when>
1066 <xsl:when test="local-name($node)='set'">1</xsl:when>
1067 <xsl:when test="local-name($node)='setindex'">1</xsl:when>
1068 <xsl:when test="local-name($node)='legalnotice'
1069 and $generate.legalnotice.link != 0">1</xsl:when>
1070 <xsl:otherwise>0</xsl:otherwise>
1074 <!-- ==================================================================== -->
1075 <xsl:template name="href.target.uri">
1076 <xsl:param name="object" select="."/>
1077 <xsl:variable name="ischunk">
1078 <xsl:call-template name="chunk">
1079 <xsl:with-param name="node" select="$object"/>
1080 </xsl:call-template>
1083 <xsl:apply-templates mode="chunk-filename" select="$object"/>
1085 <xsl:if test="$ischunk='0'">
1086 <xsl:text>#</xsl:text>
1087 <xsl:call-template name="object.id">
1088 <xsl:with-param name="object" select="$object"/>
1089 </xsl:call-template>
1093 <xsl:template name="href.target">
1094 <xsl:param name="context" select="."/>
1095 <xsl:param name="object" select="."/>
1096 <xsl:param name="toc-context" select="."/>
1097 <!-- * If $toc-context contains some node other than the current node, -->
1098 <!-- * it means we're processing a link in a TOC. In that case, to -->
1099 <!-- * ensure the link will work correctly, we need to take a look at -->
1100 <!-- * where the file containing the TOC will get written, and where -->
1101 <!-- * the file that's being linked to will get written. -->
1102 <xsl:variable name="toc-output-dir">
1103 <xsl:if test="not($toc-context = .)">
1104 <!-- * Get the $toc-context node and all its ancestors, look down -->
1105 <!-- * through them to find the last/closest node to the -->
1106 <!-- * toc-context node that has a "dbhtml dir" PI, and get the -->
1107 <!-- * directory name from that. That's the name of the directory -->
1108 <!-- * to which the current toc output file will get written. -->
1109 <xsl:call-template name="dbhtml-dir">
1110 <xsl:with-param name="context"
1111 select="$toc-context/ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
1112 </xsl:call-template>
1115 <xsl:variable name="linked-file-output-dir">
1116 <xsl:if test="not($toc-context = .)">
1117 <!-- * Get the current node and all its ancestors, look down -->
1118 <!-- * through them to find the last/closest node to the current -->
1119 <!-- * node that has a "dbhtml dir" PI, and get the directory name -->
1120 <!-- * from that. That's the name of the directory to which the -->
1121 <!-- * file that's being linked to will get written. -->
1122 <xsl:call-template name="dbhtml-dir">
1123 <xsl:with-param name="context"
1124 select="ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
1125 </xsl:call-template>
1128 <xsl:variable name="href.to.uri">
1129 <xsl:call-template name="href.target.uri">
1130 <xsl:with-param name="object" select="$object"/>
1131 </xsl:call-template>
1133 <xsl:variable name="href.from.uri">
1135 <xsl:when test="not($toc-context = .)">
1136 <xsl:call-template name="href.target.uri">
1137 <xsl:with-param name="object" select="$toc-context"/>
1138 </xsl:call-template>
1141 <xsl:call-template name="href.target.uri">
1142 <xsl:with-param name="object" select="$context"/>
1143 </xsl:call-template>
1147 <!-- * <xsl:message>toc-context: <xsl:value-of select="local-name($toc-context)"/></xsl:message> -->
1148 <!-- * <xsl:message>node: <xsl:value-of select="local-name(.)"/></xsl:message> -->
1149 <!-- * <xsl:message>context: <xsl:value-of select="local-name($context)"/></xsl:message> -->
1150 <!-- * <xsl:message>object: <xsl:value-of select="local-name($object)"/></xsl:message> -->
1151 <!-- * <xsl:message>toc-output-dir: <xsl:value-of select="$toc-output-dir"/></xsl:message> -->
1152 <!-- * <xsl:message>linked-file-output-dir: <xsl:value-of select="$linked-file-output-dir"/></xsl:message> -->
1153 <!-- * <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> -->
1154 <!-- * <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> -->
1155 <xsl:variable name="href.to">
1157 <!-- * 2007-07-19, MikeSmith: Added the following conditional to -->
1158 <!-- * deal with a problem case for links in TOCs. It checks to see -->
1159 <!-- * if the output dir that a TOC will get written to is -->
1160 <!-- * different from the output dir of the file being linked to. -->
1161 <!-- * If it is different, we do not call trim.common.uri.paths. -->
1163 <!-- * Reason why I added that conditional is: I ran into a bug for -->
1164 <!-- * this case: -->
1166 <!-- * 1. we are chunking into separate dirs -->
1168 <!-- * 2. output for the TOC is written to current dir, but the file -->
1169 <!-- * being linked to is written to some subdir "foo". -->
1171 <!-- * For that case, links to that file in that TOC did not show -->
1172 <!-- * the correct path - they omitted the "foo". -->
1174 <!-- * The cause of that problem was that the trim.common.uri.paths -->
1175 <!-- * template[1] was being called under all conditions. But it's -->
1176 <!-- * apparent that we don't want to call trim.common.uri.paths in -->
1177 <!-- * the case where a linked file is being written to a different -->
1178 <!-- * directory than the TOC that contains the link, because doing -->
1179 <!-- * so will cause a necessary (not redundant) directory-name -->
1180 <!-- * part of the link to get inadvertently trimmed, resulting in -->
1181 <!-- * a broken link to that file. Thus, added the conditional. -->
1183 <!-- * [1] The purpose of the trim.common.uri.paths template is to -->
1184 <!-- * prevent cases where, if we didn't call it, we end up with -->
1185 <!-- * unnecessary, redundant directory names getting output; for -->
1186 <!-- * example, "foo/foo/refname.html". -->
1187 <xsl:when test="not($toc-output-dir = $linked-file-output-dir)">
1188 <xsl:value-of select="$href.to.uri"/>
1191 <xsl:call-template name="trim.common.uri.paths">
1192 <xsl:with-param name="uriA" select="$href.to.uri"/>
1193 <xsl:with-param name="uriB" select="$href.from.uri"/>
1194 <xsl:with-param name="return" select="'A'"/>
1195 </xsl:call-template>
1199 <xsl:variable name="href.from">
1200 <xsl:call-template name="trim.common.uri.paths">
1201 <xsl:with-param name="uriA" select="$href.to.uri"/>
1202 <xsl:with-param name="uriB" select="$href.from.uri"/>
1203 <xsl:with-param name="return" select="'B'"/>
1204 </xsl:call-template>
1206 <xsl:variable name="depth">
1207 <xsl:call-template name="count.uri.path.depth">
1208 <xsl:with-param name="filename" select="$href.from"/>
1209 </xsl:call-template>
1211 <xsl:variable name="href">
1212 <xsl:call-template name="copy-string">
1213 <xsl:with-param name="string" select="'../'"/>
1214 <xsl:with-param name="count" select="$depth"/>
1215 </xsl:call-template>
1216 <xsl:value-of select="$href.to"/>
1220 <xsl:text>In </xsl:text>
1221 <xsl:value-of select="name(.)"/>
1222 <xsl:text> (</xsl:text>
1223 <xsl:value-of select="$href.from"/>
1224 <xsl:text>,</xsl:text>
1225 <xsl:value-of select="$depth"/>
1226 <xsl:text>) </xsl:text>
1227 <xsl:value-of select="name($object)"/>
1228 <xsl:text> href=</xsl:text>
1229 <xsl:value-of select="$href"/>
1232 <xsl:value-of select="$href"/>
1235 <!-- Returns the complete olink href value if found -->
1236 <!-- Must take into account any dbhtml dir of the chunk containing the olink -->
1237 <xsl:template name="make.olink.href">
1238 <xsl:param name="olink.key" select="''"/>
1239 <xsl:param name="target.database"/>
1241 <xsl:if test="$olink.key != ''">
1242 <xsl:variable name="target.href" >
1243 <xsl:for-each select="$target.database" >
1244 <xsl:value-of select="key('targetptr-key', $olink.key)[1]/@href" />
1248 <!-- an olink starting point may be in a subdirectory, so need
1249 the "from" reference point to compute a relative path -->
1251 <xsl:variable name="from.href">
1252 <xsl:call-template name="olink.from.uri">
1253 <xsl:with-param name="target.database" select="$target.database"/>
1254 <xsl:with-param name="object" select="."/>
1255 <xsl:with-param name="object.targetdoc" select="$current.docid"/>
1256 </xsl:call-template>
1259 <!-- If the from.href has directory path, then must "../" upward
1260 to document level -->
1261 <xsl:variable name="upward.from.path">
1262 <xsl:call-template name="upward.path">
1263 <xsl:with-param name="path" select="$from.href"/>
1264 </xsl:call-template>
1267 <xsl:variable name="targetdoc">
1268 <xsl:value-of select="substring-before($olink.key, '/')"/>
1271 <!-- Does the target database use a sitemap? -->
1272 <xsl:variable name="use.sitemap">
1274 <xsl:when test="$target.database//sitemap">1</xsl:when>
1275 <xsl:otherwise>0</xsl:otherwise>
1280 <!-- Get the baseuri for this targetptr -->
1281 <xsl:variable name="baseuri" >
1283 <!-- Does the database use a sitemap? -->
1284 <xsl:when test="$use.sitemap != 0" >
1286 <!-- Was current.docid parameter set? -->
1287 <xsl:when test="$current.docid != ''">
1288 <!-- Was it found in the database? -->
1289 <xsl:variable name="currentdoc.key" >
1290 <xsl:for-each select="$target.database" >
1291 <xsl:value-of select="key('targetdoc-key',
1292 $current.docid)[1]/@targetdoc" />
1296 <xsl:when test="$currentdoc.key != ''">
1297 <xsl:for-each select="$target.database" >
1298 <xsl:call-template name="targetpath" >
1299 <xsl:with-param name="dirnode"
1300 select="key('targetdoc-key', $current.docid)[1]/parent::dir"/>
1301 <xsl:with-param name="targetdoc" select="$targetdoc"/>
1302 </xsl:call-template>
1306 <xsl:call-template name="olink.error">
1307 <xsl:with-param name="message">
1308 <xsl:text>cannot compute relative </xsl:text>
1309 <xsl:text>sitemap path because $current.docid '</xsl:text>
1310 <xsl:value-of select="$current.docid"/>
1311 <xsl:text>' not found in target database.</xsl:text>
1313 </xsl:call-template>
1318 <xsl:call-template name="olink.error">
1319 <xsl:with-param name="message">
1320 <xsl:text>cannot compute relative </xsl:text>
1321 <xsl:text>sitemap path without $current.docid parameter</xsl:text>
1323 </xsl:call-template>
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="/d:foo"/>
1411 <xsl:param name="next" select="/d: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="//d:part
1482 |//d:appendix[not(parent::d:article)]|d:appendix
1483 |//d:glossary[not(parent::d:article)]|d:glossary
1484 |//d:index[not(parent::d:article)]|d: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="d:section|d:sect1|d:refsection|d: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="d:sect2|d:sect3|d:sect4|d:sect5|d:refsect2|d: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="//d: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="/d:foo"/>
1556 <xsl:param name="next" select="/d: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="/d:foo"/>
1638 <xsl:param name="next" select="/d: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="d: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="(//d: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="(//d: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>