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 7833 2008-03-04 19:09:35Z nwalsh $
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=
"function-available('exsl:node-set')">
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 function-available('exsl:node-set')">
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"/>
566 <xsl:call-template name=
"list.of.titles">
567 <xsl:with-param name=
"titles" select=
"'equation'"/>
568 <xsl:with-param name=
"nodes" select=
".//equation"/>
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=
"left"/>
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">
1093 <xsl:call-template name=
"href.target.uri">
1094 <xsl:with-param name=
"object" select=
"$context"/>
1095 </xsl:call-template>
1097 <!-- * <xsl:message>toc-context: <xsl:value-of select="local-name($toc-context)"/></xsl:message> -->
1098 <!-- * <xsl:message>node: <xsl:value-of select="local-name(.)"/></xsl:message> -->
1099 <!-- * <xsl:message>context: <xsl:value-of select="local-name($context)"/></xsl:message> -->
1100 <!-- * <xsl:message>object: <xsl:value-of select="local-name($object)"/></xsl:message> -->
1101 <!-- * <xsl:message>toc-output-dir: <xsl:value-of select="$toc-output-dir"/></xsl:message> -->
1102 <!-- * <xsl:message>linked-file-output-dir: <xsl:value-of select="$linked-file-output-dir"/></xsl:message> -->
1103 <!-- * <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> -->
1104 <!-- * <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> -->
1105 <xsl:variable name=
"href.to">
1107 <!-- * 2007-07-19, MikeSmith: Added the following conditional to -->
1108 <!-- * deal with a problem case for links in TOCs. It checks to see -->
1109 <!-- * if the output dir that a TOC will get written to is -->
1110 <!-- * different from the output dir of the file being linked to. -->
1111 <!-- * If it is different, we do not call trim.common.uri.paths. -->
1113 <!-- * Reason why I added that conditional is: I ran into a bug for -->
1114 <!-- * this case: -->
1116 <!-- * 1. we are chunking into separate dirs -->
1118 <!-- * 2. output for the TOC is written to current dir, but the file -->
1119 <!-- * being linked to is written to some subdir "foo". -->
1121 <!-- * For that case, links to that file in that TOC did not show -->
1122 <!-- * the correct path - they omitted the "foo". -->
1124 <!-- * The cause of that problem was that the trim.common.uri.paths -->
1125 <!-- * template[1] was being called under all conditions. But it's -->
1126 <!-- * apparent that we don't want to call trim.common.uri.paths in -->
1127 <!-- * the case where a linked file is being written to a different -->
1128 <!-- * directory than the TOC that contains the link, because doing -->
1129 <!-- * so will cause a necessary (not redundant) directory-name -->
1130 <!-- * part of the link to get inadvertently trimmed, resulting in -->
1131 <!-- * a broken link to that file. Thus, added the conditional. -->
1133 <!-- * [1] The purpose of the trim.common.uri.paths template is to -->
1134 <!-- * prevent cases where, if we didn't call it, we end up with -->
1135 <!-- * unnecessary, redundant directory names getting output; for -->
1136 <!-- * example, "foo/foo/refname.html". -->
1137 <xsl:when test=
"not($toc-output-dir = $linked-file-output-dir)">
1138 <xsl:value-of select=
"$href.to.uri"/>
1141 <xsl:call-template name=
"trim.common.uri.paths">
1142 <xsl:with-param name=
"uriA" select=
"$href.to.uri"/>
1143 <xsl:with-param name=
"uriB" select=
"$href.from.uri"/>
1144 <xsl:with-param name=
"return" select=
"'A'"/>
1145 </xsl:call-template>
1149 <xsl:variable name=
"href.from">
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=
"'B'"/>
1154 </xsl:call-template>
1156 <xsl:variable name=
"depth">
1157 <xsl:call-template name=
"count.uri.path.depth">
1158 <xsl:with-param name=
"filename" select=
"$href.from"/>
1159 </xsl:call-template>
1161 <xsl:variable name=
"href">
1162 <xsl:call-template name=
"copy-string">
1163 <xsl:with-param name=
"string" select=
"'../'"/>
1164 <xsl:with-param name=
"count" select=
"$depth"/>
1165 </xsl:call-template>
1166 <xsl:value-of select=
"$href.to"/>
1170 <xsl:text>In </xsl:text>
1171 <xsl:value-of select="name(.)"/>
1172 <xsl:text> (</xsl:text>
1173 <xsl:value-of select="$href.from"/>
1174 <xsl:text>,</xsl:text>
1175 <xsl:value-of select="$depth"/>
1176 <xsl:text>) </xsl:text>
1177 <xsl:value-of select="name($object)"/>
1178 <xsl:text> href=</xsl:text>
1179 <xsl:value-of select="$href"/>
1182 <xsl:value-of select=
"$href"/>
1185 <!-- Returns the complete olink href value if found -->
1186 <!-- Must take into account any dbhtml dir of the chunk containing the olink -->
1187 <xsl:template name=
"make.olink.href">
1188 <xsl:param name=
"olink.key" select=
"''"/>
1189 <xsl:param name=
"target.database"/>
1191 <xsl:if test=
"$olink.key != ''">
1192 <xsl:variable name=
"target.href" >
1193 <xsl:for-each select=
"$target.database" >
1194 <xsl:value-of select=
"key('targetptr-key', $olink.key)/@href" />
1198 <!-- an olink starting point may be in a subdirectory, so need
1199 the "from" reference point to compute a relative path -->
1201 <xsl:variable name=
"from.href">
1202 <xsl:call-template name=
"olink.from.uri">
1203 <xsl:with-param name=
"target.database" select=
"$target.database"/>
1204 <xsl:with-param name=
"object" select=
"."/>
1205 <xsl:with-param name=
"object.targetdoc" select=
"$current.docid"/>
1206 </xsl:call-template>
1209 <!-- If the from.href has directory path, then must "../" upward
1210 to document level -->
1211 <xsl:variable name=
"upward.from.path">
1212 <xsl:call-template name=
"upward.path">
1213 <xsl:with-param name=
"path" select=
"$from.href"/>
1214 </xsl:call-template>
1217 <xsl:variable name=
"targetdoc">
1218 <xsl:value-of select=
"substring-before($olink.key, '/')"/>
1221 <!-- Does the target database use a sitemap? -->
1222 <xsl:variable name=
"use.sitemap">
1224 <xsl:when test=
"$target.database//sitemap">1</xsl:when>
1225 <xsl:otherwise>0</xsl:otherwise>
1230 <!-- Get the baseuri for this targetptr -->
1231 <xsl:variable name=
"baseuri" >
1233 <!-- Does the database use a sitemap? -->
1234 <xsl:when test=
"$use.sitemap != 0" >
1236 <!-- Was current.docid parameter set? -->
1237 <xsl:when test=
"$current.docid != ''">
1238 <!-- Was it found in the database? -->
1239 <xsl:variable name=
"currentdoc.key" >
1240 <xsl:for-each select=
"$target.database" >
1241 <xsl:value-of select=
"key('targetdoc-key',
1242 $current.docid)/@targetdoc" />
1246 <xsl:when test=
"$currentdoc.key != ''">
1247 <xsl:for-each select=
"$target.database" >
1248 <xsl:call-template name=
"targetpath" >
1249 <xsl:with-param name=
"dirnode"
1250 select=
"key('targetdoc-key', $current.docid)/parent::dir"/>
1251 <xsl:with-param name=
"targetdoc" select=
"$targetdoc"/>
1252 </xsl:call-template>
1257 <xsl:text>Olink error: cannot compute relative
</xsl:text>
1258 <xsl:text>sitemap path because $current.docid '
</xsl:text>
1259 <xsl:value-of select=
"$current.docid"/>
1260 <xsl:text>' not found in target database.
</xsl:text>
1267 <xsl:text>Olink warning: cannot compute relative
</xsl:text>
1268 <xsl:text>sitemap path without $current.docid parameter
</xsl:text>
1272 <!-- In either case, add baseuri from its document entry-->
1273 <xsl:variable name=
"docbaseuri">
1274 <xsl:for-each select=
"$target.database" >
1275 <xsl:value-of select=
"key('targetdoc-key', $targetdoc)/@baseuri" />
1278 <xsl:if test=
"$docbaseuri != ''" >
1279 <xsl:value-of select=
"$docbaseuri"/>
1282 <!-- No database sitemap in use -->
1284 <!-- Just use any baseuri from its document entry -->
1285 <xsl:variable name=
"docbaseuri">
1286 <xsl:for-each select=
"$target.database" >
1287 <xsl:value-of select=
"key('targetdoc-key', $targetdoc)/@baseuri" />
1290 <xsl:if test=
"$docbaseuri != ''" >
1291 <xsl:value-of select=
"$docbaseuri"/>
1297 <!-- Form the href information -->
1298 <xsl:if test=
"not(contains($baseuri, ':'))">
1299 <!-- if not an absolute uri, add upward path from olink chunk -->
1300 <xsl:value-of select=
"$upward.from.path"/>
1303 <xsl:if test=
"$baseuri != ''">
1304 <xsl:value-of select=
"$baseuri"/>
1305 <xsl:if test=
"substring($target.href,1,1) != '#'">
1306 <!--xsl:text>/</xsl:text-->
1309 <!-- optionally turn off frag for PDF references -->
1310 <xsl:if test=
"not($insert.olink.pdf.frag = 0 and
1311 translate(substring($baseuri, string-length($baseuri) - 3),
1312 'PDF', 'pdf') = '.pdf'
1313 and starts-with($target.href, '#') )">
1314 <xsl:value-of select=
"$target.href"/>
1319 <!-- Computes "../" to reach top -->
1320 <xsl:template name=
"upward.path">
1321 <xsl:param name=
"path" select=
"''"/>
1323 <!-- Don't bother with absolute uris -->
1324 <xsl:when test=
"contains($path, ':')"/>
1325 <xsl:when test=
"starts-with($path, '/')"/>
1326 <xsl:when test=
"contains($path, '/')">
1327 <xsl:text>../
</xsl:text>
1328 <xsl:call-template name=
"upward.path">
1329 <xsl:with-param name=
"path" select=
"substring-after($path, '/')"/>
1330 </xsl:call-template>
1336 <!-- ==================================================================== -->
1338 <xsl:template name=
"html.head">
1339 <xsl:param name=
"prev" select=
"/foo"/>
1340 <xsl:param name=
"next" select=
"/foo"/>
1341 <xsl:variable name=
"this" select=
"."/>
1342 <xsl:variable name=
"home" select=
"/*[1]"/>
1343 <xsl:variable name=
"up" select=
"parent::*"/>
1346 <xsl:call-template name=
"system.head.content"/>
1347 <xsl:call-template name=
"head.content"/>
1349 <xsl:if test=
"$home">
1351 <xsl:attribute name=
"href">
1352 <xsl:call-template name=
"href.target">
1353 <xsl:with-param name=
"object" select=
"$home"/>
1354 </xsl:call-template>
1356 <xsl:attribute name=
"title">
1357 <xsl:apply-templates select=
"$home"
1358 mode=
"object.title.markup.textonly"/>
1365 <xsl:attribute name=
"href">
1366 <xsl:call-template name=
"href.target">
1367 <xsl:with-param name=
"object" select=
"$up"/>
1368 </xsl:call-template>
1370 <xsl:attribute name=
"title">
1371 <xsl:apply-templates select=
"$up" mode=
"object.title.markup.textonly"/>
1376 <xsl:if test=
"$prev">
1378 <xsl:attribute name=
"href">
1379 <xsl:call-template name=
"href.target">
1380 <xsl:with-param name=
"object" select=
"$prev"/>
1381 </xsl:call-template>
1383 <xsl:attribute name=
"title">
1384 <xsl:apply-templates select=
"$prev" mode=
"object.title.markup.textonly"/>
1389 <xsl:if test=
"$next">
1391 <xsl:attribute name=
"href">
1392 <xsl:call-template name=
"href.target">
1393 <xsl:with-param name=
"object" select=
"$next"/>
1394 </xsl:call-template>
1396 <xsl:attribute name=
"title">
1397 <xsl:apply-templates select=
"$next" mode=
"object.title.markup.textonly"/>
1402 <xsl:if test=
"$html.extra.head.links != 0">
1403 <xsl:for-each select=
"//part
1409 |//appendix[not(parent::article)]|appendix
1410 |//glossary[not(parent::article)]|glossary
1411 |//index[not(parent::article)]|index">
1412 <link rel=
"{local-name(.)}">
1413 <xsl:attribute name=
"href">
1414 <xsl:call-template name=
"href.target">
1415 <xsl:with-param name=
"context" select=
"$this"/>
1416 <xsl:with-param name=
"object" select=
"."/>
1417 </xsl:call-template>
1419 <xsl:attribute name=
"title">
1420 <xsl:apply-templates select=
"." mode=
"object.title.markup.textonly"/>
1425 <xsl:for-each select=
"section|sect1|refsection|refsect1">
1427 <xsl:attribute name=
"rel">
1429 <xsl:when test=
"local-name($this) = 'section'
1430 or local-name($this) = 'refsection'">
1431 <xsl:value-of select=
"'subsection'"/>
1434 <xsl:value-of select=
"'section'"/>
1438 <xsl:attribute name=
"href">
1439 <xsl:call-template name=
"href.target">
1440 <xsl:with-param name=
"context" select=
"$this"/>
1441 <xsl:with-param name=
"object" select=
"."/>
1442 </xsl:call-template>
1444 <xsl:attribute name=
"title">
1445 <xsl:apply-templates select=
"." mode=
"object.title.markup.textonly"/>
1450 <xsl:for-each select=
"sect2|sect3|sect4|sect5|refsect2|refsect3">
1451 <link rel=
"subsection">
1452 <xsl:attribute name=
"href">
1453 <xsl:call-template name=
"href.target">
1454 <xsl:with-param name=
"context" select=
"$this"/>
1455 <xsl:with-param name=
"object" select=
"."/>
1456 </xsl:call-template>
1458 <xsl:attribute name=
"title">
1459 <xsl:apply-templates select=
"." mode=
"object.title.markup.textonly"/>
1465 <!-- * if we have a legalnotice and user wants it output as a -->
1466 <!-- * separate page and $html.head.legalnotice.link.types is -->
1467 <!-- * non-empty, we generate a link or links for each value in -->
1468 <!-- * $html.head.legalnotice.link.types -->
1469 <xsl:if test=
"//legalnotice
1470 and not($generate.legalnotice.link = 0)
1471 and not($html.head.legalnotice.link.types = '')">
1472 <xsl:call-template name=
"make.legalnotice.head.links"/>
1475 <xsl:call-template name=
"user.head.content"/>
1479 <!-- ==================================================================== -->
1481 <xsl:template name=
"header.navigation">
1482 <xsl:param name=
"prev" select=
"/foo"/>
1483 <xsl:param name=
"next" select=
"/foo"/>
1484 <xsl:param name=
"nav.context"/>
1486 <xsl:variable name=
"home" select=
"/*[1]"/>
1487 <xsl:variable name=
"up" select=
"parent::*"/>
1489 <xsl:variable name=
"row1" select=
"$navig.showtitles != 0"/>
1490 <xsl:variable name=
"row2" select=
"count($prev) > 0
1491 or (count($up) > 0
1492 and generate-id($up) != generate-id($home)
1493 and $navig.showtitles != 0)
1494 or count($next) > 0"/>
1496 <xsl:if test=
"$suppress.navigation = '0' and $suppress.header.navigation = '0'">
1497 <div class=
"navheader">
1498 <xsl:if test=
"$row1 or $row2">
1499 <table width=
"100%" summary=
"Navigation header">
1500 <xsl:if test=
"$row1">
1502 <th colspan=
"3" align=
"center">
1503 <xsl:apply-templates select=
"." mode=
"object.title.markup"/>
1508 <xsl:if test=
"$row2">
1510 <td width=
"20%" align=
"left">
1511 <xsl:if test=
"count($prev)>0">
1513 <xsl:attribute name=
"href">
1514 <xsl:call-template name=
"href.target">
1515 <xsl:with-param name=
"object" select=
"$prev"/>
1516 </xsl:call-template>
1518 <xsl:call-template name=
"navig.content">
1519 <xsl:with-param name=
"direction" select=
"'prev'"/>
1520 </xsl:call-template>
1523 <xsl:text> </xsl:text>
1525 <th width=
"60%" align=
"center">
1527 <xsl:when test=
"count($up) > 0
1528 and generate-id($up) != generate-id($home)
1529 and $navig.showtitles != 0">
1530 <xsl:apply-templates select=
"$up" mode=
"object.title.markup"/>
1532 <xsl:otherwise> </xsl:otherwise>
1535 <td width=
"20%" align=
"right">
1536 <xsl:text> </xsl:text>
1537 <xsl:if test=
"count($next)>0">
1539 <xsl:attribute name=
"href">
1540 <xsl:call-template name=
"href.target">
1541 <xsl:with-param name=
"object" select=
"$next"/>
1542 </xsl:call-template>
1544 <xsl:call-template name=
"navig.content">
1545 <xsl:with-param name=
"direction" select=
"'next'"/>
1546 </xsl:call-template>
1554 <xsl:if test=
"$header.rule != 0">
1561 <!-- ==================================================================== -->
1563 <xsl:template name=
"footer.navigation">
1564 <xsl:param name=
"prev" select=
"/foo"/>
1565 <xsl:param name=
"next" select=
"/foo"/>
1566 <xsl:param name=
"nav.context"/>
1568 <xsl:variable name=
"home" select=
"/*[1]"/>
1569 <xsl:variable name=
"up" select=
"parent::*"/>
1571 <xsl:variable name=
"row1" select=
"count($prev) > 0
1572 or count($up) > 0
1573 or count($next) > 0"/>
1575 <xsl:variable name=
"row2" select=
"($prev and $navig.showtitles != 0)
1576 or (generate-id($home) != generate-id(.)
1577 or $nav.context = 'toc')
1578 or ($chunk.tocs.and.lots != 0
1579 and $nav.context != 'toc')
1580 or ($next and $navig.showtitles != 0)"/>
1582 <xsl:if test=
"$suppress.navigation = '0' and $suppress.footer.navigation = '0'">
1583 <div class=
"navfooter">
1584 <xsl:if test=
"$footer.rule != 0">
1588 <xsl:if test=
"$row1 or $row2">
1589 <table width=
"100%" summary=
"Navigation footer">
1590 <xsl:if test=
"$row1">
1592 <td width=
"40%" align=
"left">
1593 <xsl:if test=
"count($prev)>0">
1595 <xsl:attribute name=
"href">
1596 <xsl:call-template name=
"href.target">
1597 <xsl:with-param name=
"object" select=
"$prev"/>
1598 </xsl:call-template>
1600 <xsl:call-template name=
"navig.content">
1601 <xsl:with-param name=
"direction" select=
"'prev'"/>
1602 </xsl:call-template>
1605 <xsl:text> </xsl:text>
1607 <td width=
"20%" align=
"center">
1609 <xsl:when test=
"count($up)>0
1610 and generate-id($up) != generate-id($home)">
1612 <xsl:attribute name=
"href">
1613 <xsl:call-template name=
"href.target">
1614 <xsl:with-param name=
"object" select=
"$up"/>
1615 </xsl:call-template>
1617 <xsl:call-template name=
"navig.content">
1618 <xsl:with-param name=
"direction" select=
"'up'"/>
1619 </xsl:call-template>
1622 <xsl:otherwise> </xsl:otherwise>
1625 <td width=
"40%" align=
"right">
1626 <xsl:text> </xsl:text>
1627 <xsl:if test=
"count($next)>0">
1629 <xsl:attribute name=
"href">
1630 <xsl:call-template name=
"href.target">
1631 <xsl:with-param name=
"object" select=
"$next"/>
1632 </xsl:call-template>
1634 <xsl:call-template name=
"navig.content">
1635 <xsl:with-param name=
"direction" select=
"'next'"/>
1636 </xsl:call-template>
1643 <xsl:if test=
"$row2">
1645 <td width=
"40%" align=
"left" valign=
"top">
1646 <xsl:if test=
"$navig.showtitles != 0">
1647 <xsl:apply-templates select=
"$prev" mode=
"object.title.markup"/>
1649 <xsl:text> </xsl:text>
1651 <td width=
"20%" align=
"center">
1653 <xsl:when test=
"$home != . or $nav.context = 'toc'">
1655 <xsl:attribute name=
"href">
1656 <xsl:call-template name=
"href.target">
1657 <xsl:with-param name=
"object" select=
"$home"/>
1658 </xsl:call-template>
1660 <xsl:call-template name=
"navig.content">
1661 <xsl:with-param name=
"direction" select=
"'home'"/>
1662 </xsl:call-template>
1664 <xsl:if test=
"$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1665 <xsl:text> |
 </xsl:text>
