1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
3 xmlns=
"http://www.w3.org/1999/xhtml"
6 <!-- Performance-optimized versions of some upstream templates from xhtml/
9 <!-- from xhtml/autoidx.xsl -->
11 <xsl:template match=
"indexterm" mode=
"reference">
12 <xsl:param name=
"scope" select=
"."/>
13 <xsl:param name=
"role" select=
"''"/>
14 <xsl:param name=
"type" select=
"''"/>
15 <xsl:param name=
"position"/>
16 <xsl:param name=
"separator" select=
"''"/>
18 <xsl:variable name=
"term.separator">
19 <xsl:call-template name=
"index.separator">
20 <xsl:with-param name=
"key" select=
"'index.term.separator'"/>
24 <xsl:variable name=
"number.separator">
25 <xsl:call-template name=
"index.separator">
26 <xsl:with-param name=
"key" select=
"'index.number.separator'"/>
30 <xsl:variable name=
"range.separator">
31 <xsl:call-template name=
"index.separator">
32 <xsl:with-param name=
"key" select=
"'index.range.separator'"/>
37 <xsl:when test=
"$separator != ''">
38 <xsl:value-of select=
"$separator"/>
40 <xsl:when test=
"$position = 1">
41 <xsl:value-of select=
"$term.separator"/>
44 <xsl:value-of select=
"$number.separator"/>
49 <xsl:when test=
"@zone and string(@zone)">
50 <xsl:call-template name=
"reference">
51 <xsl:with-param name=
"zones" select=
"normalize-space(@zone)"/>
52 <xsl:with-param name=
"position" select=
"position()"/>
53 <xsl:with-param name=
"scope" select=
"$scope"/>
54 <xsl:with-param name=
"role" select=
"$role"/>
55 <xsl:with-param name=
"type" select=
"$type"/>
60 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
61 <xsl:variable name=
"title">
63 <xsl:when test=
"$index.prefer.titleabbrev != 0">
64 <xsl:apply-templates select=
"(ancestor-or-self::set|ancestor-or-self::book|ancestor-or-self::part|ancestor-or-self::reference|ancestor-or-self::partintro|ancestor-or-self::chapter|ancestor-or-self::appendix|ancestor-or-self::preface|ancestor-or-self::article|ancestor-or-self::section|ancestor-or-self::sect1|ancestor-or-self::sect2|ancestor-or-self::sect3|ancestor-or-self::sect4|ancestor-or-self::sect5|ancestor-or-self::refentry|ancestor-or-self::refsect1|ancestor-or-self::refsect2|ancestor-or-self::refsect3|ancestor-or-self::simplesect|ancestor-or-self::bibliography|ancestor-or-self::glossary|ancestor-or-self::index|ancestor-or-self::webpage|ancestor-or-self::topic)[last()]" mode=
"titleabbrev.markup"/>
67 <xsl:apply-templates select=
"(ancestor-or-self::set|ancestor-or-self::book|ancestor-or-self::part|ancestor-or-self::reference|ancestor-or-self::partintro|ancestor-or-self::chapter|ancestor-or-self::appendix|ancestor-or-self::preface|ancestor-or-self::article|ancestor-or-self::section|ancestor-or-self::sect1|ancestor-or-self::sect2|ancestor-or-self::sect3|ancestor-or-self::sect4|ancestor-or-self::sect5|ancestor-or-self::refentry|ancestor-or-self::refsect1|ancestor-or-self::refsect2|ancestor-or-self::refsect3|ancestor-or-self::simplesect|ancestor-or-self::bibliography|ancestor-or-self::glossary|ancestor-or-self::index|ancestor-or-self::webpage|ancestor-or-self::topic)[last()]" mode=
"title.markup"/>
72 <xsl:attribute name=
"href">
74 <xsl:when test=
"$index.links.to.section = 1">
75 <xsl:call-template name=
"href.target">
76 <xsl:with-param name=
"object" select=
"(ancestor-or-self::set|ancestor-or-self::book|ancestor-or-self::part|ancestor-or-self::reference|ancestor-or-self::partintro|ancestor-or-self::chapter|ancestor-or-self::appendix|ancestor-or-self::preface|ancestor-or-self::article|ancestor-or-self::section|ancestor-or-self::sect1|ancestor-or-self::sect2|ancestor-or-self::sect3|ancestor-or-self::sect4|ancestor-or-self::sect5|ancestor-or-self::refentry|ancestor-or-self::refsect1|ancestor-or-self::refsect2|ancestor-or-self::refsect3|ancestor-or-self::simplesect|ancestor-or-self::bibliography|ancestor-or-self::glossary|ancestor-or-self::index|ancestor-or-self::webpage|ancestor-or-self::topic)[last()]"/>
77 <!-- Optimization for pgsql-docs: We only have an index as a
78 child of book, so look that up directly instead of
79 scanning the entire node tree. Also, don't look for
81 <!-- <xsl:with-param name="context" select="(//index[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))] | //setindex[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))])[1]"/> -->
82 <xsl:with-param name=
"context" select=
"(/book/index[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))])[1]"/>
86 <xsl:call-template name=
"href.target">
87 <xsl:with-param name=
"object" select=
"."/>
88 <xsl:with-param name=
"context" select=
"(//index[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))] | //setindex[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))])[1]"/>
95 <xsl:value-of select=
"$title"/> <!-- text only -->
98 <xsl:variable name=
"id" select=
"(@id|@xml:id)[1]"/>
99 <xsl:if test=
"key('endofrange', $id)[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))]">
100 <xsl:apply-templates select=
"key('endofrange', $id)[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][last()]" mode=
"reference">
101 <xsl:with-param name=
"position" select=
"position()"/>
102 <xsl:with-param name=
"scope" select=
"$scope"/>
103 <xsl:with-param name=
"role" select=
"$role"/>
104 <xsl:with-param name=
"type" select=
"$type"/>
105 <xsl:with-param name=
"separator" select=
"$range.separator"/>
106 </xsl:apply-templates>
112 <xsl:template name=
"reference">
113 <xsl:param name=
"scope" select=
"."/>
114 <xsl:param name=
"role" select=
"''"/>
115 <xsl:param name=
"type" select=
"''"/>
116 <xsl:param name=
"zones"/>
119 <xsl:when test=
"contains($zones, ' ')">
120 <xsl:variable name=
"zone" select=
"substring-before($zones, ' ')"/>
121 <xsl:variable name=
"target" select=
"key('sections', $zone)"/>
124 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
125 <!-- Optimization for pgsql-docs: this call adds nothing but fails with docbook-xsl 1.76 -->
126 <!-- <xsl:call-template name="id.attribute"/> -->
127 <xsl:attribute name=
"href">
128 <xsl:call-template name=
"href.target">
129 <xsl:with-param name=
"object" select=
"$target[1]"/>
130 <xsl:with-param name=
"context" select=
"//index[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]"/>
133 <xsl:apply-templates select=
"$target[1]" mode=
"index-title-content"/>
135 <xsl:text>,
</xsl:text>
136 <xsl:call-template name=
"reference">
137 <xsl:with-param name=
"zones" select=
"substring-after($zones, ' ')"/>
138 <xsl:with-param name=
"position" select=
"position()"/>
139 <xsl:with-param name=
"scope" select=
"$scope"/>
140 <xsl:with-param name=
"role" select=
"$role"/>
141 <xsl:with-param name=
"type" select=
"$type"/>
145 <xsl:variable name=
"zone" select=
"$zones"/>
146 <xsl:variable name=
"target" select=
"key('sections', $zone)"/>
149 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
150 <!-- Optimization for pgsql-docs: this call adds nothing but fails with docbook-xsl 1.76 -->
151 <!-- <xsl:call-template name="id.attribute"/> -->
152 <xsl:attribute name=
"href">
153 <xsl:call-template name=
"href.target">
154 <xsl:with-param name=
"object" select=
"$target[1]"/>
155 <!-- Optimization for pgsql-docs: Only look for index under book
156 instead of searching the whole node tree. -->
157 <!-- <xsl:with-param name="context" select="//index[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]"/> -->
158 <xsl:with-param name=
"context" select=
"/book/index[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]"/>
161 <xsl:apply-templates select=
"$target[1]" mode=
"index-title-content"/>
168 <!-- from xhtml/chunk-common.xsl -->
170 <xsl:template name=
"chunk-all-sections">
171 <xsl:param name=
"content">
175 <!-- Optimization for pgsql-docs: Since we set a fixed $chunk.section.depth,
176 we can do away with a bunch of complicated XPath searches for the
177 previous and next sections at various levels. -->
179 <xsl:if test=
"$chunk.section.depth != 1">
180 <xsl:message terminate=
"yes">
181 <xsl:text>Error: If you change $chunk.section.depth, then you must update the performance-optimized chunk-all-sections-template.
</xsl:text>
185 <xsl:variable name=
"prev"
186 select=
"(preceding::book[1]
187 |preceding::preface[1]
188 |preceding::chapter[1]
189 |preceding::appendix[1]
191 |preceding::reference[1]
192 |preceding::refentry[1]
193 |preceding::colophon[1]
194 |preceding::article[1]
196 |preceding::bibliography[parent::article or parent::book or parent::part][1]
197 |preceding::glossary[parent::article or parent::book or parent::part][1]
198 |preceding::index[$generate.index != 0]
199 [parent::article or parent::book or parent::part][1]
200 |preceding::setindex[$generate.index != 0][1]
203 |ancestor::preface[1]
204 |ancestor::chapter[1]
205 |ancestor::appendix[1]
207 |ancestor::reference[1]
208 |ancestor::article[1]
211 |ancestor::sect1[1])[last()]"/>
213 <xsl:variable name=
"next"
214 select=
"(following::book[1]
215 |following::preface[1]
216 |following::chapter[1]
217 |following::appendix[1]
219 |following::reference[1]
220 |following::refentry[1]
221 |following::colophon[1]
222 |following::bibliography[parent::article or parent::book or parent::part][1]
223 |following::glossary[parent::article or parent::book or parent::part][1]
224 |following::index[$generate.index != 0]
225 [parent::article or parent::book][1]
226 |following::article[1]
228 |following::setindex[$generate.index != 0][1]
230 |descendant::preface[1]
231 |descendant::chapter[1]
232 |descendant::appendix[1]
233 |descendant::article[1]
234 |descendant::topic[1]
235 |descendant::bibliography[parent::article or parent::book][1]
236 |descendant::glossary[parent::article or parent::book or parent::part][1]
237 |descendant::index[$generate.index != 0]
238 [parent::article or parent::book][1]
239 |descendant::colophon[1]
240 |descendant::setindex[$generate.index != 0][1]
242 |descendant::reference[1]
243 |descendant::refentry[1]
245 |descendant::sect1[1])[1]"/>
247 <xsl:call-template name=
"process-chunk">
248 <xsl:with-param name=
"prev" select=
"$prev"/>
249 <xsl:with-param name=
"next" select=
"$next"/>
250 <xsl:with-param name=
"content" select=
"$content"/>
254 <xsl:template name=
"href.target">
255 <xsl:param name=
"context" select=
"."/>
256 <xsl:param name=
"object" select=
"."/>
257 <xsl:param name=
"toc-context" select=
"."/>
258 <!-- Optimization for pgsql-docs: Remove support for dbhtml processing
260 <xsl:variable name=
"href.to.uri">
261 <xsl:call-template name=
"href.target.uri">
262 <xsl:with-param name=
"object" select=
"$object"/>
265 <xsl:variable name=
"href.from.uri">
267 <xsl:when test=
"not($toc-context = .)">
268 <xsl:call-template name=
"href.target.uri">
269 <xsl:with-param name=
"object" select=
"$toc-context"/>
273 <xsl:call-template name=
"href.target.uri">
274 <xsl:with-param name=
"object" select=
"$context"/>
279 <xsl:variable name=
"href.to">
280 <xsl:value-of select=
"$href.to.uri"/>
282 <xsl:variable name=
"href.from">
283 <xsl:call-template name=
"trim.common.uri.paths">
284 <xsl:with-param name=
"uriA" select=
"$href.to.uri"/>
285 <xsl:with-param name=
"uriB" select=
"$href.from.uri"/>
286 <xsl:with-param name=
"return" select=
"'B'"/>
289 <xsl:variable name=
"depth">
290 <xsl:call-template name=
"count.uri.path.depth">
291 <xsl:with-param name=
"filename" select=
"$href.from"/>
294 <xsl:variable name=
"href">
295 <xsl:call-template name=
"copy-string">
296 <xsl:with-param name=
"string" select=
"'../'"/>
297 <xsl:with-param name=
"count" select=
"$depth"/>
299 <xsl:value-of select=
"$href.to"/>
301 <xsl:value-of select=
"$href"/>
304 <xsl:template name=
"html.head">
305 <xsl:param name=
"prev" select=
"/foo"/>
306 <xsl:param name=
"next" select=
"/foo"/>
308 <!-- Optimization for pgsql-docs: Cut out a bunch of things we don't need
309 here, including an expensive //legalnotice search. -->
312 <xsl:call-template name=
"system.head.content"/>
313 <xsl:call-template name=
"head.content"/>
315 <xsl:if test=
"$prev">
317 <xsl:attribute name=
"href">
318 <xsl:call-template name=
"href.target">
319 <xsl:with-param name=
"object" select=
"$prev"/>
322 <xsl:attribute name=
"title">
323 <xsl:apply-templates select=
"$prev" mode=
"object.title.markup.textonly"/>
328 <xsl:if test=
"$next">
330 <xsl:attribute name=
"href">
331 <xsl:call-template name=
"href.target">
332 <xsl:with-param name=
"object" select=
"$next"/>
335 <xsl:attribute name=
"title">
336 <xsl:apply-templates select=
"$next" mode=
"object.title.markup.textonly"/>
341 <xsl:call-template name=
"user.head.content"/>