1 <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" 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 d">
3 <!-- ********************************************************************
5 This file is part of the XSL DocBook Stylesheet distribution.
6 See ../README or http://cdn.docbook.org/release/xsl/current/ for
7 copyright and other information.
9 ******************************************************************** -->
11 <!-- ==================================================================== -->
13 <xsl:param name="onechunk" select="0"/>
14 <xsl:param name="refentry.separator" select="0"/>
15 <xsl:param name="chunk.fast" select="0"/>
17 <xsl:key name="genid" match="*" use="generate-id()"/>
19 <!-- ==================================================================== -->
21 <xsl:variable name="chunk.hierarchy">
22 <xsl:if test="$chunk.fast != 0">
24 <!-- Do we need to fix namespace? -->
25 <xsl:when test="$exsl.node.set.available != 0 and namespace-uri(/*) != 'http://docbook.org/ns/docbook'">
26 <xsl:if test="$chunk.quietly = 0">
27 <xsl:message>Computing chunks...</xsl:message>
29 <xsl:apply-templates mode="find.chunks" select="exsl:node-set($with.namespace)"/>
31 <xsl:when test="$exsl.node.set.available != 0">
32 <xsl:if test="$chunk.quietly = 0">
33 <xsl:message>Computing chunks...</xsl:message>
35 <xsl:apply-templates select="/*" mode="find.chunks"/>
38 <xsl:if test="$chunk.quietly = 0">
40 <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
41 <xsl:text>Using "slow" chunking.</xsl:text>
49 <!-- ==================================================================== -->
51 <xsl:template name="process-chunk-element">
52 <xsl:param name="content">
57 <xsl:when test="$chunk.fast != 0 and $exsl.node.set.available != 0">
58 <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
59 <xsl:variable name="genid" select="generate-id()"/>
61 <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
63 <xsl:variable name="prevdiv" select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
64 <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
66 <xsl:variable name="nextdiv" select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
67 <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
70 <xsl:when test="$onechunk != 0 and parent::*">
71 <xsl:copy-of select="$content"/>
74 <xsl:call-template name="process-chunk">
75 <xsl:with-param name="prev" select="$prev"/>
76 <xsl:with-param name="next" select="$next"/>
77 <xsl:with-param name="content" select="$content"/>
84 <xsl:when test="$onechunk != 0 and not(parent::*)">
85 <xsl:call-template name="chunk-all-sections">
86 <xsl:with-param name="content" select="$content"/>
89 <xsl:when test="$onechunk != 0">
90 <xsl:copy-of select="$content"/>
92 <xsl:when test="$chunk.first.sections = 0">
93 <xsl:call-template name="chunk-first-section-with-parent">
94 <xsl:with-param name="content" select="$content"/>
98 <xsl:call-template name="chunk-all-sections">
99 <xsl:with-param name="content" select="$content"/>
107 <xsl:template name="process-chunk">
108 <xsl:param name="prev" select="."/>
109 <xsl:param name="next" select="."/>
110 <xsl:param name="content">
114 <xsl:variable name="ischunk">
115 <xsl:call-template name="chunk"/>
118 <xsl:variable name="chunkfn">
119 <xsl:if test="$ischunk='1'">
120 <xsl:apply-templates mode="chunk-filename" select="."/>
124 <xsl:if test="$ischunk='0'">
126 <xsl:text>Error </xsl:text>
127 <xsl:value-of select="name(.)"/>
128 <xsl:text> is not a chunk!</xsl:text>
132 <xsl:variable name="filename">
133 <xsl:call-template name="make-relative-filename">
134 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
135 <xsl:with-param name="base.name" select="$chunkfn"/>
139 <xsl:call-template name="write.chunk">
140 <xsl:with-param name="filename" select="$filename"/>
141 <xsl:with-param name="content">
142 <xsl:call-template name="chunk-element-content">
143 <xsl:with-param name="prev" select="$prev"/>
144 <xsl:with-param name="next" select="$next"/>
145 <xsl:with-param name="content" select="$content"/>
148 <xsl:with-param name="quiet" select="$chunk.quietly"/>
152 <xsl:template name="chunk-first-section-with-parent">
153 <xsl:param name="content">
157 <!-- These xpath expressions are really hairy. The trick is to pick sections -->
158 <!-- that are not first children and are not the children of first children -->
160 <!-- Break these variables into pieces to work around
161 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
163 <xsl:variable name="prev-v1" select="(ancestor::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect1][1] |ancestor::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect2 and parent::d:sect1[preceding-sibling::d:sect1]][1] |ancestor::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect3 and parent::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |ancestor::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect4 and parent::d:sect3[preceding-sibling::d:sect3] and ancestor::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |ancestor::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect5 and parent::d:sect4[preceding-sibling::d:sect4] and ancestor::d:sect3[preceding-sibling::d:sect3] and ancestor::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |ancestor::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and not(ancestor::d:section[not(preceding-sibling::d:section)])][1])[last()]"/>
165 <xsl:variable name="prev-v2" select="(preceding::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect1][1] |preceding::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect2 and parent::d:sect1[preceding-sibling::d:sect1]][1] |preceding::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect3 and parent::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |preceding::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect4 and parent::d:sect3[preceding-sibling::d:sect3] and ancestor::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |preceding::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect5 and parent::d:sect4[preceding-sibling::d:sect4] and ancestor::d:sect3[preceding-sibling::d:sect3] and ancestor::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |preceding::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:section and not(ancestor::d:section[not(preceding-sibling::d:section)])][1])[last()]"/>
167 <xsl:variable name="prev" select="(preceding::d:book[1] |preceding::d:preface[1] |preceding::d:chapter[1] |preceding::d:appendix[1] |preceding::d:part[1] |preceding::d:reference[1] |preceding::d:refentry[1] |preceding::d:colophon[1] |preceding::d:article[1] |preceding::d:topic[1] |preceding::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1] |preceding::d:glossary[parent::d:article or parent::d:book or parent::d:part][1] |preceding::d:index[$generate.index != 0] [parent::d:article or parent::d:book or parent::d:part][1] |preceding::d:setindex[$generate.index != 0][1] |ancestor::d:set |ancestor::d:book[1] |ancestor::d:preface[1] |ancestor::d:chapter[1] |ancestor::d:appendix[1] |ancestor::d:part[1] |ancestor::d:reference[1] |ancestor::d:article[1] |ancestor::d:topic[1] |$prev-v1 |$prev-v2)[last()]"/>
169 <xsl:variable name="next-v1" select="(following::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect1][1] |following::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect2 and parent::d:sect1[preceding-sibling::d:sect1]][1] |following::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect3 and parent::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |following::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect4 and parent::d:sect3[preceding-sibling::d:sect3] and ancestor::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |following::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect5 and parent::d:sect4[preceding-sibling::d:sect4] and ancestor::d:sect3[preceding-sibling::d:sect3] and ancestor::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |following::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:section and not(ancestor::d:section[not(preceding-sibling::d:section)])][1])[1]"/>
171 <xsl:variable name="next-v2" select="(descendant::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect1][1] |descendant::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect2 and parent::d:sect1[preceding-sibling::d:sect1]][1] |descendant::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect3 and parent::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |descendant::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect4 and parent::d:sect3[preceding-sibling::d:sect3] and ancestor::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |descendant::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:sect5 and parent::d:sect4[preceding-sibling::d:sect4] and ancestor::d:sect3[preceding-sibling::d:sect3] and ancestor::d:sect2[preceding-sibling::d:sect2] and ancestor::d:sect1[preceding-sibling::d:sect1]][1] |descendant::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking']) and preceding-sibling::d:section and not(ancestor::d:section[not(preceding-sibling::d:section)])])[1]"/>
173 <xsl:variable name="next" select="(following::d:book[1] |following::d:preface[1] |following::d:chapter[1] |following::d:appendix[1] |following::d:part[1] |following::d:reference[1] |following::d:refentry[1] |following::d:colophon[1] |following::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1] |following::d:glossary[parent::d:article or parent::d:book or parent::d:part][1] |following::d:index[$generate.index != 0] [parent::d:article or parent::d:book or parent::d:part][1] |following::d:article[1] |following::d:topic[1] |following::d:setindex[$generate.index != 0][1] |descendant::d:book[1] |descendant::d:preface[1] |descendant::d:chapter[1] |descendant::d:appendix[1] |descendant::d:article[1] |descendant::d:topic[1] |descendant::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1] |descendant::d:glossary[parent::d:article or parent::d:book or parent::d:part][1] |descendant::d:index[$generate.index != 0] [parent::d:article or parent::d:book or parent::d:part][1] |descendant::d:colophon[1] |descendant::d:setindex[$generate.index != 0][1] |descendant::d:part[1] |descendant::d:reference[1] |descendant::d:refentry[1] |$next-v1 |$next-v2)[1]"/>
175 <xsl:call-template name="process-chunk">
176 <xsl:with-param name="prev" select="$prev"/>
177 <xsl:with-param name="next" select="$next"/>
178 <xsl:with-param name="content" select="$content"/>
182 <xsl:template name="chunk-all-sections">
183 <xsl:param name="content">
187 <xsl:variable name="prev-v1" select="(preceding::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |preceding::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
189 <xsl:variable name="prev-v2" select="(ancestor::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |ancestor::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[last()]"/>
191 <xsl:variable name="prev" select="(preceding::d:book[1] |preceding::d:preface[1] |preceding::d:chapter[1] |preceding::d:appendix[1] |preceding::d:part[1] |preceding::d:reference[1] |preceding::d:refentry[1] |preceding::d:colophon[1] |preceding::d:article[1] |preceding::d:topic[1] |preceding::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1] |preceding::d:glossary[parent::d:article or parent::d:book or parent::d:part][1] |preceding::d:index[$generate.index != 0] [parent::d:article or parent::d:book or parent::d:part][1] |preceding::d:setindex[$generate.index != 0][1] |ancestor::d:set |ancestor::d:book[1] |ancestor::d:preface[1] |ancestor::d:chapter[1] |ancestor::d:appendix[1] |ancestor::d:part[1] |ancestor::d:reference[1] |ancestor::d:article[1] |ancestor::d:topic[1] |$prev-v1 |$prev-v2)[last()]"/>
193 <xsl:variable name="next-v1" select="(following::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |following::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
195 <xsl:variable name="next-v2" select="(descendant::d:sect1[$chunk.section.depth > 0 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::d:sect2[$chunk.section.depth > 1 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::d:sect3[$chunk.section.depth > 2 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::d:sect4[$chunk.section.depth > 3 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::d:sect5[$chunk.section.depth > 4 and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1] |descendant::d:section[$chunk.section.depth > count(ancestor::d:section) and not(ancestor::*/processing-instruction('dbhtml')[normalize-space(.) ='stop-chunking'])][1])[1]"/>
197 <xsl:variable name="next" select="(following::d:book[1] |following::d:preface[1] |following::d:chapter[1] |following::d:appendix[1] |following::d:part[1] |following::d:reference[1] |following::d:refentry[1] |following::d:colophon[1] |following::d:bibliography[parent::d:article or parent::d:book or parent::d:part][1] |following::d:glossary[parent::d:article or parent::d:book or parent::d:part][1] |following::d:index[$generate.index != 0] [parent::d:article or parent::d:book][1] |following::d:article[1] |following::d:topic[1] |following::d:setindex[$generate.index != 0][1] |descendant::d:book[1] |descendant::d:preface[1] |descendant::d:chapter[1] |descendant::d:appendix[1] |descendant::d:article[1] |descendant::d:topic[1] |descendant::d:bibliography[parent::d:article or parent::d:book][1] |descendant::d:glossary[parent::d:article or parent::d:book or parent::d:part][1] |descendant::d:index[$generate.index != 0] [parent::d:article or parent::d:book][1] |descendant::d:colophon[1] |descendant::d:setindex[$generate.index != 0][1] |descendant::d:part[1] |descendant::d:reference[1] |descendant::d:refentry[1] |$next-v1 |$next-v2)[1]"/>
199 <xsl:call-template name="process-chunk">
200 <xsl:with-param name="prev" select="$prev"/>
201 <xsl:with-param name="next" select="$next"/>
202 <xsl:with-param name="content" select="$content"/>
206 <!-- ==================================================================== -->
208 <!-- ==================================================================== -->
210 <xsl:template name="make.lots">
211 <xsl:param name="toc.params" select="''"/>
212 <xsl:param name="toc"/>
214 <xsl:variable name="lots">
215 <xsl:if test="contains($toc.params, 'toc')">
216 <xsl:copy-of select="$toc"/>
219 <xsl:if test="contains($toc.params, 'figure')">
221 <xsl:when test="$chunk.separate.lots != '0'">
222 <xsl:call-template name="make.lot.chunk">
223 <xsl:with-param name="type" select="'figure'"/>
224 <xsl:with-param name="lot">
225 <xsl:call-template name="list.of.titles">
226 <xsl:with-param name="titles" select="'figure'"/>
227 <xsl:with-param name="nodes" select=".//d:figure"/>
233 <xsl:call-template name="list.of.titles">
234 <xsl:with-param name="titles" select="'figure'"/>
235 <xsl:with-param name="nodes" select=".//d:figure"/>
241 <xsl:if test="contains($toc.params, 'table')">
243 <xsl:when test="$chunk.separate.lots != '0'">
244 <xsl:call-template name="make.lot.chunk">
245 <xsl:with-param name="type" select="'table'"/>
246 <xsl:with-param name="lot">
247 <xsl:call-template name="list.of.titles">
248 <xsl:with-param name="titles" select="'table'"/>
249 <xsl:with-param name="nodes" select=".//d:table[not(@tocentry = 0)]"/>
255 <xsl:call-template name="list.of.titles">
256 <xsl:with-param name="titles" select="'table'"/>
257 <xsl:with-param name="nodes" select=".//d:table[not(@tocentry = 0)]"/>
263 <xsl:if test="contains($toc.params, 'example')">
265 <xsl:when test="$chunk.separate.lots != '0'">
266 <xsl:call-template name="make.lot.chunk">
267 <xsl:with-param name="type" select="'example'"/>
268 <xsl:with-param name="lot">
269 <xsl:call-template name="list.of.titles">
270 <xsl:with-param name="titles" select="'example'"/>
271 <xsl:with-param name="nodes" select=".//d:example"/>
277 <xsl:call-template name="list.of.titles">
278 <xsl:with-param name="titles" select="'example'"/>
279 <xsl:with-param name="nodes" select=".//d:example"/>
285 <xsl:if test="contains($toc.params, 'equation')">
287 <xsl:when test="$chunk.separate.lots != '0'">
288 <xsl:call-template name="make.lot.chunk">
289 <xsl:with-param name="type" select="'equation'"/>
290 <xsl:with-param name="lot">
291 <xsl:call-template name="list.of.titles">
292 <xsl:with-param name="titles" select="'equation'"/>
293 <xsl:with-param name="nodes" select=".//d:equation[d:title or d:info/d:title]"/>
299 <xsl:call-template name="list.of.titles">
300 <xsl:with-param name="titles" select="'equation'"/>
301 <xsl:with-param name="nodes" select=".//d:equation[d:title or d:info/d:title]"/>
307 <xsl:if test="contains($toc.params, 'procedure')">
309 <xsl:when test="$chunk.separate.lots != '0'">
310 <xsl:call-template name="make.lot.chunk">
311 <xsl:with-param name="type" select="'procedure'"/>
312 <xsl:with-param name="lot">
313 <xsl:call-template name="list.of.titles">
314 <xsl:with-param name="titles" select="'procedure'"/>
315 <xsl:with-param name="nodes" select=".//d:procedure[d:title]"/>
321 <xsl:call-template name="list.of.titles">
322 <xsl:with-param name="titles" select="'procedure'"/>
323 <xsl:with-param name="nodes" select=".//d:procedure[d:title]"/>
330 <xsl:if test="string($lots) != ''">
332 <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
333 <xsl:call-template name="write.chunk">
334 <xsl:with-param name="filename">
335 <xsl:call-template name="make-relative-filename">
336 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
337 <xsl:with-param name="base.name">
338 <xsl:call-template name="dbhtml-dir"/>
339 <xsl:value-of select="$chunked.filename.prefix"/>
340 <xsl:apply-templates select="." mode="recursive-chunk-filename">
341 <xsl:with-param name="recursive" select="true()"/>
342 </xsl:apply-templates>
343 <xsl:text>-toc</xsl:text>
344 <xsl:value-of select="$html.ext"/>
348 <xsl:with-param name="content">
349 <xsl:call-template name="chunk-element-content">
350 <xsl:with-param name="prev" select="/d:foo"/>
351 <xsl:with-param name="next" select="/d:foo"/>
352 <xsl:with-param name="nav.context" select="'toc'"/>
353 <xsl:with-param name="content">
354 <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
356 <xsl:apply-templates select="." mode="object.title.markup"/>
359 <xsl:copy-of select="$lots"/>
363 <xsl:with-param name="quiet" select="$chunk.quietly"/>
367 <xsl:copy-of select="$lots"/>
373 <xsl:template name="make.lot.chunk">
374 <xsl:param name="type" select="''"/>
375 <xsl:param name="lot"/>
377 <xsl:if test="string($lot) != ''">
378 <xsl:variable name="filename">
379 <xsl:call-template name="make-relative-filename">
380 <xsl:with-param name="base.dir" select="$chunk.base.dir"/>
381 <xsl:with-param name="base.name">
382 <xsl:call-template name="dbhtml-dir"/>
383 <xsl:value-of select="$type"/>
384 <xsl:text>-toc</xsl:text>
385 <xsl:value-of select="$html.ext"/>
390 <xsl:variable name="href">
391 <xsl:call-template name="make-relative-filename">
392 <xsl:with-param name="base.dir" select="''"/>
393 <xsl:with-param name="base.name">
394 <xsl:call-template name="dbhtml-dir"/>
395 <xsl:value-of select="$type"/>
396 <xsl:text>-toc</xsl:text>
397 <xsl:value-of select="$html.ext"/>
402 <xsl:call-template name="write.chunk">
403 <xsl:with-param name="filename" select="$filename"/>
404 <xsl:with-param name="content">
405 <xsl:call-template name="chunk-element-content">
406 <xsl:with-param name="prev" select="/d:foo"/>
407 <xsl:with-param name="next" select="/d:foo"/>
408 <xsl:with-param name="nav.context" select="'toc'"/>
409 <xsl:with-param name="content">
410 <xsl:copy-of select="$lot"/>
414 <xsl:with-param name="quiet" select="$chunk.quietly"/>
416 <!-- And output a link to this file -->
418 <xsl:attribute name="class">
419 <xsl:text>ListofTitles</xsl:text>
422 <xsl:call-template name="gentext">
423 <xsl:with-param name="key">
425 <xsl:when test="$type='table'">ListofTables</xsl:when>
426 <xsl:when test="$type='figure'">ListofFigures</xsl:when>
427 <xsl:when test="$type='equation'">ListofEquations</xsl:when>
428 <xsl:when test="$type='example'">ListofExamples</xsl:when>
429 <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
430 <xsl:otherwise>ListofUnknown</xsl:otherwise>
439 <!-- ==================================================================== -->
441 <xsl:template name="in.other.chunk">
442 <xsl:param name="chunk" select="."/>
443 <xsl:param name="node" select="."/>
445 <xsl:variable name="is.chunk">
446 <xsl:call-template name="chunk">
447 <xsl:with-param name="node" select="$node"/>
453 <xsl:text>in.other.chunk: </xsl:text>
454 <xsl:value-of select="name($chunk)"/>
455 <xsl:text> </xsl:text>
456 <xsl:value-of select="name($node)"/>
457 <xsl:text> </xsl:text>
458 <xsl:value-of select="$chunk = $node"/>
459 <xsl:text> </xsl:text>
460 <xsl:value-of select="$is.chunk"/>
465 <xsl:when test="$chunk = $node">0</xsl:when>
466 <xsl:when test="$is.chunk = 1">1</xsl:when>
467 <xsl:when test="count($node) = 0">0</xsl:when>
469 <xsl:call-template name="in.other.chunk">
470 <xsl:with-param name="chunk" select="$chunk"/>
471 <xsl:with-param name="node" select="$node/parent::*"/>
477 <xsl:template name="count.footnotes.in.this.chunk">
478 <xsl:param name="node" select="."/>
479 <xsl:param name="footnotes" select="$node//d:footnote"/>
480 <xsl:param name="count" select="0"/>
484 <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
485 <xsl:value-of select="name($node)"/>
489 <xsl:variable name="in.other.chunk">
490 <xsl:call-template name="in.other.chunk">
491 <xsl:with-param name="chunk" select="$node"/>
492 <xsl:with-param name="node" select="$footnotes[1]"/>
497 <xsl:when test="count($footnotes) = 0">
498 <xsl:value-of select="$count"/>
502 <xsl:when test="$in.other.chunk != 0">
503 <xsl:call-template name="count.footnotes.in.this.chunk">
504 <xsl:with-param name="node" select="$node"/>
505 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
506 <xsl:with-param name="count" select="$count"/>
509 <xsl:when test="$footnotes[1]/ancestor::d:table |$footnotes[1]/ancestor::d:informaltable">
510 <xsl:call-template name="count.footnotes.in.this.chunk">
511 <xsl:with-param name="node" select="$node"/>
512 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
513 <xsl:with-param name="count" select="$count"/>
517 <xsl:call-template name="count.footnotes.in.this.chunk">
518 <xsl:with-param name="node" select="$node"/>
519 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
520 <xsl:with-param name="count" select="$count + 1"/>
528 <xsl:template name="process.footnotes.in.this.chunk">
529 <xsl:param name="node" select="."/>
530 <xsl:param name="footnotes" select="$node//d:footnote"/>
533 <xsl:message>process.footnotes.in.this.chunk</xsl:message>
536 <xsl:variable name="in.other.chunk">
537 <xsl:call-template name="in.other.chunk">
538 <xsl:with-param name="chunk" select="$node"/>
539 <xsl:with-param name="node" select="$footnotes[1]"/>
544 <xsl:when test="count($footnotes) = 0">
549 <xsl:when test="$in.other.chunk != 0">
550 <xsl:call-template name="process.footnotes.in.this.chunk">
551 <xsl:with-param name="node" select="$node"/>
552 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
555 <xsl:when test="$footnotes[1]/ancestor::d:table |$footnotes[1]/ancestor::d:informaltable">
556 <xsl:call-template name="process.footnotes.in.this.chunk">
557 <xsl:with-param name="node" select="$node"/>
558 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
562 <xsl:apply-templates select="$footnotes[1]" mode="process.footnote.mode"/>
563 <xsl:call-template name="process.footnotes.in.this.chunk">
564 <xsl:with-param name="node" select="$node"/>
565 <xsl:with-param name="footnotes" select="$footnotes[position() > 1]"/>
573 <xsl:template name="process.footnotes">
574 <xsl:variable name="footnotes" select=".//d:footnote"/>
575 <xsl:variable name="fcount">
576 <xsl:call-template name="count.footnotes.in.this.chunk">
577 <xsl:with-param name="node" select="."/>
578 <xsl:with-param name="footnotes" select="$footnotes"/>
584 <xsl:value-of select="name(.)"/>
585 <xsl:text> fcount: </xsl:text>
586 <xsl:value-of select="$fcount"/>
590 <!-- Only bother to do this if there's at least one non-table footnote -->
591 <xsl:if test="$fcount > 0">
592 <div class="footnotes">
593 <xsl:call-template name="footnotes.attributes"/>
597 <xsl:when test="$make.clean.html != 0">
598 <xsl:attribute name="class">footnote-hr</xsl:attribute>
600 <xsl:when test="$css.decoration != 0">
601 <xsl:attribute name="style">
602 <xsl:value-of select="concat('width:100; text-align:', $direction.align.start, ';', 'margin-', $direction.align.start, ': 0')"/>
606 <xsl:attribute name="width">100</xsl:attribute>
607 <xsl:attribute name="align"><xsl:value-of select="$direction.align.start"/></xsl:attribute>
611 <xsl:call-template name="process.footnotes.in.this.chunk">
612 <xsl:with-param name="node" select="."/>
613 <xsl:with-param name="footnotes" select="$footnotes"/>
618 <!-- FIXME: When chunking, only the annotations actually used
619 in this chunk should be referenced. I don't think it
620 does any harm to reference them all, but it adds
621 unnecessary bloat to each chunk. -->
622 <xsl:if test="$annotation.support != 0 and //d:annotation">
623 <div class="annotation-list">
624 <div class="annotation-nocss">
625 <p>The following annotations are from this essay. You are seeing
626 them here because your browser doesn’t support the user-interface
627 techniques used to make them appear as ‘popups’ on modern browsers.</p>
630 <xsl:apply-templates select="//d:annotation" mode="annotation-popup"/>
635 <xsl:template name="process.chunk.footnotes">
636 <xsl:variable name="is.chunk">
637 <xsl:call-template name="chunk"/>
639 <xsl:if test="$is.chunk = 1">
640 <xsl:call-template name="process.footnotes"/>
644 <!-- ====================================================================== -->
646 <xsl:template name="chunk">
647 <xsl:param name="node" select="."/>
648 <!-- returns 1 if $node is a chunk -->
650 <!-- ==================================================================== -->
656 bibliography in article or part or book
660 glossary in article or part or book
661 index in article or part or book
666 sect{1,2,3,4,5} if position()>1 && depth < chunk.section.depth
667 section if position()>1 && depth < chunk.section.depth
672 <!-- ==================================================================== -->
676 <xsl:text>chunk: </xsl:text>
677 <xsl:value-of select="name($node)"/>
678 <xsl:text>(</xsl:text>
679 <xsl:value-of select="$node/@id"/>
680 <xsl:text>)</xsl:text>
681 <xsl:text> csd: </xsl:text>
682 <xsl:value-of select="$chunk.section.depth"/>
683 <xsl:text> cfs: </xsl:text>
684 <xsl:value-of select="$chunk.first.sections"/>
685 <xsl:text> ps: </xsl:text>
686 <xsl:value-of select="count($node/parent::d:section)"/>
687 <xsl:text> prs: </xsl:text>
688 <xsl:value-of select="count($node/preceding-sibling::d:section)"/>
693 <xsl:when test="$node/parent::*/processing-instruction('dbhtml')[normalize-space(.) = 'stop-chunking']">0</xsl:when>
694 <xsl:when test="not($node/parent::*)">1</xsl:when>
696 <xsl:when test="local-name($node) = 'sect1' and $chunk.section.depth >= 1 and ($chunk.first.sections != 0 or count($node/preceding-sibling::d:sect1) > 0)">
697 <xsl:text>1</xsl:text>
699 <xsl:when test="local-name($node) = 'sect2' and $chunk.section.depth >= 2 and ($chunk.first.sections != 0 or count($node/preceding-sibling::d:sect2) > 0)">
700 <xsl:call-template name="chunk">
701 <xsl:with-param name="node" select="$node/parent::*"/>
704 <xsl:when test="local-name($node) = 'sect3' and $chunk.section.depth >= 3 and ($chunk.first.sections != 0 or count($node/preceding-sibling::d:sect3) > 0)">
705 <xsl:call-template name="chunk">
706 <xsl:with-param name="node" select="$node/parent::*"/>
709 <xsl:when test="local-name($node) = 'sect4' and $chunk.section.depth >= 4 and ($chunk.first.sections != 0 or count($node/preceding-sibling::d:sect4) > 0)">
710 <xsl:call-template name="chunk">
711 <xsl:with-param name="node" select="$node/parent::*"/>
714 <xsl:when test="local-name($node) = 'sect5' and $chunk.section.depth >= 5 and ($chunk.first.sections != 0 or count($node/preceding-sibling::d:sect5) > 0)">
715 <xsl:call-template name="chunk">
716 <xsl:with-param name="node" select="$node/parent::*"/>
719 <xsl:when test="local-name($node) = 'section' and $chunk.section.depth >= count($node/ancestor::d:section)+1 and ($chunk.first.sections != 0 or count($node/preceding-sibling::d:section) > 0)">
720 <xsl:call-template name="chunk">
721 <xsl:with-param name="node" select="$node/parent::*"/>
725 <xsl:when test="local-name($node)='preface'">1</xsl:when>
726 <xsl:when test="local-name($node)='chapter'">1</xsl:when>
727 <xsl:when test="local-name($node)='appendix'">1</xsl:when>
728 <xsl:when test="local-name($node)='article'">1</xsl:when>
729 <xsl:when test="local-name($node)='topic'">1</xsl:when>
730 <xsl:when test="local-name($node)='part'">1</xsl:when>
731 <xsl:when test="local-name($node)='reference'">1</xsl:when>
732 <xsl:when test="local-name($node)='refentry'">1</xsl:when>
733 <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>
734 <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>
735 <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>
736 <xsl:when test="local-name($node)='colophon'">1</xsl:when>
737 <xsl:when test="local-name($node)='book'">1</xsl:when>
738 <xsl:when test="local-name($node)='set'">1</xsl:when>
739 <xsl:when test="local-name($node)='setindex'">1</xsl:when>
740 <xsl:when test="local-name($node)='legalnotice' and $generate.legalnotice.link != 0">1</xsl:when>
741 <xsl:otherwise>0</xsl:otherwise>
745 <!-- ==================================================================== -->
746 <xsl:template name="href.target.uri">
747 <xsl:param name="object" select="."/>
748 <xsl:variable name="ischunk">
749 <xsl:call-template name="chunk">
750 <xsl:with-param name="node" select="$object"/>
754 <xsl:apply-templates mode="chunk-filename" select="$object"/>
756 <xsl:if test="$ischunk='0'">
757 <xsl:text>#</xsl:text>
758 <xsl:call-template name="object.id">
759 <xsl:with-param name="object" select="$object"/>
764 <xsl:template name="href.target">
765 <xsl:param name="context" select="."/>
766 <xsl:param name="object" select="."/>
767 <xsl:param name="toc-context" select="."/>
768 <!-- * If $toc-context contains some node other than the current node, -->
769 <!-- * it means we're processing a link in a TOC. In that case, to -->
770 <!-- * ensure the link will work correctly, we need to take a look at -->
771 <!-- * where the file containing the TOC will get written, and where -->
772 <!-- * the file that's being linked to will get written. -->
773 <xsl:variable name="toc-output-dir">
774 <xsl:if test="not($toc-context = .)">
775 <!-- * Get the $toc-context node and all its ancestors, look down -->
776 <!-- * through them to find the last/closest node to the -->
777 <!-- * toc-context node that has a "dbhtml dir" PI, and get the -->
778 <!-- * directory name from that. That's the name of the directory -->
779 <!-- * to which the current toc output file will get written. -->
780 <xsl:call-template name="dbhtml-dir">
781 <xsl:with-param name="context" select="$toc-context/ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
785 <xsl:variable name="linked-file-output-dir">
786 <xsl:if test="not($toc-context = .)">
787 <!-- * Get the current node and all its ancestors, look down -->
788 <!-- * through them to find the last/closest node to the current -->
789 <!-- * node that has a "dbhtml dir" PI, and get the directory name -->
790 <!-- * from that. That's the name of the directory to which the -->
791 <!-- * file that's being linked to will get written. -->
792 <xsl:call-template name="dbhtml-dir">
793 <xsl:with-param name="context" select="ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/>
797 <xsl:variable name="href.to.uri">
798 <xsl:call-template name="href.target.uri">
799 <xsl:with-param name="object" select="$object"/>
802 <xsl:variable name="href.from.uri">
804 <xsl:when test="not($toc-context = .)">
805 <xsl:call-template name="href.target.uri">
806 <xsl:with-param name="object" select="$toc-context"/>
810 <xsl:call-template name="href.target.uri">
811 <xsl:with-param name="object" select="$context"/>
816 <!-- * <xsl:message>toc-context: <xsl:value-of select="local-name($toc-context)"/></xsl:message> -->
817 <!-- * <xsl:message>node: <xsl:value-of select="local-name(.)"/></xsl:message> -->
818 <!-- * <xsl:message>context: <xsl:value-of select="local-name($context)"/></xsl:message> -->
819 <!-- * <xsl:message>object: <xsl:value-of select="local-name($object)"/></xsl:message> -->
820 <!-- * <xsl:message>toc-output-dir: <xsl:value-of select="$toc-output-dir"/></xsl:message> -->
821 <!-- * <xsl:message>linked-file-output-dir: <xsl:value-of select="$linked-file-output-dir"/></xsl:message> -->
822 <!-- * <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> -->
823 <!-- * <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> -->
824 <xsl:variable name="href.to">
826 <!-- * 2007-07-19, MikeSmith: Added the following conditional to -->
827 <!-- * deal with a problem case for links in TOCs. It checks to see -->
828 <!-- * if the output dir that a TOC will get written to is -->
829 <!-- * different from the output dir of the file being linked to. -->
830 <!-- * If it is different, we do not call trim.common.uri.paths. -->
832 <!-- * Reason why I added that conditional is: I ran into a bug for -->
833 <!-- * this case: -->
835 <!-- * 1. we are chunking into separate dirs -->
837 <!-- * 2. output for the TOC is written to current dir, but the file -->
838 <!-- * being linked to is written to some subdir "foo". -->
840 <!-- * For that case, links to that file in that TOC did not show -->
841 <!-- * the correct path - they omitted the "foo". -->
843 <!-- * The cause of that problem was that the trim.common.uri.paths -->
844 <!-- * template[1] was being called under all conditions. But it's -->
845 <!-- * apparent that we don't want to call trim.common.uri.paths in -->
846 <!-- * the case where a linked file is being written to a different -->
847 <!-- * directory than the TOC that contains the link, because doing -->
848 <!-- * so will cause a necessary (not redundant) directory-name -->
849 <!-- * part of the link to get inadvertently trimmed, resulting in -->
850 <!-- * a broken link to that file. Thus, added the conditional. -->
852 <!-- * [1] The purpose of the trim.common.uri.paths template is to -->
853 <!-- * prevent cases where, if we didn't call it, we end up with -->
854 <!-- * unnecessary, redundant directory names getting output; for -->
855 <!-- * example, "foo/foo/refname.html". -->
856 <xsl:when test="not($toc-output-dir = $linked-file-output-dir)">
857 <xsl:value-of select="$href.to.uri"/>
860 <xsl:call-template name="trim.common.uri.paths">
861 <xsl:with-param name="uriA" select="$href.to.uri"/>
862 <xsl:with-param name="uriB" select="$href.from.uri"/>
863 <xsl:with-param name="return" select="'A'"/>
868 <xsl:variable name="href.from">
869 <xsl:call-template name="trim.common.uri.paths">
870 <xsl:with-param name="uriA" select="$href.to.uri"/>
871 <xsl:with-param name="uriB" select="$href.from.uri"/>
872 <xsl:with-param name="return" select="'B'"/>
875 <xsl:variable name="depth">
876 <xsl:call-template name="count.uri.path.depth">
877 <xsl:with-param name="filename" select="$href.from"/>
880 <xsl:variable name="href">
881 <xsl:call-template name="copy-string">
882 <xsl:with-param name="string" select="'../'"/>
883 <xsl:with-param name="count" select="$depth"/>
885 <xsl:value-of select="$href.to"/>
889 <xsl:text>In </xsl:text>
890 <xsl:value-of select="name(.)"/>
891 <xsl:text> (</xsl:text>
892 <xsl:value-of select="$href.from"/>
893 <xsl:text>,</xsl:text>
894 <xsl:value-of select="$depth"/>
895 <xsl:text>) </xsl:text>
896 <xsl:value-of select="name($object)"/>
897 <xsl:text> href=</xsl:text>
898 <xsl:value-of select="$href"/>
901 <xsl:value-of select="$href"/>
904 <!-- Returns the complete olink href value if found -->
905 <!-- Must take into account any dbhtml dir of the chunk containing the olink -->
906 <xsl:template name="make.olink.href">
907 <xsl:param name="olink.key" select="''"/>
908 <xsl:param name="target.database"/>
910 <xsl:if test="$olink.key != ''">
911 <xsl:variable name="target.href">
912 <xsl:for-each select="$target.database">
913 <xsl:value-of select="key('targetptr-key', $olink.key)[1]/@href"/>
917 <!-- an olink starting point may be in a subdirectory, so need
918 the "from" reference point to compute a relative path -->
920 <xsl:variable name="from.href">
921 <xsl:call-template name="olink.from.uri">
922 <xsl:with-param name="target.database" select="$target.database"/>
923 <xsl:with-param name="object" select="."/>
924 <xsl:with-param name="object.targetdoc" select="$current.docid"/>
928 <!-- If the from.href has directory path, then must "../" upward
929 to document level -->
930 <xsl:variable name="upward.from.path">
931 <xsl:call-template name="upward.path">
932 <xsl:with-param name="path" select="$from.href"/>
936 <xsl:variable name="targetdoc">
937 <xsl:value-of select="substring-before($olink.key, '/')"/>
940 <!-- Does the target database use a sitemap? -->
941 <xsl:variable name="use.sitemap">
943 <xsl:when test="$target.database//sitemap">1</xsl:when>
944 <xsl:otherwise>0</xsl:otherwise>
949 <!-- Get the baseuri for this targetptr -->
950 <xsl:variable name="baseuri">
952 <!-- Does the database use a sitemap? -->
953 <xsl:when test="$use.sitemap != 0">
955 <!-- Was current.docid parameter set? -->
956 <xsl:when test="$current.docid != ''">
957 <!-- Was it found in the database? -->
958 <xsl:variable name="currentdoc.key">
959 <xsl:for-each select="$target.database">
960 <xsl:value-of select="key('targetdoc-key', $current.docid)[1]/@targetdoc"/>
964 <xsl:when test="$currentdoc.key != ''">
965 <xsl:for-each select="$target.database">
966 <xsl:call-template name="targetpath">
967 <xsl:with-param name="dirnode" select="key('targetdoc-key', $current.docid)[1]/parent::dir"/>
968 <xsl:with-param name="targetdoc" select="$targetdoc"/>
973 <xsl:call-template name="olink.error">
974 <xsl:with-param name="message">
975 <xsl:text>cannot compute relative </xsl:text>
976 <xsl:text>sitemap path because $current.docid '</xsl:text>
977 <xsl:value-of select="$current.docid"/>
978 <xsl:text>' not found in target database.</xsl:text>
985 <xsl:call-template name="olink.error">
986 <xsl:with-param name="message">
987 <xsl:text>cannot compute relative </xsl:text>
988 <xsl:text>sitemap path without $current.docid parameter</xsl:text>
993 <!-- In either case, add baseuri from its document entry-->
994 <xsl:variable name="docbaseuri">
995 <xsl:for-each select="$target.database">
996 <xsl:value-of select="key('targetdoc-key', $targetdoc)[1]/@baseuri"/>
999 <xsl:if test="$docbaseuri != ''">
1000 <xsl:value-of select="$docbaseuri"/>
1003 <!-- No database sitemap in use -->
1005 <!-- Just use any baseuri from its document entry -->
1006 <xsl:variable name="docbaseuri">
1007 <xsl:for-each select="$target.database">
1008 <xsl:value-of select="key('targetdoc-key', $targetdoc)[1]/@baseuri"/>
1011 <xsl:if test="$docbaseuri != ''">
1012 <xsl:value-of select="$docbaseuri"/>
1018 <!-- Is this olink to be active? -->
1019 <xsl:variable name="active.olink">
1021 <xsl:when test="$activate.external.olinks = 0">
1023 <xsl:when test="$current.docid = ''">1</xsl:when>
1024 <xsl:when test="$targetdoc = ''">1</xsl:when>
1025 <xsl:when test="$targetdoc = $current.docid">1</xsl:when>
1026 <xsl:otherwise>0</xsl:otherwise>
1029 <xsl:otherwise>1</xsl:otherwise>
1033 <xsl:if test="$active.olink != 0">
1034 <!-- Form the href information -->
1035 <xsl:if test="not(contains($baseuri, ':'))">
1036 <!-- if not an absolute uri, add upward path from olink chunk -->
1037 <xsl:value-of select="$upward.from.path"/>
1040 <xsl:if test="$baseuri != ''">
1041 <xsl:value-of select="$baseuri"/>
1042 <xsl:if test="substring($target.href,1,1) != '#'">
1043 <!--xsl:text>/</xsl:text-->
1046 <!-- optionally turn off frag for PDF references -->
1047 <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, '#') )">
1048 <xsl:value-of select="$target.href"/>
1054 <!-- Computes "../" to reach top -->
1055 <xsl:template name="upward.path">
1056 <xsl:param name="path" select="''"/>
1058 <!-- Don't bother with absolute uris -->
1059 <xsl:when test="contains($path, ':')"/>
1060 <xsl:when test="starts-with($path, '/')"/>
1061 <xsl:when test="contains($path, '/')">
1062 <xsl:text>../</xsl:text>
1063 <xsl:call-template name="upward.path">
1064 <xsl:with-param name="path" select="substring-after($path, '/')"/>
1065 </xsl:call-template>
1071 <!-- ==================================================================== -->
1073 <xsl:template name="html.head">
1074 <xsl:param name="prev" select="/d:foo"/>
1075 <xsl:param name="next" select="/d:foo"/>
1076 <xsl:variable name="this" select="."/>
1077 <xsl:variable name="home" select="/*[1]"/>
1078 <xsl:variable name="up" select="parent::*"/>
1081 <xsl:call-template name="system.head.content"/>
1082 <xsl:call-template name="head.content"/>
1084 <!-- home link not valid in HTML5 -->
1085 <xsl:if test="$home and $div.element != 'section'">
1087 <xsl:attribute name="href">
1088 <xsl:call-template name="href.target">
1089 <xsl:with-param name="object" select="$home"/>
1090 </xsl:call-template>
1092 <xsl:attribute name="title">
1093 <xsl:apply-templates select="$home" mode="object.title.markup.textonly"/>
1098 <!-- up link not valid in HTML5 -->
1099 <xsl:if test="$up and $div.element != 'section'">
1101 <xsl:attribute name="href">
1102 <xsl:call-template name="href.target">
1103 <xsl:with-param name="object" select="$up"/>
1104 </xsl:call-template>
1106 <xsl:attribute name="title">
1107 <xsl:apply-templates select="$up" mode="object.title.markup.textonly"/>
1112 <xsl:if test="$prev">
1114 <xsl:attribute name="href">
1115 <xsl:call-template name="href.target">
1116 <xsl:with-param name="object" select="$prev"/>
1117 </xsl:call-template>
1119 <xsl:attribute name="title">
1120 <xsl:apply-templates select="$prev" mode="object.title.markup.textonly"/>
1125 <xsl:if test="$next">
1127 <xsl:attribute name="href">
1128 <xsl:call-template name="href.target">
1129 <xsl:with-param name="object" select="$next"/>
1130 </xsl:call-template>
1132 <xsl:attribute name="title">
1133 <xsl:apply-templates select="$next" mode="object.title.markup.textonly"/>
1138 <xsl:if test="$html.extra.head.links != 0">
1139 <xsl:for-each select="//d:part |//d:reference |//d:preface |//d:chapter |//d:article |//d:refentry |//d:appendix[not(parent::d:article)]|d:appendix |//d:glossary[not(parent::d:article)]|d:glossary |//d:index[not(parent::d:article)]|d:index">
1140 <link rel="{local-name(.)}">
1141 <xsl:attribute name="href">
1142 <xsl:call-template name="href.target">
1143 <xsl:with-param name="context" select="$this"/>
1144 <xsl:with-param name="object" select="."/>
1145 </xsl:call-template>
1147 <xsl:attribute name="title">
1148 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1153 <xsl:for-each select="d:section|d:sect1|d:refsection|d:refsect1">
1155 <xsl:attribute name="rel">
1157 <xsl:when test="local-name($this) = 'section' or local-name($this) = 'refsection'">
1158 <xsl:value-of select="'subsection'"/>
1161 <xsl:value-of select="'section'"/>
1165 <xsl:attribute name="href">
1166 <xsl:call-template name="href.target">
1167 <xsl:with-param name="context" select="$this"/>
1168 <xsl:with-param name="object" select="."/>
1169 </xsl:call-template>
1171 <xsl:attribute name="title">
1172 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1177 <xsl:for-each select="d:sect2|d:sect3|d:sect4|d:sect5|d:refsect2|d:refsect3">
1178 <link rel="subsection">
1179 <xsl:attribute name="href">
1180 <xsl:call-template name="href.target">
1181 <xsl:with-param name="context" select="$this"/>
1182 <xsl:with-param name="object" select="."/>
1183 </xsl:call-template>
1185 <xsl:attribute name="title">
1186 <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
1192 <!-- * if we have a legalnotice and user wants it output as a -->
1193 <!-- * separate page and $html.head.legalnotice.link.types is -->
1194 <!-- * non-empty, we generate a link or links for each value in -->
1195 <!-- * $html.head.legalnotice.link.types -->
1196 <xsl:if test="//d:legalnotice and not($generate.legalnotice.link = 0) and not($html.head.legalnotice.link.types = '')">
1197 <xsl:call-template name="make.legalnotice.head.links"/>
1200 <xsl:call-template name="user.head.content"/>
1204 <!-- ==================================================================== -->
1206 <xsl:template name="header.navigation">
1207 <xsl:param name="prev" select="/d:foo"/>
1208 <xsl:param name="next" select="/d:foo"/>
1209 <xsl:param name="nav.context"/>
1211 <xsl:variable name="home" select="/*[1]"/>
1212 <xsl:variable name="up" select="parent::*"/>
1214 <xsl:variable name="row1" select="$navig.showtitles != 0"/>
1215 <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"/>
1217 <xsl:if test="$suppress.navigation = '0' and $suppress.header.navigation = '0'">
1218 <div class="navheader">
1219 <xsl:if test="$row1 or $row2">
1220 <table width="100%" summary="Navigation header">
1221 <xsl:if test="$row1">
1223 <th colspan="3" align="center">
1224 <xsl:apply-templates select="." mode="object.title.markup"/>
1229 <xsl:if test="$row2">
1231 <td width="20%" align="{$direction.align.start}">
1232 <xsl:if test="count($prev)>0">
1234 <xsl:attribute name="href">
1235 <xsl:call-template name="href.target">
1236 <xsl:with-param name="object" select="$prev"/>
1237 </xsl:call-template>
1239 <xsl:call-template name="navig.content">
1240 <xsl:with-param name="direction" select="'prev'"/>
1241 </xsl:call-template>
1244 <xsl:text> </xsl:text>
1246 <th width="60%" align="center">
1248 <xsl:when test="count($up) > 0 and generate-id($up) != generate-id($home) and $navig.showtitles != 0">
1249 <xsl:apply-templates select="$up" mode="object.title.markup"/>
1251 <xsl:otherwise> </xsl:otherwise>
1254 <td width="20%" align="{$direction.align.end}">
1255 <xsl:text> </xsl:text>
1256 <xsl:if test="count($next)>0">
1258 <xsl:attribute name="href">
1259 <xsl:call-template name="href.target">
1260 <xsl:with-param name="object" select="$next"/>
1261 </xsl:call-template>
1263 <xsl:call-template name="navig.content">
1264 <xsl:with-param name="direction" select="'next'"/>
1265 </xsl:call-template>
1273 <xsl:if test="$header.rule != 0">
1280 <!-- ==================================================================== -->
1282 <xsl:template name="footer.navigation">
1283 <xsl:param name="prev" select="/d:foo"/>
1284 <xsl:param name="next" select="/d:foo"/>
1285 <xsl:param name="nav.context"/>
1287 <xsl:variable name="home" select="/*[1]"/>
1288 <xsl:variable name="up" select="parent::*"/>
1290 <xsl:variable name="row1" select="count($prev) > 0 or count($up) > 0 or count($next) > 0"/>
1292 <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)"/>
1294 <xsl:if test="$suppress.navigation = '0' and $suppress.footer.navigation = '0'">
1295 <div class="navfooter">
1296 <xsl:if test="$footer.rule != 0">
1300 <xsl:if test="$row1 or $row2">
1301 <table width="100%" summary="Navigation footer">
1302 <xsl:if test="$row1">
1304 <td width="40%" align="{$direction.align.start}">
1305 <xsl:if test="count($prev)>0">
1307 <xsl:attribute name="href">
1308 <xsl:call-template name="href.target">
1309 <xsl:with-param name="object" select="$prev"/>
1310 </xsl:call-template>
1312 <xsl:call-template name="navig.content">
1313 <xsl:with-param name="direction" select="'prev'"/>
1314 </xsl:call-template>
1317 <xsl:text> </xsl:text>
1319 <td width="20%" align="center">
1321 <xsl:when test="count($up)>0 and generate-id($up) != generate-id($home)">
1323 <xsl:attribute name="href">
1324 <xsl:call-template name="href.target">
1325 <xsl:with-param name="object" select="$up"/>
1326 </xsl:call-template>
1328 <xsl:call-template name="navig.content">
1329 <xsl:with-param name="direction" select="'up'"/>
1330 </xsl:call-template>
1333 <xsl:otherwise> </xsl:otherwise>
1336 <td width="40%" align="{$direction.align.end}">
1337 <xsl:text> </xsl:text>
1338 <xsl:if test="count($next)>0">
1340 <xsl:attribute name="href">
1341 <xsl:call-template name="href.target">
1342 <xsl:with-param name="object" select="$next"/>
1343 </xsl:call-template>
1345 <xsl:call-template name="navig.content">
1346 <xsl:with-param name="direction" select="'next'"/>
1347 </xsl:call-template>
1354 <xsl:if test="$row2">
1356 <td width="40%" align="{$direction.align.start}" valign="top">
1357 <xsl:if test="$navig.showtitles != 0">
1358 <xsl:apply-templates select="$prev" mode="object.title.markup"/>
1360 <xsl:text> </xsl:text>
1362 <td width="20%" align="center">
1364 <xsl:when test="$home != . or $nav.context = 'toc'">
1366 <xsl:attribute name="href">
1367 <xsl:call-template name="href.target">
1368 <xsl:with-param name="object" select="$home"/>
1369 </xsl:call-template>
1371 <xsl:call-template name="navig.content">
1372 <xsl:with-param name="direction" select="'home'"/>
1373 </xsl:call-template>
1375 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1376 <xsl:text> | </xsl:text>
1379 <xsl:otherwise> </xsl:otherwise>
1382 <xsl:if test="$chunk.tocs.and.lots != 0 and $nav.context != 'toc'">
1384 <xsl:attribute name="href">
1385 <xsl:value-of select="$chunked.filename.prefix"/>
1386 <xsl:apply-templates select="/*[1]" mode="recursive-chunk-filename">
1387 <xsl:with-param name="recursive" select="true()"/>
1388 </xsl:apply-templates>
1389 <xsl:text>-toc</xsl:text>
1390 <xsl:value-of select="$html.ext"/>
1392 <xsl:call-template name="gentext">
1393 <xsl:with-param name="key" select="'nav-toc'"/>
1394 </xsl:call-template>
1398 <td width="40%" align="{$direction.align.end}" valign="top">
1399 <xsl:text> </xsl:text>
1400 <xsl:if test="$navig.showtitles != 0">
1401 <xsl:apply-templates select="$next" mode="object.title.markup"/>
1412 <!-- ==================================================================== -->
1414 <xsl:template name="navig.content">
1415 <xsl:param name="direction" select="d:next"/>
1416 <xsl:variable name="navtext">
1418 <xsl:when test="$direction = 'prev'">
1419 <xsl:call-template name="gentext.nav.prev"/>
1421 <xsl:when test="$direction = 'next'">
1422 <xsl:call-template name="gentext.nav.next"/>
1424 <xsl:when test="$direction = 'up'">
1425 <xsl:call-template name="gentext.nav.up"/>
1427 <xsl:when test="$direction = 'home'">
1428 <xsl:call-template name="gentext.nav.home"/>
1431 <xsl:text>xxx</xsl:text>
1437 <xsl:when test="$navig.graphics != 0">
1439 <xsl:attribute name="src">
1440 <xsl:value-of select="$navig.graphics.path"/>
1441 <xsl:value-of select="$direction"/>
1442 <xsl:value-of select="$navig.graphics.extension"/>
1444 <xsl:attribute name="alt">
1445 <xsl:value-of select="$navtext"/>
1450 <xsl:value-of select="$navtext"/>
1455 <!-- ==================================================================== -->
1457 <!-- * The following template assumes that the first legalnotice -->
1458 <!-- * instance found in a document applies to the contents of the -->
1459 <!-- * entire document. It generates an HTML link in each chunk, back -->
1460 <!-- * to the file containing the contents of the first legalnotice. -->
1462 <!-- * Actually, it may generate multiple link instances in each chunk, -->
1463 <!-- * because it walks through the space-separated list of link -->
1464 <!-- * types specified in the $html.head.legalnotice.link.types param, -->
1465 <!-- * popping off link types and generating links for them until it -->
1466 <!-- * depletes the list. -->
1468 <xsl:template name="make.legalnotice.head.links">
1469 <!-- * the following ID is used as part of the legalnotice filename; -->
1470 <!-- * we need it in order to construct the filename for use in the -->
1471 <!-- * value of the href attribute on the link -->
1473 <xsl:param name="ln-node" select="(//d:legalnotice)[1]"/>
1475 <xsl:param name="linktype">
1477 <xsl:when test="contains($html.head.legalnotice.link.types, ' ')">
1478 <xsl:value-of select="normalize-space( substring-before($html.head.legalnotice.link.types, ' '))"/>
1481 <xsl:value-of select="$html.head.legalnotice.link.types"/>
1485 <xsl:param name="remaining.linktypes" select="concat( normalize-space( substring-after($html.head.legalnotice.link.types, ' ')),' ')"/>
1486 <xsl:if test="not($linktype = '')">
1488 <!-- Compute name of legalnotice file (see titlepage.xsl) -->
1489 <xsl:variable name="file">
1490 <xsl:call-template name="ln.or.rh.filename">
1491 <xsl:with-param name="node" select="$ln-node"/>
1492 </xsl:call-template>
1495 <link rel="{$linktype}">
1496 <xsl:attribute name="href">
1497 <xsl:value-of select="$file"/>
1499 <xsl:attribute name="title">
1500 <xsl:apply-templates select="(//d:legalnotice)[1]" mode="object.title.markup.textonly"/>
1503 <xsl:call-template name="make.legalnotice.head.links">
1504 <!-- * pop the next value off the list of link types -->
1505 <xsl:with-param name="linktype" select="substring-before($remaining.linktypes, ' ')"/>
1506 <!-- * remove the link type from the list of remaining link types -->
1507 <xsl:with-param name="remaining.linktypes" select="substring-after($remaining.linktypes, ' ')"/>
1508 </xsl:call-template>
1512 <!-- ==================================================================== -->
1513 <xsl:template name="chunk-element-content">
1514 <xsl:param name="prev"/>
1515 <xsl:param name="next"/>
1516 <xsl:param name="nav.context"/>
1517 <xsl:param name="content">
1518 <xsl:apply-imports/>
1521 <xsl:call-template name="user.preroot"/>
1524 <xsl:call-template name="root.attributes"/>
1525 <xsl:call-template name="html.head">
1526 <xsl:with-param name="prev" select="$prev"/>
1527 <xsl:with-param name="next" select="$next"/>
1528 </xsl:call-template>
1531 <xsl:call-template name="body.attributes"/>
1533 <xsl:call-template name="user.header.navigation">
1534 <xsl:with-param name="prev" select="$prev"/>
1535 <xsl:with-param name="next" select="$next"/>
1536 <xsl:with-param name="nav.context" select="$nav.context"/>
1537 </xsl:call-template>
1539 <xsl:call-template name="header.navigation">
1540 <xsl:with-param name="prev" select="$prev"/>
1541 <xsl:with-param name="next" select="$next"/>
1542 <xsl:with-param name="nav.context" select="$nav.context"/>
1543 </xsl:call-template>
1545 <xsl:call-template name="user.header.content"/>
1547 <xsl:copy-of select="$content"/>
1549 <xsl:call-template name="user.footer.content"/>
1551 <xsl:call-template name="footer.navigation">
1552 <xsl:with-param name="prev" select="$prev"/>
1553 <xsl:with-param name="next" select="$next"/>
1554 <xsl:with-param name="nav.context" select="$nav.context"/>
1555 </xsl:call-template>
1557 <xsl:call-template name="user.footer.navigation">
1558 <xsl:with-param name="prev" select="$prev"/>
1559 <xsl:with-param name="next" select="$next"/>
1560 <xsl:with-param name="nav.context" select="$nav.context"/>
1561 </xsl:call-template>
1564 <xsl:value-of select="$chunk.append"/>
1567 <!-- ==================================================================== -->
1568 <xsl:template name="generate.manifest">
1569 <xsl:param name="node" select="/"/>
1570 <xsl:call-template name="write.text.chunk">
1571 <xsl:with-param name="filename">
1572 <xsl:if test="$manifest.in.base.dir != 0">
1573 <xsl:value-of select="$chunk.base.dir"/>
1575 <xsl:value-of select="$manifest"/>
1577 <xsl:with-param name="method" select="'text'"/>
1578 <xsl:with-param name="content">
1579 <xsl:apply-templates select="$node" mode="enumerate-files"/>
1581 <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
1582 </xsl:call-template>
1585 <!-- ==================================================================== -->
1587 <xsl:template name="dbhtml-dir">
1588 <xsl:param name="context" select="."/>
1589 <!-- directories are now inherited from previous levels -->
1590 <xsl:variable name="ppath">
1591 <xsl:if test="$context/parent::*">
1592 <xsl:call-template name="dbhtml-dir">
1593 <xsl:with-param name="context" select="$context/parent::*"/>
1594 </xsl:call-template>
1597 <xsl:variable name="path">
1598 <xsl:call-template name="pi.dbhtml_dir">
1599 <xsl:with-param name="node" select="$context"/>
1600 </xsl:call-template>
1603 <xsl:when test="$path = ''">
1604 <xsl:if test="$ppath != ''">
1605 <xsl:value-of select="$ppath"/>
1609 <xsl:if test="$ppath != ''">
1610 <xsl:value-of select="$ppath"/>
1611 <xsl:if test="substring($ppath, string-length($ppath), 1) != '/'">
1612 <xsl:text>/</xsl:text>
1615 <xsl:value-of select="$path"/>
1616 <xsl:text>/</xsl:text>