1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="exsl cf">
6 <!-- ********************************************************************
7 $Id: chunk-common.xsl 9866 2014-01-29 02:55:52Z bobstayton $
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
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 namespace-uri(/*) = 'http://docbook.org/ns/docbook'">
31 <xsl:if test="$chunk.quietly = 0">
32 <xsl:message>Computing chunks...</xsl:message>
34 <xsl:apply-templates mode="find.chunks" select="exsl:node-set($no.namespace)"/>
36 <xsl:when test="$exsl.node.set.available != 0">
37 <xsl:if test="$chunk.quietly = 0">
38 <xsl:message>Computing chunks...</xsl:message>
40 <xsl:apply-templates select="/*" mode="find.chunks"/>
43 <xsl:if test="$chunk.quietly = 0">
45 <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
46 <xsl:text>Using "slow" chunking.</xsl:text>
54 <!-- ==================================================================== -->
56 <xsl:template name="process-chunk-element">
57 <xsl:param name="content">
62 <xsl:when test="$chunk.fast != 0 and $exsl.node.set.available != 0">
63 <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
64 <xsl:variable name="genid" select="generate-id()"/>
66 <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
68 <xsl:variable name="prevdiv" select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
69 <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
71 <xsl:variable name="nextdiv" select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
72 <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
75 <xsl:when test="$onechunk != 0 and parent::*">
76 <xsl:copy-of select="$content"/>
79 <xsl:call-template name="process-chunk">
80 <xsl:with-param name="prev" select="$prev"/>
81 <xsl:with-param name="next" select="$next"/>
82 <xsl:with-param name="content" select="$content"/>
89 <xsl:when test="$onechunk != 0 and not(parent::*)">
90 <xsl:call-template name="chunk-all-sections">
91 <xsl:with-param name="content" select="$content"/>
94 <xsl:when test="$onechunk != 0">
95 <xsl:copy-of select="$content"/>
97 <xsl:when test="$chunk.first.sections = 0">
98 <xsl:call-template name="chunk-first-section-with-parent">
99 <xsl:with-param name="content" select="$content"/>
103 <xsl:call-template name="chunk-all-sections">
104 <xsl:with-param name="content" select="$content"/>
112 <xsl:template name="process-chunk">
113 <xsl:param name="prev" select="."/>
114 <xsl:param name="next" select="."/>
115 <xsl:param name="content">
119 <xsl:variable name="ischunk">
120 <xsl:call-template name="chunk"/>
123 <xsl:variable name="chunkfn">
124 <xsl:if test="$ischunk='1'">
125 <xsl:apply-templates mode="chunk-filename" select="."/>
129 <xsl:if test="$ischunk='0'">
131 <xsl:text>Error </xsl:text>
132 <xsl:value-of select="name(.)"/>
133 <xsl:text> is not a chunk!</xsl:text>
137 <xsl:variable name="filename">
138 <xsl:call-template name="make-relative-filename">
139 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
140 <xsl:with-param name="base.name" select="$chunkfn"/>
144 <xsl:call-template name="write.chunk">
145 <xsl:with-param name="filename" select="$filename"/>
146 <xsl:with-param name="content">
147 <xsl:call-template name="chunk-element-content">
148 <xsl:with-param name="prev" select="$prev"/>
149 <xsl:with-param name="next" select="$next"/>
150 <xsl:with-param name="content" select="$content"/>
153 <xsl:with-param name="quiet" select="$chunk.quietly"/>
157 <xsl:template name="chunk-first-section-with-parent">
158 <xsl:param name="content">
162 <!-- These xpath expressions are really hairy. The trick is to pick sections -->
163 <!-- that are not first children and are not the children of first children -->
165 <!-- Break these variables into pieces to work around
166 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
168 <xsl:variable name="prev-v1" select="(ancestor::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect1][1] |ancestor::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect2 and parent::sect1[preceding-sibling::sect1]][1] |ancestor::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect3 and parent::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |ancestor::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect4 and parent::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |ancestor::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect5 and parent::sect4[preceding-sibling::sect4] and ancestor::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |ancestor::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
170 <xsl:variable name="prev-v2" select="(preceding::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect1][1] |preceding::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect2 and parent::sect1[preceding-sibling::sect1]][1] |preceding::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect3 and parent::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |preceding::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect4 and parent::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |preceding::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect5 and parent::sect4[preceding-sibling::sect4] and ancestor::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |preceding::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::section and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
172 <xsl:variable name="prev" select="(preceding::book[1] |preceding::preface[1] |preceding::chapter[1] |preceding::appendix[1] |preceding::part[1] |preceding::reference[1] |preceding::refentry[1] |preceding::colophon[1] |preceding::article[1] |preceding::topic[1] |preceding::bibliography[parent::article or parent::book or parent::part][1] |preceding::glossary[parent::article or parent::book or parent::part][1] |preceding::index[$generate.index != 0] [parent::article or parent::book or parent::part][1] |preceding::setindex[$generate.index != 0][1] |ancestor::set |ancestor::book[1] |ancestor::preface[1] |ancestor::chapter[1] |ancestor::appendix[1] |ancestor::part[1] |ancestor::reference[1] |ancestor::article[1] |ancestor::topic[1] |$prev-v1 |$prev-v2)[last()]"/>
174 <xsl:variable name="next-v1" select="(following::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect1][1] |following::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect2 and parent::sect1[preceding-sibling::sect1]][1] |following::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect3 and parent::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |following::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect4 and parent::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |following::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect5 and parent::sect4[preceding-sibling::sect4] and ancestor::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |following::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::section and not(ancestor::section[not(preceding-sibling::section)])][1])[1]"/>
176 <xsl:variable name="next-v2" select="(descendant::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect1][1] |descendant::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect2 and parent::sect1[preceding-sibling::sect1]][1] |descendant::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect3 and parent::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |descendant::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect4 and parent::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |descendant::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::sect5 and parent::sect4[preceding-sibling::sect4] and ancestor::sect3[preceding-sibling::sect3] and ancestor::sect2[preceding-sibling::sect2] and ancestor::sect1[preceding-sibling::sect1]][1] |descendant::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::section and not(ancestor::section[not(preceding-sibling::section)])])[1]"/>
178 <xsl:variable name="next" select="(following::book[1] |following::preface[1] |following::chapter[1] |following::appendix[1] |following::part[1] |following::reference[1] |following::refentry[1] |following::colophon[1] |following::bibliography[parent::article or parent::book or parent::part][1] |following::glossary[parent::article or parent::book or parent::part][1] |following::index[$generate.index != 0] [parent::article or parent::book or parent::part][1] |following::article[1] |following::topic[1] |following::setindex[$generate.index != 0][1] |descendant::book[1] |descendant::preface[1] |descendant::chapter[1] |descendant::appendix[1] |descendant::article[1] |descendant::topic[1] |descendant::bibliography[parent::article or parent::book or parent::part][1] |descendant::glossary[parent::article or parent::book or parent::part][1] |descendant::index[$generate.index != 0] [parent::article or parent::book or parent::part][1] |descendant::colophon[1] |descendant::setindex[$generate.index != 0][1] |descendant::part[1] |descendant::reference[1] |descendant::refentry[1] |$next-v1 |$next-v2)[1]"/>
180 <xsl:call-template name="process-chunk">
181 <xsl:with-param name="prev" select="$prev"/>
182 <xsl:with-param name="next" select="$next"/>
183 <xsl:with-param name="content" select="$content"/>
187 <xsl:template name="chunk-all-sections">
188 <xsl:param name="content">
192 <xsl:variable name="prev-v1" select="(preceding::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
194 <xsl:variable name="prev-v2" select="(ancestor::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
196 <xsl:variable name="prev" select="(preceding::book[1] |preceding::preface[1] |preceding::chapter[1] |preceding::appendix[1] |preceding::part[1] |preceding::reference[1] |preceding::refentry[1] |preceding::colophon[1] |preceding::article[1] |preceding::topic[1] |preceding::bibliography[parent::article or parent::book or parent::part][1] |preceding::glossary[parent::article or parent::book or parent::part][1] |preceding::index[$generate.index != 0] [parent::article or parent::book or parent::part][1] |preceding::setindex[$generate.index != 0][1] |ancestor::set |ancestor::book[1] |ancestor::preface[1] |ancestor::chapter[1] |ancestor::appendix[1] |ancestor::part[1] |ancestor::reference[1] |ancestor::article[1] |ancestor::topic[1] |$prev-v1 |$prev-v2)[last()]"/>
198 <xsl:variable name="next-v1" select="(following::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
200 <xsl:variable name="next-v2" select="(descendant::sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::section[$chunk.section.depth > count(ancestor::section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
202 <xsl:variable name="next" select="(following::book[1] |following::preface[1] |following::chapter[1] |following::appendix[1] |following::part[1] |following::reference[1] |following::refentry[1] |following::colophon[1] |following::bibliography[parent::article or parent::book or parent::part][1] |following::glossary[parent::article or parent::book or parent::part][1] |following::index[$generate.index != 0] [parent::article or parent::book][1] |following::article[1] |following::topic[1] |following::setindex[$generate.index != 0][1] |descendant::book[1] |descendant::preface[1] |descendant::chapter[1] |descendant::appendix[1] |descendant::article[1] |descendant::topic[1] |descendant::bibliography[parent::article or parent::book][1] |descendant::glossary[parent::article or parent::book or parent::part][1] |descendant::index[$generate.index != 0] [parent::article or parent::book][1] |descendant::colophon[1] |descendant::setindex[$generate.index != 0][1] |descendant::part[1] |descendant::reference[1] |descendant::refentry[1] |$next-v1 |$next-v2)[1]"/>
204 <xsl:call-template name="process-chunk">
205 <xsl:with-param name="prev" select="$prev"/>
206 <xsl:with-param name="next" select="$next"/>
207 <xsl:with-param name="content" select="$content"/>
211 <!-- ==================================================================== -->
213 <!-- ==================================================================== -->
215 <xsl:template name="make.lots">
216 <xsl:param name="toc.params" select="''"/>
217 <xsl:param name="toc"/>
219 <xsl:variable name="lots">
220 <xsl:if test="contains($toc.params, 'toc')">
221 <xsl:copy-of select="$toc"/>
224 <xsl:if test="contains($toc.params, 'figure')">
226 <xsl:when test="$chunk.separate.lots != '0'">
227 <xsl:call-template name="make.lot.chunk">
228 <xsl:with-param name="type" select="'figure'"/>
229 <xsl:with-param name="lot">
230 <xsl:call-template name="list.of.titles">
231 <xsl:with-param name="titles" select="'figure'"/>
232 <xsl:with-param name="nodes" select=".//figure"/>
238 <xsl:call-template name="list.of.titles">
239 <xsl:with-param name="titles" select="'figure'"/>
240 <xsl:with-param name="nodes" select=".//figure"/>
246 <xsl:if test="contains($toc.params, 'table')">
248 <xsl:when test="$chunk.separate.lots != '0'">
249 <xsl:call-template name="make.lot.chunk">
250 <xsl:with-param name="type" select="'table'"/>
251 <xsl:with-param name="lot">
252 <xsl:call-template name="list.of.titles">
253 <xsl:with-param name="titles" select="'table'"/>
254 <xsl:with-param name="nodes" select=".//table[not(@tocentry = 0)]"/>
260 <xsl:call-template name="list.of.titles">
261 <xsl:with-param name="titles" select="'table'"/>
262 <xsl:with-param name="nodes" select=".//table[not(@tocentry = 0)]"/>
268 <xsl:if test="contains($toc.params, 'example')">
270 <xsl:when test="$chunk.separate.lots != '0'">
271 <xsl:call-template name="make.lot.chunk">
272 <xsl:with-param name="type" select="'example'"/>
273 <xsl:with-param name="lot">
274 <xsl:call-template name="list.of.titles">
275 <xsl:with-param name="titles" select="'example'"/>
276 <xsl:with-param name="nodes" select=".//example"/>
282 <xsl:call-template name="list.of.titles">
283 <xsl:with-param name="titles" select="'example'"/>
284 <xsl:with-param name="nodes" select=".//example"/>
290 <xsl:if test="contains($toc.params, 'equation')">
292 <xsl:when test="$chunk.separate.lots != '0'">
293 <xsl:call-template name="make.lot.chunk">
294 <xsl:with-param name="type" select="'equation'"/>
295 <xsl:with-param name="lot">
296 <xsl:call-template name="list.of.titles">
297 <xsl:with-param name="titles" select="'equation'"/>
298 <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
304 <xsl:call-template name="list.of.titles">
305 <xsl:with-param name="titles" select="'equation'"/>
306 <xsl:with-param name="nodes" select=".//equation[title or info/title]"/>
312 <xsl:if test="contains($toc.params, 'procedure')">
314 <xsl:when test="$chunk.separate.lots != '0'">
315 <xsl:call-template name="make.lot.chunk">
316 <xsl:with-param name="type" select="'procedure'"/>
317 <xsl:with-param name="lot">
318 <xsl:call-template name="list.of.titles">
319 <xsl:with-param name="titles" select="'procedure'"/>
320 <xsl:with-param name="nodes" select=".//procedure[title]"/>
326 <xsl:call-template name="list.of.titles">
327 <xsl:with-param name="titles" select="'procedure'"/>
328 <xsl:with-param name="nodes" select=".//procedure[title]"/>
335 <xsl:if test="string($lots) != ''">
337 <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
338 <xsl:call-template name="write.chunk">
339 <xsl:with-param name="filename">
340 <xsl:call-template name="make-relative-filename">
341 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
342 <xsl:with-param name="base.name">
343 <xsl:call-template name="dbhtml-dir"/>
344 <xsl:value-of select="$chunked.filename.prefix"/>
345 <xsl:apply-templates select="." mode="recursive-chunk-filename">
346 <xsl:with-param name="recursive" select="true()"/>
347 </xsl:apply-templates>
348 <xsl:text>-toc</xsl:text>
349 <xsl:value-of select="$html.ext"/>
353 <xsl:with-param name="content">
354 <xsl:call-template name="chunk-element-content">
355 <xsl:with-param name="prev" select="/foo"/>
356 <xsl:with-param name="next" select="/foo"/>
357 <xsl:with-param name="nav.context" select="'toc'"/>
358 <xsl:with-param name="content">
359 <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
361 <xsl:apply-templates select="." mode="object.title.markup"/>
364 <xsl:copy-of select="$lots"/>
368 <xsl:with-param name="quiet" select="$chunk.quietly"/>
372 <xsl:copy-of select="$lots"/>
378 <xsl:template name="make.lot.chunk">
379 <xsl:param name="type" select="''"/>
380 <xsl:param name="lot"/>
382 <xsl:if test="string($lot) != ''">
383 <xsl:variable name="filename">
384 <xsl:call-template name="make-relative-filename">
385 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
386 <xsl:with-param name="base.name">
387 <xsl:call-template name="dbhtml-dir"/>
388 <xsl:value-of select="$type"/>
389 <xsl:text>-toc</xsl:text>
390 <xsl:value-of select="$html.ext"/>
395 <xsl:variable name="href">
396 <xsl:call-template name="make-relative-filename">
397 <xsl:with-param name="base.dir" select="''"/>
398 <xsl:with-param name="base.name">
399 <xsl:call-template name="dbhtml-dir"/>
400 <xsl:value-of select="$type"/>
401 <xsl:text>-toc</xsl:text>
402 <xsl:value-of select="$html.ext"/>
407 <xsl:call-template name="write.chunk">
408 <xsl:with-param name="filename" select="$filename"/>
409 <xsl:with-param name="content">
410 <xsl:call-template name="chunk-element-content">
411 <xsl:with-param name="prev" select="/foo"/>
412 <xsl:with-param name="next" select="/foo"/>
413 <xsl:with-param name="nav.context" select="'toc'"/>
414 <xsl:with-param name="content">
415 <xsl:copy-of select="$lot"/>
419 <xsl:with-param name="quiet" select="$chunk.quietly"/>
421 <!-- And output a link to this file -->
423 <xsl:attribute name="class">
424 <xsl:text>ListofTitles</xsl:text>
427 <xsl:call-template name="gentext">
428 <xsl:with-param name="key">
430 <xsl:when test="$type='table'">ListofTables</xsl:when>
431 <xsl:when test="$type='figure'">ListofFigures</xsl:when>
432 <xsl:when test="$type='equation'">ListofEquations</xsl:when>
433 <xsl:when test="$type='example'">ListofExamples</xsl:when>
434 <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
435 <xsl:otherwise>ListofUnknown</xsl:otherwise>
444 <!-- ==================================================================== -->
446 <xsl:template name="in.other.chunk">
447 <xsl:param name="chunk" select="."/>
448 <xsl:param name="node" select="."/>
450 <xsl:variable name="is.chunk">
451 <xsl:call-template name="chunk">
452 <xsl:with-param name="node" select="$node"/>
458 <xsl:text>in.other.chunk: </xsl:text>
459 <xsl:value-of select="name($chunk)"/>
460 <xsl:text> </xsl:text>
461 <xsl:value-of select="name($node)"/>
462 <xsl:text> </xsl:text>
463 <xsl:value-of select="$chunk = $node"/>
464 <xsl:text> </xsl:text>
465 <xsl:value-of select="$is.chunk"/>
470 <xsl:when test="$chunk = $node">0</xsl:when>
471 <xsl:when test="$is.chunk = 1">1</xsl:when>
472 <xsl:when test="count($node) = 0">0</xsl:when>
474 <xsl:call-template name="in.other.chunk">
475 <xsl:with-param name="chunk" select="$chunk"/>
476 <xsl:with-param name="node" select="$node/parent::*"/>
482 <xsl:template name="count.footnotes.in.this.chunk">
483 <xsl:param name="node" select="."/>
484 <xsl:param name="footnotes" select="$node//footnote"/>
485 <xsl:param name="count" select="0"/>
489 <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
490 <xsl:value-of select="name($node)"/>
494 <xsl:variable name="in.other.chunk">
495 <xsl:call-template name="in.other.chunk">
496 <xsl:with-param name="chunk" select="$node"/>
497 <xsl:with-param name="node" select="$footnotes[1]"/>
502 <xsl:when test="count($footnotes) = 0">
503 <xsl:value-of select="$count"/>
507 <xsl:when test="$in.other.chunk != 0">
508 <xsl:call-template name="count.footnotes.in.this.chunk">
509 <xsl:with-param name="node" select="$node"/>
510 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
511 <xsl:with-param name="count" select="$count"/>
514 <xsl:when test="$footnotes[1]/ancestor::table |$footnotes[1]/ancestor::informaltable">
515 <xsl:call-template name="count.footnotes.in.this.chunk">
516 <xsl:with-param name="node" select="$node"/>
517 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
518 <xsl:with-param name="count" select="$count"/>
522 <xsl:call-template name="count.footnotes.in.this.chunk">
523 <xsl:with-param name="node" select="$node"/>
524 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
525 <xsl:with-param name="count" select="$count + 1"/>
533 <xsl:template name="process.footnotes.in.this.chunk">
534 <xsl:param name="node" select="."/>
535 <xsl:param name="footnotes" select="$node//footnote"/>
538 <xsl:message>process.footnotes.in.this.chunk</xsl:message>
541 <xsl:variable name="in.other.chunk">
542 <xsl:call-template name="in.other.chunk">
543 <xsl:with-param name="chunk" select="$node"/>
544 <xsl:with-param name="node" select="$footnotes[1]"/>
549 <xsl:when test="count($footnotes) = 0">
554 <xsl:when test="$in.other.chunk != 0">
555 <xsl:call-template name="process.footnotes.in.this.chunk">
556 <xsl:with-param name="node" select="$node"/>
557 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
560 <xsl:when test="$footnotes[1]/ancestor::table |$footnotes[1]/ancestor::informaltable">
561 <xsl:call-template name="process.footnotes.in.this.chunk">
562 <xsl:with-param name="node" select="$node"/>
563 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
567 <xsl:apply-templates select="$footnotes[1]" mode="process.footnote.mode"/>
568 <xsl:call-template name="process.footnotes.in.this.chunk">
569 <xsl:with-param name="node" select="$node"/>
570 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
578 <xsl:template name="process.footnotes">
579 <xsl:variable name="footnotes" select=".//footnote"/>
580 <xsl:variable name="fcount">
581 <xsl:call-template name="count.footnotes.in.this.chunk">
582 <xsl:with-param name="node" select="."/>
583 <xsl:with-param name="footnotes" select="$footnotes"/>
589 <xsl:value-of select="name(.)"/>
590 <xsl:text> fcount: </xsl:text>
591 <xsl:value-of select="$fcount"/>
595 <!-- Only bother to do this if there's at least one non-table footnote -->
596 <xsl:if test="$fcount > 0">
597 <div class="footnotes">
598 <xsl:call-template name="footnotes.attributes"/>
602 <xsl:when test="$make.clean.html != 0">
603 <xsl:attribute name="class">footnote-hr</xsl:attribute>
605 <xsl:when test="$css.decoration != 0">
606 <xsl:attribute name="style">
607 <xsl:value-of select="concat('width:100; text-align:', $direction.align.start, ';', 'margin-', $direction.align.start, ': 0')"/>
611 <xsl:attribute name="width">100</xsl:attribute>
612 <xsl:attribute name="align"><xsl:value-of select="$direction.align.start"/></xsl:attribute>
616 <xsl:call-template name="process.footnotes.in.this.chunk">
617 <xsl:with-param name="node" select="."/>
618 <xsl:with-param name="footnotes" select="$footnotes"/>
623 <!-- FIXME: When chunking, only the annotations actually used
624 in this chunk should be referenced. I don't think it
625 does any harm to reference them all, but it adds
626 unnecessary bloat to each chunk. -->
627 <xsl:if test="$annotation.support != 0 and //annotation">
628 <div class="annotation-list">
629 <div class="annotation-nocss">
630 <p>The following annotations are from this essay. You are seeing
631 them here because your browser doesn’t support the user-interface
632 techniques used to make them appear as ‘popups’ on modern browsers.</p>
635 <xsl:apply-templates select="//annotation" mode="annotation-popup"/>
640 <xsl:template name="process.chunk.footnotes">
641 <xsl:variable name="is.chunk">
642 <xsl:call-template name="chunk"/>
644 <xsl:if test="$is.chunk = 1">
645 <xsl:call-template name="process.footnotes"/>
649 <!-- ====================================================================== -->
651 <xsl:template name="chunk">
652 <xsl:param name="node" select="."/>
653 <!-- returns 1 if $node is a chunk -->
655 <!-- ==================================================================== -->
661 bibliography in article or part or book
665 glossary in article or part or book
666 index in article or part or book
671 sect{1,2,3,4,5} if position()>1 && depth < chunk.section.depth
672 section if position()>1 && depth < chunk.section.depth
677 <!-- ==================================================================== -->
681 <xsl:text>chunk: </xsl:text>
682 <xsl:value-of select="name($node)"/>
683 <xsl:text>(</xsl:text>
684 <xsl:value-of select="$node/@id"/>
685 <xsl:text>)</xsl:text>
686 <xsl:text> csd: </xsl:text>
687 <xsl:value-of select="$chunk.section.depth"/>
688 <xsl:text> cfs: </xsl:text>
689 <xsl:value-of select="$chunk.first.sections"/>
690 <xsl:text> ps: </xsl:text>
691 <xsl:value-of select="count($node/parent::section)"/>
692 <xsl:text> prs: </xsl:text>
693 <xsl:value-of select="count($node/preceding-sibling::section)"/>
698 <xsl:when test="$node/parent::*/processing-instruction('dbhtml')[normalize-space(.) = 'stop-chunking']">0</xsl:when>
699 <xsl:when test="not($node/parent::*)">1</xsl:when>
701 <xsl:when test="local-name($node) = 'sect1' and $chunk.section.depth >= 1 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect1) > 0)">
702 <xsl:text>1</xsl:text>
704 <xsl:when test="local-name($node) = 'sect2' and $chunk.section.depth >= 2 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect2) > 0)">
705 <xsl:call-template name="chunk">
706 <xsl:with-param name="node" select="$node/parent::*"/>
709 <xsl:when test="local-name($node) = 'sect3' and $chunk.section.depth >= 3 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect3) > 0)">
710 <xsl:call-template name="chunk">
711 <xsl:with-param name="node" select="$node/parent::*"/>
714 <xsl:when test="local-name($node) = 'sect4' and $chunk.section.depth >= 4 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect4) > 0)">
715 <xsl:call-template name="chunk">
716 <xsl:with-param name="node" select="$node/parent::*"/>
719 <xsl:when test="local-name($node) = 'sect5' and $chunk.section.depth >= 5 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect5) > 0)">
720 <xsl:call-template name="chunk">
721 <xsl:with-param name="node" select="$node/parent::*"/>
724 <xsl:when test="local-name($node) = 'section' and $chunk.section.depth >= count($node/ancestor::section)+1 and ($chunk.first.sections != 0 or count($node/preceding-sibling::section) > 0)">
725 <xsl:call-template name="chunk">
726 <xsl:with-param name="node" select="$node/parent::*"/>
730 <xsl:when test="local-name($node)='preface'">1</xsl:when>
731 <xsl:when test="local-name($node)='chapter'">1</xsl:when>
732 <xsl:when test="local-name($node)='appendix'">1</xsl:when>
733 <xsl:when test="local-name($node)='article'">1</xsl:when>
734 <xsl:when test="local-name($node)='topic'">1</xsl:when>
735 <xsl:when test="local-name($node)='part'">1</xsl:when>
736 <xsl:when test="local-name($node)='reference'">1</xsl:when>
737 <xsl:when test="local-name($node)='refentry'">1</xsl:when>
738 <xsl:when test="local-name($node)='index' and ($generate.index != 0 or count($node/*) > 0) and (local-name($node/parent::*) = 'article' or local-name($node/parent::*) = 'book' or local-name($node/parent::*) = 'part' )">1</xsl:when>
739 <xsl:when test="local-name($node)='bibliography' and (local-name($node/parent::*) = 'article' or local-name($node/parent::*) = 'book' or local-name($node/parent::*) = 'part' )">1</xsl:when>
740 <xsl:when test="local-name($node)='glossary' and (local-name($node/parent::*) = 'article' or local-name($node/parent::*) = 'book' or local-name($node/parent::*) = 'part' )">1</xsl:when>
741 <xsl:when test="local-name($node)='colophon'">1</xsl:when>
742 <xsl:when test="local-name($node)='book'">1</xsl:when>
743 <xsl:when test="local-name($node)='set'">1</xsl:when>
744 <xsl:when test="local-name($node)='setindex'">1</xsl:when>
745 <xsl:when test="local-name($node)='legalnotice' and $generate.legalnotice.link != 0">1</xsl:when>
746 <xsl:otherwise>0</xsl:otherwise>
750 <!-- ==================================================================== -->
751 <xsl:template name="href.target.uri">
752 <xsl:param name="object" select="."/>
753 <xsl:variable name="ischunk">
754 <xsl:call-template name="chunk">
755 <xsl:with-param name="node" select="$object"/>
759 <xsl:apply-templates mode="chunk-filename" select="$object"/>
761 <xsl:if test="$ischunk='0'">
762 <xsl:text>#</xsl:text>
763 <xsl:call-template name="object.id">
764 <xsl:with-param name="object" select="$object"/>
769 <xsl:template name="href.target">
770 <xsl:param name="context" select="."/>
771 <xsl:param name="object" select="."/>
772 <xsl:param name="toc-context" select="."/>
773 <!-- * If $toc-context contains some node other than the current node, -->
774 <!-- * it means we're processing a link in a TOC. In that case, to -->
775 <!-- * ensure the link will work correctly, we need to take a look at -->
776 <!-- * where the file containing the TOC will get written, and where -->
777 <!-- * the file that's being linked to will get written. -->
778 <xsl:variable name="toc-output-dir">
779 <xsl:if test="not($toc-context = .)">
780 <!-- * Get the $toc-context node and all its ancestors, look down -->
781 <!-- * through them to find the last/closest node to the -->
782 <!-- * toc-context node that has a "dbhtml dir" PI, and get the -->
783 <!-- * directory name from that. That's the name of the directory -->
784 <!-- * to which the current toc output file will get written. -->
785 <xsl:call-template name="dbhtml-dir">
786 <xsl:with-param name="context" select="$toc-context/ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
790 <xsl:variable name="linked-file-output-dir">
791 <xsl:if test="not($toc-context = .)">
792 <!-- * Get the current node and all its ancestors, look down -->
793 <!-- * through them to find the last/closest node to the current -->
794 <!-- * node that has a "dbhtml dir" PI, and get the directory name -->
795 <!-- * from that. That's the name of the directory to which the -->
796 <!-- * file that's being linked to will get written. -->
797 <xsl:call-template name="dbhtml-dir">
798 <xsl:with-param name="context" select="ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
802 <xsl:variable name="href.to.uri">
803 <xsl:call-template name="href.target.uri">
804 <xsl:with-param name="object" select="$object"/>
807 <xsl:variable name="href.from.uri">
809 <xsl:when test="not($toc-context = .)">
810 <xsl:call-template name="href.target.uri">
811 <xsl:with-param name="object" select="$toc-context"/>
815 <xsl:call-template name="href.target.uri">
816 <xsl:with-param name="object" select="$context"/>
821 <!-- * <xsl:message>toc-context: <xsl:value-of select="local-name($toc-context)"/></xsl:message> -->
822 <!-- * <xsl:message>node: <xsl:value-of select="local-name(.)"/></xsl:message> -->
823 <!-- * <xsl:message>context: <xsl:value-of select="local-name($context)"/></xsl:message> -->
824 <!-- * <xsl:message>object: <xsl:value-of select="local-name($object)"/></xsl:message> -->
825 <!-- * <xsl:message>toc-output-dir: <xsl:value-of select="$toc-output-dir"/></xsl:message> -->
826 <!-- * <xsl:message>linked-file-output-dir: <xsl:value-of select="$linked-file-output-dir"/></xsl:message> -->
827 <!-- * <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> -->
828 <!-- * <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> -->
829 <xsl:variable name="href.to">
831 <!-- * 2007-07-19, MikeSmith: Added the following conditional to -->
832 <!-- * deal with a problem case for links in TOCs. It checks to see -->
833 <!-- * if the output dir that a TOC will get written to is -->
834 <!-- * different from the output dir of the file being linked to. -->
835 <!-- * If it is different, we do not call trim.common.uri.paths. -->
837 <!-- * Reason why I added that conditional is: I ran into a bug for -->
838 <!-- * this case: -->
840 <!-- * 1. we are chunking into separate dirs -->
842 <!-- * 2. output for the TOC is written to current dir, but the file -->
843 <!-- * being linked to is written to some subdir "foo". -->
845 <!-- * For that case, links to that file in that TOC did not show -->
846 <!-- * the correct path - they omitted the "foo". -->
848 <!-- * The cause of that problem was that the trim.common.uri.paths -->
849 <!-- * template[1] was being called under all conditions. But it's -->
850 <!-- * apparent that we don't want to call trim.common.uri.paths in -->
851 <!-- * the case where a linked file is being written to a different -->
852 <!-- * directory than the TOC that contains the link, because doing -->
853 <!-- * so will cause a necessary (not redundant) directory-name -->
854 <!-- * part of the link to get inadvertently trimmed, resulting in -->
855 <!-- * a broken link to that file. Thus, added the conditional. -->
857 <!-- * [1] The purpose of the trim.common.uri.paths template is to -->
858 <!-- * prevent cases where, if we didn't call it, we end up with -->
859 <!-- * unnecessary, redundant directory names getting output; for -->
860 <!-- * example, "foo/foo/refname.html". -->
861 <xsl:when test="not($toc-output-dir = $linked-file-output-dir)">
862 <xsl:value-of select="$href.to.uri"/>
865 <xsl:call-template name="trim.common.uri.paths">
866 <xsl:with-param name="uriA" select="$href.to.uri"/>
867 <xsl:with-param name="uriB" select="$href.from.uri"/>
868 <xsl:with-param name="return" select="'A'"/>
873 <xsl:variable name="href.from">
874 <xsl:call-template name="trim.common.uri.paths">
875 <xsl:with-param name="uriA" select="$href.to.uri"/>
876 <xsl:with-param name="uriB" select="$href.from.uri"/>
877 <xsl:with-param name="return" select="'B'"/>
880 <xsl:variable name="depth">
881 <xsl:call-template name="count.uri.path.depth">
882 <xsl:with-param name="filename" select="$href.from"/>
885 <xsl:variable name="href">
886 <xsl:call-template name="copy-string">
887 <xsl:with-param name="string" select="'../'"/>
888 <xsl:with-param name="count" select="$depth"/>
890 <xsl:value-of select="$href.to"/>
894 <xsl:text>In </xsl:text>
895 <xsl:value-of select="name(.)"/>
896 <xsl:text> (</xsl:text>
897 <xsl:value-of select="$href.from"/>
898 <xsl:text>,</xsl:text>
899 <xsl:value-of select="$depth"/>
900 <xsl:text>) </xsl:text>
901 <xsl:value-of select="name($object)"/>
902 <xsl:text> href=</xsl:text>
903 <xsl:value-of select="$href"/>
906 <xsl:value-of select="$href"/>
909 <!-- Returns the complete olink href value if found -->
910 <!-- Must take into account any dbhtml dir of the chunk containing the olink -->
911 <xsl:template name="make.olink.href">
912 <xsl:param name="olink.key" select="''"/>
913 <xsl:param name="target.database"/>
915 <xsl:if test="$olink.key != ''">
916 <xsl:variable name="target.href">
917 <xsl:for-each select="$target.database">
918 <xsl:value-of select="key('targetptr-key', $olink.key)[1]/@href"/>
922 <!-- an olink starting point may be in a subdirectory, so need
923 the "from" reference point to compute a relative path -->
925 <xsl:variable name="from.href">
926 <xsl:call-template name="olink.from.uri">
927 <xsl:with-param name="target.database" select="$target.database"/>
928 <xsl:with-param name="object" select="."/>
929 <xsl:with-param name="object.targetdoc" select="$current.docid"/>
933 <!-- If the from.href has directory path, then must "../" upward
934 to document level -->
935 <xsl:variable name="upward.from.path">
936 <xsl:call-template name="upward.path">
937 <xsl:with-param name="path" select="$from.href"/>
941 <xsl:variable name="targetdoc">
942 <xsl:value-of select="substring-before($olink.key, '/')"/>
945 <!-- Does the target database use a sitemap? -->
946 <xsl:variable name="use.sitemap">
948 <xsl:when test="$target.database//sitemap">1</xsl:when>
949 <xsl:otherwise>0</xsl:otherwise>
954 <!-- Get the baseuri for this targetptr -->
955 <xsl:variable name="baseuri">
957 <!-- Does the database use a sitemap? -->
958 <xsl:when test="$use.sitemap != 0">
960 <!-- Was current.docid parameter set? -->
961 <xsl:when test="$current.docid != ''">
962 <!-- Was it found in the database? -->
963 <xsl:variable name="currentdoc.key">
964 <xsl:for-each select="$target.database">
965 <xsl:value-of select="key('targetdoc-key', $current.docid)[1]/@targetdoc"/>
969 <xsl:when test="$currentdoc.key != ''">
970 <xsl:for-each select="$target.database">
971 <xsl:call-template name="targetpath">
972 <xsl:with-param name="dirnode" select="key('targetdoc-key', $current.docid)[1]/parent::dir"/>
973 <xsl:with-param name="targetdoc" select="$targetdoc"/>
978 <xsl:call-template name="olink.error">
979 <xsl:with-param name="message">
980 <xsl:text>cannot compute relative </xsl:text>
981 <xsl:text>sitemap path because $current.docid '</xsl:text>
982 <xsl:value-of select="$current.docid"/>
983 <xsl:text>' not found in target database.</xsl:text>
990 <xsl:call-template name="olink.error">
991 <xsl:with-param name="message">
992 <xsl:text>cannot compute relative </xsl:text>
993 <xsl:text>sitemap path without $current.docid parameter</xsl:text>
998 <!-- In either case, add baseuri from its document entry-->
999 <xsl:variable name="docbaseuri">
1000 <xsl:for-each select="$target.database">
1001 <xsl:value-of select="key('targetdoc-key', $targetdoc)[1]/@baseuri"/>
1004 <xsl:if test="$docbaseuri != ''">
1005 <xsl:value-of select="$docbaseuri"/>
1008 <!-- No database sitemap in use -->
1010 <!-- Just use any baseuri from its document entry -->
1011 <xsl:variable name="docbaseuri">
1012 <xsl:for-each select="$target.database">
1013 <xsl:value-of select="key('targetdoc-key', $targetdoc)[1]/@baseuri"/>
1016 <xsl:if test="$docbaseuri != ''">
1017 <xsl:value-of select="$docbaseuri"/>
1023 <!-- Is this olink to be active? -->
1024 <xsl:variable name="active.olink">
1026 <xsl:when test="$activate.external.olinks = 0">
1028 <xsl:when test="$current.docid = ''">1</xsl:when>
1029 <xsl:when test="$targetdoc = ''">1</xsl:when>
1030 <xsl:when test="$targetdoc = $current.docid">1</xsl:when>
1031 <xsl:otherwise>0</xsl:otherwise>
1034 <xsl:otherwise>1</xsl:otherwise>
1038 <xsl:if test="$active.olink != 0">
1039 <!-- Form the href information -->
1040 <xsl:if test="not(contains($baseuri, ':'))">
1041 <!-- if not an absolute uri, add upward path from olink chunk -->
1042 <xsl:value-of select="$upward.from.path"/>
1045 <xsl:if test="$baseuri != ''">
1046 <xsl:value-of select="$baseuri"/>
1047 <xsl:if test="substring($target.href,1,1) != '#'">
1048 <!--xsl:text>/</xsl:text-->
1051 <!-- optionally turn off frag for PDF references -->
1052 <xsl:if test="not($insert.olink.pdf.frag = 0 and translate(substring($baseuri, string-length($baseuri) - 3), 'PDF', 'pdf') = '.pdf' and starts-with($target.href, '#') )">
1053 <xsl:value-of select="$target.href"/>
1059 <!-- Computes "../" to reach top -->
1060 <xsl:template name="upward.path">
1061 <xsl:param name="path" select="''"/>
1063 <!-- Don't bother with absolute uris -->
1064 <xsl:when test="contains($path, ':')"/>
1065 <xsl:when test="starts-with($path, '/')"/>
1066 <xsl:when test="contains($path, '/')">
1067 <xsl:text>../</xsl:text>
1068 <xsl:call-template name="upward.path">
1069 <xsl:with-param name="path" select="substring-after($path, '/')"/>
1070 </xsl:call-template>
1076 <!-- ==================================================================== -->
1078 <xsl:template name="html.head">
1079 <xsl:param name="prev" select="/foo"/>
1080 <xsl:param name="next" select="/foo"/>
1081 <xsl:variable name="this" select="."/>
1082 <xsl:variable name="home" select="/*[1]"/>
1083 <xsl:variable name="up" select="parent::*"/>
1086 <xsl:call-template name="system.head.content"/>
1087 <xsl:call-template name="head.content"/>
1089 <!-- home link not valid in HTML5 -->
1090 <xsl:if test="$home and $div.element != 'section'">
1092 <xsl:attribute name="href">
1093 <xsl:call-template name="href.target">
1094 <xsl:with-param name="object" select="$home"/>
1095 </xsl:call-template>
1097 <xsl:attribute name="title">
1098 <xsl:apply-templates select="$home" mode="object.title.markup.textonly"/>
1103 <!-- up link not valid in HTML5 -->
1104 <xsl:if test="$up and $div.element != 'section'">
1106 <xsl:attribute name="href">
1107 <xsl:call-template name="href.target">
1108 <xsl:with-param name="object" select="$up"/>
1109 </xsl:call-template>
1111 <xsl:attribute name="title">
1112 <xsl:apply-templates select="$up" mode="object.title.markup.textonly"/>
1117 <xsl:if test="$prev">
1119 <xsl:attribute name="href">
1120 <xsl:call-template name="href.target">
1121 <xsl:with-param name="object" select="$prev"/>
1122 </xsl:call-template>
1124 <xsl:attribute name="title">
1125 <xsl:apply-templates select="$prev" mode="object.title.markup.textonly"/>
1130 <xsl:if test="$next">
1132 <xsl:attribute name="href">
1133 <xsl:call-template name="href.target">
1134 <xsl:with-param name="object" select="$next"/>
1135 </xsl:call-template>
1137 <xsl:attribute name="title">
1138 <xsl:apply-templates select="$next" mode="object.title.markup.textonly"/>
1143 <xsl:if test="$html.extra.head.links != 0">
1144 <xsl:for-each select="//part |//reference |//preface |//chapter |//article |//refentry |//appendix[not(parent::article)]|appendix |//glossary[not(parent::article)]|glossary |//index[not(parent::article)]|index">
1145 <link rel="{local-name(.)}">
1146 <xsl:attribute name="href">
1147 <xsl:call-template name="href.target">
1148 <xsl:with-param name="context" select="$this"/>
1149 <xsl:with-param name="object" select="."/>
1150 </xsl:call-template>
1152 <xsl:attribute name="title">
1153 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1158 <xsl:for-each select="section|sect1|refsection|refsect1">
1160 <xsl:attribute name="rel">
1162 <xsl:when test="local-name($this) = 'section' or local-name($this) = 'refsection'">
1163 <xsl:value-of select="'subsection'"/>
1166 <xsl:value-of select="'section'"/>
1170 <xsl:attribute name="href">
1171 <xsl:call-template name="href.target">
1172 <xsl:with-param name="context" select="$this"/>
1173 <xsl:with-param name="object" select="."/>
1174 </xsl:call-template>
1176 <xsl:attribute name="title">
1177 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1182 <xsl:for-each select="sect2|sect3|sect4|sect5|refsect2|refsect3">
1183 <link rel="subsection">
1184 <xsl:attribute name="href">
1185 <xsl:call-template name="href.target">
1186 <xsl:with-param name="context" select="$this"/>
1187 <xsl:with-param name="object" select="."/>
1188 </xsl:call-template>
1190 <xsl:attribute name="title">
1191 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1197 <!-- * if we have a legalnotice and user wants it output as a -->
1198 <!-- * separate page and $html.head.legalnotice.link.types is -->
1199 <!-- * non-empty, we generate a link or links for each value in -->
1200 <!-- * $html.head.legalnotice.link.types -->
1201 <xsl:if test="//legalnotice and not($generate.legalnotice.link = 0) and not($html.head.legalnotice.link.types = '')">
1202 <xsl:call-template name="make.legalnotice.head.links"/>
1205 <xsl:call-template name="user.head.content"/>
1209 <!-- ==================================================================== -->
1211 <xsl:template name="header.navigation">
1212 <xsl:param name="prev" select="/foo"/>
1213 <xsl:param name="next" select="/foo"/>
1214 <xsl:param name="nav.context"/>
1216 <xsl:variable name="home" select="/*[1]"/>
1217 <xsl:variable name="up" select="parent::*"/>
1219 <xsl:variable name="row1" select="$navig.showtitles != 0"/>
1220 <xsl:variable name="row2" select="count($prev) > 0 or (count($up) > 0 and generate-id($up) != generate-id($home) and $navig.showtitles != 0) or count($next) > 0"/>
1222 <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'">
1223 <div class="navheader">
1224 <xsl:if test="$row1 or $row2">
1225 <table width="100%" summary="Navigation header">
1226 <xsl:if test="$row1">
1228 <th colspan="3" align="center">
1229 <xsl:apply-templates select="." mode="object.title.markup"/>
1234 <xsl:if test="$row2">
1236 <td width="20%" align="{$direction.align.start}">
1237 <xsl:if test="count($prev)>0">
1239 <xsl:attribute name="href">
1240 <xsl:call-template name="href.target">
1241 <xsl:with-param name="object" select="$prev"/>
1242 </xsl:call-template>
1244 <xsl:call-template name="navig.content">
1245 <xsl:with-param name="direction" select="'prev'"/>
1246 </xsl:call-template>
1249 <xsl:text> </xsl:text>
1251 <th width="60%" align="center">
1253 <xsl:when test="count($up) > 0 and generate-id($up) != generate-id($home) and $navig.showtitles != 0">
1254 <xsl:apply-templates select="$up" mode="object.title.markup"/>
1256 <xsl:otherwise> </xsl:otherwise>
1259 <td width="20%" align="{$direction.align.end}">
1260 <xsl:text> </xsl:text>
1261 <xsl:if test="count($next)>0">
1263 <xsl:attribute name="href">
1264 <xsl:call-template name="href.target">
1265 <xsl:with-param name="object" select="$next"/>
1266 </xsl:call-template>
1268 <xsl:call-template name="navig.content">
1269 <xsl:with-param name="direction" select="'next'"/>
1270 </xsl:call-template>
1278 <xsl:if test="$header.rule != 0">
1285 <!-- ==================================================================== -->
1287 <xsl:template name="footer.navigation">
1288 <xsl:param name="prev" select="/foo"/>
1289 <xsl:param name="next" select="/foo"/>
1290 <xsl:param name="nav.context"/>
1292 <xsl:variable name="home" select="/*[1]"/>
1293 <xsl:variable name="up" select="parent::*"/>
1295 <xsl:variable name="row1" select="count($prev) > 0 or count($up) > 0 or count($next) > 0"/>
1297 <xsl:variable name="row2" select="($prev and $navig.showtitles != 0) or (generate-id($home) != generate-id(.) or $nav.context = 'toc') or ($chunk.tocs.and.lots != 0 and $nav.context != 'toc') or ($next and $navig.showtitles != 0)"/>
1299 <xsl:if test="$suppress.navigation = '0' and $suppress.footer.navigation = '0'">
1300 <div class="navfooter">
1301 <xsl:if test="$footer.rule != 0">
1305 <xsl:if test="$row1 or $row2">
1306 <table width="100%" summary="Navigation footer">
1307 <xsl:if test="$row1">
1309 <td width="40%" align="{$direction.align.start}">
1310 <xsl:if test="count($prev)>0">
1312 <xsl:attribute name="href">
1313 <xsl:call-template name="href.target">
1314 <xsl:with-param name="object" select="$prev"/>
1315 </xsl:call-template>
1317 <xsl:call-template name="navig.content">
1318 <xsl:with-param name="direction" select="'prev'"/>
1319 </xsl:call-template>
1322 <xsl:text> </xsl:text>
1324 <td width="20%" align="center">
1326 <xsl:when test="count($up)>0 and generate-id($up) != generate-id($home)">
1328 <xsl:attribute name="href">
1329 <xsl:call-template name="href.target">
1330 <xsl:with-param name="object" select="$up"/>
1331 </xsl:call-template>
1333 <xsl:call-template name="navig.content">
1334 <xsl:with-param name="direction" select="'up'"/>
1335 </xsl:call-template>
1338 <xsl:otherwise> </xsl:otherwise>
1341 <td width="40%" align="{$direction.align.end}">
1342 <xsl:text> </xsl:text>
1343 <xsl:if test="count($next)>0">
1345 <xsl:attribute name="href">
1346 <xsl:call-template name="href.target">
1347 <xsl:with-param name="object" select="$next"/>
1348 </xsl:call-template>
1350 <xsl:call-template name="navig.content">
1351 <xsl:with-param name="direction" select="'next'"/>
1352 </xsl:call-template>
1359 <xsl:if test="$row2">
1361 <td width="40%" align="{$direction.align.start}" valign="top">
1362 <xsl:if test="$navig.showtitles != 0">
1363 <xsl:apply-templates select="$prev" mode="object.title.markup"/>
1365 <xsl:text> </xsl:text>
1367 <td width="20%" align="center">
1369 <xsl:when test="$home != . or $nav.context = 'toc'">
1371 <xsl:attribute name="href">
1372 <xsl:call-template name="href.target">
1373 <xsl:with-param name="object" select="$home"/>
1374 </xsl:call-template>
1376 <xsl:call-template name="navig.content">
1377 <xsl:with-param name="direction" select="'home'"/>
1378 </xsl:call-template>
1380 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1381 <xsl:text> | </xsl:text>
1384 <xsl:otherwise> </xsl:otherwise>
1387 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1389 <xsl:attribute name="href">
1390 <xsl:value-of select="$chunked.filename.prefix"/>
1391 <xsl:apply-templates select="/*[1]" mode="recursive-chunk-filename">
1392 <xsl:with-param name="recursive" select="true()"/>
1393 </xsl:apply-templates>
1394 <xsl:text>-toc</xsl:text>
1395 <xsl:value-of select="$html.ext"/>
1397 <xsl:call-template name="gentext">
1398 <xsl:with-param name="key" select="'nav-toc'"/>
1399 </xsl:call-template>
1403 <td width="40%" align="{$direction.align.end}" valign="top">
1404 <xsl:text> </xsl:text>
1405 <xsl:if test="$navig.showtitles != 0">
1406 <xsl:apply-templates select="$next" mode="object.title.markup"/>
1417 <!-- ==================================================================== -->
1419 <xsl:template name="navig.content">
1420 <xsl:param name="direction" select="next"/>
1421 <xsl:variable name="navtext">
1423 <xsl:when test="$direction = 'prev'">
1424 <xsl:call-template name="gentext.nav.prev"/>
1426 <xsl:when test="$direction = 'next'">
1427 <xsl:call-template name="gentext.nav.next"/>
1429 <xsl:when test="$direction = 'up'">
1430 <xsl:call-template name="gentext.nav.up"/>
1432 <xsl:when test="$direction = 'home'">
1433 <xsl:call-template name="gentext.nav.home"/>
1436 <xsl:text>xxx</xsl:text>
1442 <xsl:when test="$navig.graphics != 0">
1444 <xsl:attribute name="src">
1445 <xsl:value-of select="$navig.graphics.path"/>
1446 <xsl:value-of select="$direction"/>
1447 <xsl:value-of select="$navig.graphics.extension"/>
1449 <xsl:attribute name="alt">
1450 <xsl:value-of select="$navtext"/>
1455 <xsl:value-of select="$navtext"/>
1460 <!-- ==================================================================== -->
1462 <!-- * The following template assumes that the first legalnotice -->
1463 <!-- * instance found in a document applies to the contents of the -->
1464 <!-- * entire document. It generates an HTML link in each chunk, back -->
1465 <!-- * to the file containing the contents of the first legalnotice. -->
1467 <!-- * Actually, it may generate multiple link instances in each chunk, -->
1468 <!-- * because it walks through the space-separated list of link -->
1469 <!-- * types specified in the $html.head.legalnotice.link.types param, -->
1470 <!-- * popping off link types and generating links for them until it -->
1471 <!-- * depletes the list. -->
1473 <xsl:template name="make.legalnotice.head.links">
1474 <!-- * the following ID is used as part of the legalnotice filename; -->
1475 <!-- * we need it in order to construct the filename for use in the -->
1476 <!-- * value of the href attribute on the link -->
1478 <xsl:param name="ln-node" select="(//legalnotice)[1]"/>
1480 <xsl:param name="linktype">
1482 <xsl:when test="contains($html.head.legalnotice.link.types, ' ')">
1483 <xsl:value-of select="normalize-space( substring-before($html.head.legalnotice.link.types, ' '))"/>
1486 <xsl:value-of select="$html.head.legalnotice.link.types"/>
1490 <xsl:param name="remaining.linktypes" select="concat( normalize-space( substring-after($html.head.legalnotice.link.types, ' ')),' ')"/>
1491 <xsl:if test="not($linktype = '')">
1493 <!-- Compute name of legalnotice file (see titlepage.xsl) -->
1494 <xsl:variable name="file">
1495 <xsl:call-template name="ln.or.rh.filename">
1496 <xsl:with-param name="node" select="$ln-node"/>
1497 </xsl:call-template>
1500 <link rel="{$linktype}">
1501 <xsl:attribute name="href">
1502 <xsl:value-of select="$file"/>
1504 <xsl:attribute name="title">
1505 <xsl:apply-templates select="(//legalnotice)[1]" mode="object.title.markup.textonly"/>
1508 <xsl:call-template name="make.legalnotice.head.links">
1509 <!-- * pop the next value off the list of link types -->
1510 <xsl:with-param name="linktype" select="substring-before($remaining.linktypes, ' ')"/>
1511 <!-- * remove the link type from the list of remaining link types -->
1512 <xsl:with-param name="remaining.linktypes" select="substring-after($remaining.linktypes, ' ')"/>
1513 </xsl:call-template>
1517 <!-- ==================================================================== -->
1518 <xsl:template name="chunk-element-content">
1519 <xsl:param name="prev"/>
1520 <xsl:param name="next"/>
1521 <xsl:param name="nav.context"/>
1522 <xsl:param name="content">
1523 <xsl:apply-imports/>
1526 <xsl:call-template name="user.preroot"/>
1529 <xsl:call-template name="root.attributes"/>
1530 <xsl:call-template name="html.head">
1531 <xsl:with-param name="prev" select="$prev"/>
1532 <xsl:with-param name="next" select="$next"/>
1533 </xsl:call-template>
1536 <xsl:call-template name="body.attributes"/>
1538 <xsl:call-template name="user.header.navigation">
1539 <xsl:with-param name="prev" select="$prev"/>
1540 <xsl:with-param name="next" select="$next"/>
1541 <xsl:with-param name="nav.context" select="$nav.context"/>
1542 </xsl:call-template>
1544 <xsl:call-template name="header.navigation">
1545 <xsl:with-param name="prev" select="$prev"/>
1546 <xsl:with-param name="next" select="$next"/>
1547 <xsl:with-param name="nav.context" select="$nav.context"/>
1548 </xsl:call-template>
1550 <xsl:call-template name="user.header.content"/>
1552 <xsl:copy-of select="$content"/>
1554 <xsl:call-template name="user.footer.content"/>
1556 <xsl:call-template name="footer.navigation">
1557 <xsl:with-param name="prev" select="$prev"/>
1558 <xsl:with-param name="next" select="$next"/>
1559 <xsl:with-param name="nav.context" select="$nav.context"/>
1560 </xsl:call-template>
1562 <xsl:call-template name="user.footer.navigation">
1563 <xsl:with-param name="prev" select="$prev"/>
1564 <xsl:with-param name="next" select="$next"/>
1565 <xsl:with-param name="nav.context" select="$nav.context"/>
1566 </xsl:call-template>
1569 <xsl:value-of select="$chunk.append"/>
1572 <!-- ==================================================================== -->
1573 <xsl:template name="generate.manifest">
1574 <xsl:param name="node" select="/"/>
1575 <xsl:call-template name="write.text.chunk">
1576 <xsl:with-param name="filename">
1577 <xsl:if test="$manifest.in.base.dir != 0">
1578 <xsl:value-of select="$chunk.base.dir"/>
1580 <xsl:value-of select="$manifest"/>
1582 <xsl:with-param name="method" select="'text'"/>
1583 <xsl:with-param name="content">
1584 <xsl:apply-templates select="$node" mode="enumerate-files"/>
1586 <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
1587 </xsl:call-template>
1590 <!-- ==================================================================== -->
1592 <xsl:template name="dbhtml-dir">
1593 <xsl:param name="context" select="."/>
1594 <!-- directories are now inherited from previous levels -->
1595 <xsl:variable name="ppath">
1596 <xsl:if test="$context/parent::*">
1597 <xsl:call-template name="dbhtml-dir">
1598 <xsl:with-param name="context" select="$context/parent::*"/>
1599 </xsl:call-template>
1602 <xsl:variable name="path">
1603 <xsl:call-template name="pi.dbhtml_dir">
1604 <xsl:with-param name="node" select="$context"/>
1605 </xsl:call-template>
1608 <xsl:when test="$path = ''">
1609 <xsl:if test="$ppath != ''">
1610 <xsl:value-of select="$ppath"/>
1614 <xsl:if test="$ppath != ''">
1615 <xsl:value-of select="$ppath"/>
1616 <xsl:if test="substring($ppath, string-length($ppath), 1) != '/'">
1617 <xsl:text>/</xsl:text>
1620 <xsl:value-of select="$path"/>
1621 <xsl:text>/</xsl:text>