1668 <xsl:otherwise> </xsl:otherwise>
1671 <xsl:if test=
"$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1673 <xsl:attribute name=
"href">
1674 <xsl:apply-templates select=
"/*[1]"
1675 mode=
"recursive-chunk-filename">
1676 <xsl:with-param name=
"recursive" select=
"true()"/>
1677 </xsl:apply-templates>
1678 <xsl:text>-toc
</xsl:text>
1679 <xsl:value-of select=
"$html.ext"/>
1681 <xsl:call-template name=
"gentext">
1682 <xsl:with-param name=
"key" select=
"'nav-toc'"/>
1683 </xsl:call-template>
1687 <td width=
"40%" align=
"right" valign=
"top">
1688 <xsl:text> </xsl:text>
1689 <xsl:if test=
"$navig.showtitles != 0">
1690 <xsl:apply-templates select=
"$next" mode=
"object.title.markup"/>
1701 <!-- ==================================================================== -->
1703 <xsl:template name=
"navig.content">
1704 <xsl:param name=
"direction" select=
"next"/>
1705 <xsl:variable name=
"navtext">
1707 <xsl:when test=
"$direction = 'prev'">
1708 <xsl:call-template name=
"gentext.nav.prev"/>
1710 <xsl:when test=
"$direction = 'next'">
1711 <xsl:call-template name=
"gentext.nav.next"/>
1713 <xsl:when test=
"$direction = 'up'">
1714 <xsl:call-template name=
"gentext.nav.up"/>
1716 <xsl:when test=
"$direction = 'home'">
1717 <xsl:call-template name=
"gentext.nav.home"/>
1720 <xsl:text>xxx
</xsl:text>
1726 <xsl:when test=
"$navig.graphics != 0">
1728 <xsl:attribute name=
"src">
1729 <xsl:value-of select=
"$navig.graphics.path"/>
1730 <xsl:value-of select=
"$direction"/>
1731 <xsl:value-of select=
"$navig.graphics.extension"/>
1733 <xsl:attribute name=
"alt">
1734 <xsl:value-of select=
"$navtext"/>
1739 <xsl:value-of select=
"$navtext"/>
1744 <!-- ==================================================================== -->
1746 <!-- * The following template assumes that the first legalnotice -->
1747 <!-- * instance found in a document applies to the contents of the -->
1748 <!-- * entire document. It generates an HTML link in each chunk, back -->
1749 <!-- * to the file containing the contents of the first legalnotice. -->
1751 <!-- * Actually, it may generate multiple link instances in each chunk, -->
1752 <!-- * because it walks through the space-separated list of link -->
1753 <!-- * types specified in the $html.head.legalnotice.link.types param, -->
1754 <!-- * popping off link types and generating links for them until it -->
1755 <!-- * depletes the list. -->
1757 <xsl:template name=
"make.legalnotice.head.links">
1758 <!-- * the following ID is used as part of the legalnotice filename; -->
1759 <!-- * we need it in order to construct the filename for use in the -->
1760 <!-- * value of the href attribute on the link -->
1762 <xsl:param name=
"ln-node" select=
"(//legalnotice)[1]"/>
1764 <xsl:param name=
"linktype">
1766 <xsl:when test=
"contains($html.head.legalnotice.link.types, ' ')">
1768 select=
"normalize-space(
1769 substring-before($html.head.legalnotice.link.types, ' '))"/>
1772 <xsl:value-of select=
"$html.head.legalnotice.link.types"/>
1777 name=
"remaining.linktypes"
1780 substring-after($html.head.legalnotice.link.types, ' ')),' ')"/>
1781 <xsl:if test=
"not($linktype = '')">
1783 <!-- Compute name of legalnotice file (see titlepage.xsl) -->
1784 <xsl:variable name=
"file">
1785 <xsl:call-template name=
"ln.or.rh.filename">
1786 <xsl:with-param name=
"node" select=
"$ln-node"/>
1787 </xsl:call-template>
1790 <link rel=
"{$linktype}">
1791 <xsl:attribute name=
"href">
1792 <xsl:value-of select=
"$file"/>
1794 <xsl:attribute name=
"title">
1795 <xsl:apply-templates select=
"(//legalnotice)[1]"
1796 mode=
"object.title.markup.textonly"/>
1799 <xsl:call-template name=
"make.legalnotice.head.links">
1800 <!-- * pop the next value off the list of link types -->
1803 select=
"substring-before($remaining.linktypes, ' ')"/>
1804 <!-- * remove the link type from the list of remaining link types -->
1806 name=
"remaining.linktypes"
1807 select=
"substring-after($remaining.linktypes, ' ')"/>
1808 </xsl:call-template>
1812 <!-- ==================================================================== -->
1813 <xsl:template name=
"chunk-element-content">
1814 <xsl:param name=
"prev"/>
1815 <xsl:param name=
"next"/>
1816 <xsl:param name=
"nav.context"/>
1817 <xsl:param name=
"content">
1818 <xsl:apply-imports/>
1821 <xsl:call-template name=
"user.preroot"/>
1824 <xsl:call-template name=
"html.head">
1825 <xsl:with-param name=
"prev" select=
"$prev"/>
1826 <xsl:with-param name=
"next" select=
"$next"/>
1827 </xsl:call-template>
1830 <xsl:call-template name=
"body.attributes"/>
1831 <xsl:call-template name=
"user.header.navigation"/>
1833 <xsl:call-template name=
"header.navigation">
1834 <xsl:with-param name=
"prev" select=
"$prev"/>
1835 <xsl:with-param name=
"next" select=
"$next"/>
1836 <xsl:with-param name=
"nav.context" select=
"$nav.context"/>
1837 </xsl:call-template>
1839 <xsl:call-template name=
"user.header.content"/>
1841 <xsl:copy-of select=
"$content"/>
1843 <xsl:call-template name=
"user.footer.content"/>
1845 <xsl:call-template name=
"footer.navigation">
1846 <xsl:with-param name=
"prev" select=
"$prev"/>
1847 <xsl:with-param name=
"next" select=
"$next"/>
1848 <xsl:with-param name=
"nav.context" select=
"$nav.context"/>
1849 </xsl:call-template>
1851 <xsl:call-template name=
"user.footer.navigation"/>
1854 <xsl:value-of select=
"$chunk.append"/>
1857 <!-- ==================================================================== -->
1858 <xsl:template name=
"generate.manifest">
1859 <xsl:param name=
"node" select=
"/"/>
1860 <xsl:call-template name=
"write.text.chunk">
1861 <xsl:with-param name=
"filename">
1862 <xsl:if test=
"$manifest.in.base.dir != 0">
1863 <xsl:value-of select=
"$base.dir"/>
1865 <xsl:value-of select=
"$manifest"/>
1867 <xsl:with-param name=
"method" select=
"'text'"/>
1868 <xsl:with-param name=
"content">
1869 <xsl:apply-templates select=
"$node" mode=
"enumerate-files"/>
1871 <xsl:with-param name=
"encoding" select=
"$chunker.output.encoding"/>
1872 </xsl:call-template>
1875 <!-- ==================================================================== -->
1877 <xsl:template name=
"dbhtml-dir">
1878 <xsl:param name=
"context" select=
"."/>
1879 <!-- directories are now inherited from previous levels -->
1880 <xsl:variable name=
"ppath">
1881 <xsl:if test=
"$context/parent::*">
1882 <xsl:call-template name=
"dbhtml-dir">
1883 <xsl:with-param name=
"context" select=
"$context/parent::*"/>
1884 </xsl:call-template>
1887 <xsl:variable name=
"path">
1888 <xsl:call-template name=
"pi.dbhtml_dir">
1889 <xsl:with-param name=
"node" select=
"$context"/>
1890 </xsl:call-template>
1893 <xsl:when test=
"$path = ''">
1894 <xsl:if test=
"$ppath != ''">
1895 <xsl:value-of select=
"$ppath"/>
1899 <xsl:if test=
"$ppath != ''">
1900 <xsl:value-of select=
"$ppath"/>
1901 <xsl:if test=
"substring($ppath, string-length($ppath), 1) != '/'">
1902 <xsl:text>/
</xsl:text>
1905 <xsl:value-of select=
"$path"/>
1906 <xsl:text>/
</xsl:text>