1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % common.entities SYSTEM
"http://docbook.sourceforge.net/release/xsl/current/common/entities.ent">
6 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
8 xmlns=
"http://www.w3.org/1999/xhtml">
11 This file contains XSLT stylesheet customizations that are common to
12 all HTML output variants (chunked and single-page).
16 <xsl:param name=
"make.valid.html" select=
"1"></xsl:param>
17 <xsl:param name=
"generate.id.attributes" select=
"1"></xsl:param>
18 <xsl:param name=
"make.graphic.viewport" select=
"0"/>
19 <xsl:param name=
"link.mailto.url">pgsql-docs@lists.postgresql.org
</xsl:param>
20 <xsl:param name=
"toc.max.depth">2</xsl:param>
21 <xsl:param name=
"website.stylesheet" select=
"0"/>
22 <xsl:param name=
"custom.css.source">
23 <xsl:if test=
"$website.stylesheet = 0">stylesheet.css.xml
</xsl:if>
25 <xsl:param name=
"html.stylesheet">
26 <xsl:if test=
"not($website.stylesheet = 0)">https://www.postgresql.org/media/css/docs-complete.css
</xsl:if>
31 The below allows the stylesheets provided by the website to be applied fully
32 to the generated HTML.
34 <xsl:template name=
"body.attributes">
35 <xsl:attribute name=
"id">docContent
</xsl:attribute>
36 <xsl:attribute name=
"class">container-fluid col-
10</xsl:attribute>
39 <!-- Change display of some elements -->
41 <xsl:template match=
"command">
42 <xsl:call-template name=
"inline.monoseq"/>
45 <xsl:template match=
"confgroup" mode=
"bibliography.mode">
47 <xsl:call-template name=
"common.html.attributes"/>
48 <xsl:call-template name=
"id.attribute"/>
49 <xsl:apply-templates select=
"conftitle/text()" mode=
"bibliography.mode"/>
50 <xsl:text>,
</xsl:text>
51 <xsl:apply-templates select=
"confdates/text()" mode=
"bibliography.mode"/>
52 <xsl:copy-of select=
"$biblioentry.item.separator"/>
56 <xsl:template match=
"isbn" mode=
"bibliography.mode">
58 <xsl:call-template name=
"common.html.attributes"/>
59 <xsl:call-template name=
"id.attribute"/>
60 <xsl:text>ISBN
</xsl:text>
61 <xsl:apply-templates mode=
"bibliography.mode"/>
62 <xsl:copy-of select=
"$biblioentry.item.separator"/>
67 <!-- table of contents configuration -->
69 <xsl:param name=
"generate.toc">
89 <xsl:param name=
"generate.section.toc.level" select=
"1"></xsl:param>
91 <!-- include refentry under sect1 in tocs -->
92 <xsl:template match=
"sect1" mode=
"toc">
93 <xsl:param name=
"toc-context" select=
"."/>
94 <xsl:call-template name=
"subtoc">
95 <xsl:with-param name=
"toc-context" select=
"$toc-context"/>
96 <xsl:with-param name=
"nodes" select=
"sect2|refentry
97 |bridgehead[$bridgehead.in.toc != 0]"/>
102 <!-- Put index "quicklinks" (A | B | C | ...) at the top of the bookindex page. -->
104 <!-- from html/autoidx.xsl -->
106 <xsl:template name=
"generate-basic-index">
107 <xsl:param name=
"scope" select=
"NOTANODE"/>
109 <xsl:variable name=
"role">
110 <xsl:if test=
"$index.on.role != 0">
111 <xsl:value-of select=
"@role"/>
115 <xsl:variable name=
"type">
116 <xsl:if test=
"$index.on.type != 0">
117 <xsl:value-of select=
"@type"/>
121 <xsl:variable name=
"terms"
123 [count(.|key('letter',
124 translate(substring(&primary;, 1, 1),
128 and not(@class = 'endofrange')]"/>
130 <xsl:variable name=
"alphabetical"
131 select=
"$terms[contains(concat(&lowercase;, &uppercase;),
132 substring(&primary;, 1, 1))]"/>
134 <xsl:variable name=
"others" select=
"$terms[not(contains(concat(&lowercase;,
136 substring(&primary;, 1, 1)))]"/>
138 <!-- pgsql-docs: added xmlns:xlink, autoidx.xsl doesn't include xlink in
139 exclude-result-prefixes. Without our customization that just leads to a
140 single xmlns:xlink in this div, but because we emit it it otherwise
141 gets pushed down to the elements output by autoidx.xsl -->
142 <div class=
"index" xmlns:
xlink=
"http://www.w3.org/1999/xlink">
143 <p class=
"indexdiv-quicklinks">
144 <a href=
"#indexdiv-Symbols">
145 <xsl:call-template name=
"gentext">
146 <xsl:with-param name=
"key" select=
"'index symbols'"/>
149 <xsl:apply-templates select=
"$alphabetical[count(.|key('letter',
150 translate(substring(&primary;, 1, 1),
151 &lowercase;,&uppercase;))[&scope;][1]) = 1]"
152 mode=
"index-div-quicklinks">
153 <xsl:with-param name=
"position" select=
"position()"/>
154 <xsl:with-param name=
"scope" select=
"$scope"/>
155 <xsl:with-param name=
"role" select=
"$role"/>
156 <xsl:with-param name=
"type" select=
"$type"/>
157 <xsl:sort select=
"translate(&primary;, &lowercase;, &uppercase;)"/>
158 </xsl:apply-templates>
160 <!-- pgsql-docs: end added stuff -->
162 <xsl:if test=
"$others">
164 <xsl:when test=
"normalize-space($type) != '' and
165 $others[@type = $type][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
166 <!-- pgsql-docs: added id attribute here for linking to it -->
167 <div class=
"indexdiv" id=
"indexdiv-Symbols">
169 <xsl:call-template name=
"gentext">
170 <xsl:with-param name=
"key" select=
"'index symbols'"/>
174 <xsl:apply-templates select=
"$others[count(.|key('primary', &primary;)[&scope;][1]) = 1]"
175 mode=
"index-symbol-div">
176 <xsl:with-param name=
"position" select=
"position()"/>
177 <xsl:with-param name=
"scope" select=
"$scope"/>
178 <xsl:with-param name=
"role" select=
"$role"/>
179 <xsl:with-param name=
"type" select=
"$type"/>
180 <xsl:sort select=
"translate(&primary;, &lowercase;, &uppercase;)"/>
181 </xsl:apply-templates>
185 <xsl:when test=
"normalize-space($type) != ''">
186 <!-- Output nothing, as there isn't a match for $other using this $type -->
189 <!-- pgsql-docs: added id attribute here for linking to it -->
190 <div class=
"indexdiv" id=
"indexdiv-Symbols">
192 <xsl:call-template name=
"gentext">
193 <xsl:with-param name=
"key" select=
"'index symbols'"/>
197 <xsl:apply-templates select=
"$others[count(.|key('primary',
198 &primary;)[&scope;][1]) = 1]"
199 mode=
"index-symbol-div">
200 <xsl:with-param name=
"position" select=
"position()"/>
201 <xsl:with-param name=
"scope" select=
"$scope"/>
202 <xsl:with-param name=
"role" select=
"$role"/>
203 <xsl:with-param name=
"type" select=
"$type"/>
204 <xsl:sort select=
"translate(&primary;, &lowercase;, &uppercase;)"/>
205 </xsl:apply-templates>
212 <xsl:apply-templates select=
"$alphabetical[count(.|key('letter',
213 translate(substring(&primary;, 1, 1),
214 &lowercase;,&uppercase;))[&scope;][1]) = 1]"
215 mode=
"index-div-basic">
216 <xsl:with-param name=
"position" select=
"position()"/>
217 <xsl:with-param name=
"scope" select=
"$scope"/>
218 <xsl:with-param name=
"role" select=
"$role"/>
219 <xsl:with-param name=
"type" select=
"$type"/>
220 <xsl:sort select=
"translate(&primary;, &lowercase;, &uppercase;)"/>
221 </xsl:apply-templates>
225 <xsl:template match=
"indexterm" mode=
"index-div-basic">
226 <xsl:param name=
"scope" select=
"."/>
227 <xsl:param name=
"role" select=
"''"/>
228 <xsl:param name=
"type" select=
"''"/>
230 <xsl:variable name=
"key"
231 select=
"translate(substring(&primary;, 1, 1),
232 &lowercase;,&uppercase;)"/>
234 <xsl:if test=
"key('letter', $key)[&scope;]
235 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
236 <div class=
"indexdiv">
237 <!-- pgsql-docs: added id attribute here for linking to it -->
238 <xsl:attribute name=
"id">
239 <xsl:value-of select=
"concat('indexdiv-', $key)"/>
242 <xsl:if test=
"contains(concat(&lowercase;, &uppercase;), $key)">
244 <xsl:value-of select=
"translate($key, &lowercase;, &uppercase;)"/>
248 <xsl:apply-templates select=
"key('letter', $key)[&scope;]
249 [count(.|key('primary', &primary;)
251 mode=
"index-primary">
252 <xsl:with-param name=
"position" select=
"position()"/>
253 <xsl:with-param name=
"scope" select=
"$scope"/>
254 <xsl:with-param name=
"role" select=
"$role"/>
255 <xsl:with-param name=
"type" select=
"$type"/>
256 <xsl:sort select=
"translate(&primary;, &lowercase;, &uppercase;)"/>
257 </xsl:apply-templates>
264 <xsl:template match=
"indexterm" mode=
"index-div-quicklinks">
265 <xsl:param name=
"scope" select=
"."/>
266 <xsl:param name=
"role" select=
"''"/>
267 <xsl:param name=
"type" select=
"''"/>
269 <xsl:variable name=
"key"
270 select=
"translate(substring(&primary;, 1, 1),
271 &lowercase;,&uppercase;)"/>
273 <xsl:if test=
"key('letter', $key)[&scope;]
274 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
275 <xsl:if test=
"contains(concat(&lowercase;, &uppercase;), $key)">
278 <xsl:attribute name=
"href">
279 <xsl:value-of select=
"concat('#indexdiv-', $key)"/>
281 <xsl:value-of select=
"translate($key, &lowercase;, &uppercase;)"/>
288 <!-- upper case HTML anchors for backward compatibility -->
290 <xsl:template name=
"object.id">
291 <xsl:param name=
"object" select=
"."/>
293 <xsl:when test=
"$object/@id">
294 <xsl:value-of select=
"translate($object/@id, &lowercase;, &uppercase;)"/>
296 <xsl:when test=
"$object/@xml:id">
297 <xsl:value-of select=
"$object/@xml:id"/>
299 <xsl:when test=
"$generate.consistent.ids != 0">
300 <!-- Make $object the current node -->
301 <xsl:for-each select=
"$object">
302 <xsl:text>id-
</xsl:text>
303 <xsl:number level=
"multiple" count=
"*"/>
307 <xsl:value-of select=
"generate-id($object)"/>
313 <!-- Add an id link to each section heading. -->
315 <!-- from html/sections.xsl -->
316 <xsl:template name=
"section.heading">
317 <xsl:param name=
"section" select=
"."/>
318 <xsl:param name=
"level" select=
"1"/>
319 <xsl:param name=
"allow-anchors" select=
"1"/>
320 <xsl:param name=
"title"/>
321 <xsl:param name=
"class" select=
"'title'"/>
323 <xsl:variable name=
"id">
325 <!-- Make sure the subtitle doesn't get the same id as the title -->
326 <xsl:when test=
"self::subtitle">
327 <xsl:call-template name=
"object.id">
328 <xsl:with-param name=
"object" select=
"."/>
331 <!-- if title is in an *info wrapper, get the grandparent -->
332 <xsl:when test=
"contains(local-name(..), 'info')">
333 <xsl:call-template name=
"object.id">
334 <xsl:with-param name=
"object" select=
"../.."/>
338 <xsl:call-template name=
"object.id">
339 <xsl:with-param name=
"object" select=
".."/>
345 <!-- HTML H level is one higher than section level -->
346 <xsl:variable name=
"hlevel">
348 <!-- highest valid HTML H level is H6; so anything nested deeper
349 than 5 levels down just becomes H6 -->
350 <xsl:when test=
"$level > 5">6</xsl:when>
352 <xsl:value-of select=
"$level + 1"/>
356 <xsl:element name=
"h{$hlevel}" namespace=
"http://www.w3.org/1999/xhtml">
357 <xsl:attribute name=
"class"><xsl:value-of select=
"$class"/></xsl:attribute>
358 <xsl:if test=
"$css.decoration != '0'">
359 <xsl:if test=
"$hlevel<3">
360 <xsl:attribute name=
"style">clear: both
</xsl:attribute>
363 <xsl:if test=
"$allow-anchors != 0">
364 <xsl:call-template name=
"anchor">
365 <xsl:with-param name=
"node" select=
"$section"/>
366 <xsl:with-param name=
"conditional" select=
"0"/>
369 <xsl:copy-of select=
"$title"/>
370 <!-- pgsql-docs: begin -->
371 <xsl:call-template name=
"pg.id.link">
372 <xsl:with-param name=
"object" select=
"$section"/>
374 <!-- pgsql-docs: end -->
379 <!-- Add an id link after the last term of a varlistentry. -->
381 <!-- overrides html/lists.xsl -->
382 <xsl:template match=
"varlistentry/term">
385 <!-- Add the link after the last term -->
386 <xsl:if test=
"position() = last()">
387 <xsl:call-template name=
"pg.id.link">
388 <xsl:with-param name=
"object" select=
"parent::varlistentry"/>
394 <!-- Create a link pointing to an id within the document -->
395 <xsl:template name=
"pg.id.link">
396 <xsl:param name=
"object" select=
"."/>
398 <xsl:when test=
"$object/@id or $object/@xml:id">
399 <xsl:text> </xsl:text>
401 <xsl:attribute name=
"href">
402 <xsl:text>#
</xsl:text>
403 <xsl:call-template name=
"object.id">
404 <xsl:with-param name=
"object" select=
"$object"/>
407 <xsl:attribute name=
"class">
408 <xsl:text>id_link
</xsl:text>
410 <xsl:text>#
</xsl:text>
414 <!-- Only complain about varlistentries if at least one entry in
415 the list has an id -->
416 <xsl:if test=
"name($object) != 'varlistentry'
417 or $object/parent::variablelist/varlistentry[@id]">
418 <xsl:message terminate=
"yes">
419 <xsl:text>ERROR: id attribute missing on
<</xsl:text>
420 <xsl:value-of select =
"name($object)"/>
421 <xsl:text>> element under
</xsl:text>
422 <xsl:for-each select=
"$object/ancestor::*">
423 <xsl:text>/
</xsl:text>
424 <xsl:value-of select =
"name(.)"/>
425 <xsl:if test=
"@id|@xml:id">
426 <xsl:text>[@
</xsl:text>
427 <xsl:value-of select =
"name(@id|@xml:id)"/>
428 <xsl:text> = '
</xsl:text>
429 <xsl:value-of select =
"@id"/>
430 <xsl:text>']
</xsl:text>
439 <!-- make generated ids reproducible
440 (https://github.com/docbook/xslt10-stylesheets/issues/54) -->
442 <!-- from html/autoidx.xsl -->
444 <xsl:key name=
"primaryonly"
446 use=
"normalize-space(primary)"/>
448 <xsl:template match=
"indexterm" mode=
"index-primary">
449 <xsl:param name=
"scope" select=
"."/>
450 <xsl:param name=
"role" select=
"''"/>
451 <xsl:param name=
"type" select=
"''"/>
453 <xsl:variable name=
"key" select=
"&primary;"/>
454 <xsl:variable name=
"refs" select=
"key('primary', $key)[&scope;]"/>
456 <xsl:if test=
"$autolink.index.see != 0">
457 <!-- add internal id attribute to form see and seealso links -->
458 <xsl:attribute name=
"id">
459 <!-- pgsql-docs: begin -->
460 <xsl:text>ientry-
</xsl:text>
461 <xsl:call-template name=
"object.id"/>
462 <!-- pgsql-docs: end -->
465 <xsl:for-each select=
"$refs/primary">
466 <xsl:if test=
"@id or @xml:id">
468 <xsl:when test=
"$generate.id.attributes = 0">
469 <a name=
"{(@id|@xml:id)[1]}"/>
473 <xsl:call-template name=
"id.attribute"/>
479 <xsl:value-of select=
"primary"/>
481 <xsl:when test=
"$index.links.to.section = 1">
482 <xsl:for-each select=
"$refs[@zone != '' or generate-id() = generate-id(key('primary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]">
483 <xsl:apply-templates select=
"." mode=
"reference">
484 <xsl:with-param name=
"position" select=
"position()"/>
485 <xsl:with-param name=
"scope" select=
"$scope"/>
486 <xsl:with-param name=
"role" select=
"$role"/>
487 <xsl:with-param name=
"type" select=
"$type"/>
488 </xsl:apply-templates>
492 <xsl:for-each select=
"$refs[not(see)
493 and not(secondary)][&scope;]">
494 <xsl:apply-templates select=
"." mode=
"reference">
495 <xsl:with-param name=
"position" select=
"position()"/>
496 <xsl:with-param name=
"scope" select=
"$scope"/>
497 <xsl:with-param name=
"role" select=
"$role"/>
498 <xsl:with-param name=
"type" select=
"$type"/>
499 </xsl:apply-templates>
504 <xsl:if test=
"$refs[not(secondary)]/*[self::see]">
505 <xsl:apply-templates select=
"$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
507 <xsl:with-param name=
"position" select=
"position()"/>
508 <xsl:with-param name=
"scope" select=
"$scope"/>
509 <xsl:with-param name=
"role" select=
"$role"/>
510 <xsl:with-param name=
"type" select=
"$type"/>
511 <xsl:sort select=
"translate(see, &lowercase;, &uppercase;)"/>
512 </xsl:apply-templates>
516 <xsl:when test=
"$refs/secondary or $refs[not(secondary)]/*[self::seealso]">
519 <xsl:apply-templates select=
"$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]"
520 mode=
"index-seealso">
521 <xsl:with-param name=
"position" select=
"position()"/>
522 <xsl:with-param name=
"scope" select=
"$scope"/>
523 <xsl:with-param name=
"role" select=
"$role"/>
524 <xsl:with-param name=
"type" select=
"$type"/>
525 <xsl:sort select=
"translate(seealso, &lowercase;, &uppercase;)"/>
526 </xsl:apply-templates>
527 <xsl:apply-templates select=
"$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]"
528 mode=
"index-secondary">
529 <xsl:with-param name=
"position" select=
"position()"/>
530 <xsl:with-param name=
"scope" select=
"$scope"/>
531 <xsl:with-param name=
"role" select=
"$role"/>
532 <xsl:with-param name=
"type" select=
"$type"/>
533 <xsl:sort select=
"translate(&secondary;, &lowercase;, &uppercase;)"/>
534 </xsl:apply-templates>
538 <!-- HTML5 requires dd for each dt -->
539 <xsl:when test=
"$div.element = 'section'">
545 <xsl:template match=
"indexterm" mode=
"index-see" xmlns:xlink='http://www.w3.org/
1999/xlink'
>
546 <xsl:param name=
"scope" select=
"."/>
547 <xsl:param name=
"role" select=
"''"/>
548 <xsl:param name=
"type" select=
"''"/>
550 <xsl:variable name=
"see" select=
"normalize-space(see)"/>
552 <!-- can only link to primary, which should appear before comma
553 in see "primary, secondary" entry -->
554 <xsl:variable name=
"seeprimary">
556 <xsl:when test=
"contains($see, ',')">
557 <xsl:value-of select=
"substring-before($see, ',')"/>
560 <xsl:value-of select=
"$see"/>
565 <xsl:variable name=
"seetarget" select=
"key('primaryonly', $seeprimary)[1]"/>
567 <xsl:variable name=
"linkend">
568 <xsl:if test=
"$seetarget">
569 <!-- pgsql-docs: begin -->
570 <xsl:text>#ientry-
</xsl:text>
571 <xsl:call-template name=
"object.id">
572 <xsl:with-param name=
"object" select=
"$seetarget"/>
574 <!-- pgsql-docs: end -->
578 <xsl:text> (
</xsl:text>
579 <xsl:call-template name=
"gentext">
580 <xsl:with-param name=
"key" select=
"'see'"/>
582 <xsl:text> </xsl:text>
584 <!-- manual links have precedence -->
585 <xsl:when test=
"see/@linkend or see/@xlink:href">
586 <xsl:call-template name=
"simple.xlink">
587 <xsl:with-param name=
"node" select=
"see"/>
588 <xsl:with-param name=
"content" select=
"$see"/>
591 <xsl:when test=
"$autolink.index.see = 0">
592 <xsl:value-of select=
"$see"/>
594 <xsl:when test=
"$seetarget">
595 <a href=
"{$linkend}">
596 <xsl:value-of select=
"$see"/>
600 <xsl:value-of select=
"$see"/>
603 <xsl:text>)
</xsl:text>
606 <xsl:template match=
"indexterm" mode=
"index-seealso" xmlns:xlink='http://www.w3.org/
1999/xlink'
>
607 <xsl:param name=
"scope" select=
"."/>
608 <xsl:param name=
"role" select=
"''"/>
609 <xsl:param name=
"type" select=
"''"/>
611 <xsl:for-each select=
"seealso">
612 <xsl:sort select=
"translate(., &lowercase;, &uppercase;)"/>
614 <xsl:variable name=
"seealso" select=
"normalize-space(.)"/>
616 <!-- can only link to primary, which should appear before comma
617 in seealso "primary, secondary" entry -->
618 <xsl:variable name=
"seealsoprimary">
620 <xsl:when test=
"contains($seealso, ',')">
621 <xsl:value-of select=
"substring-before($seealso, ',')"/>
624 <xsl:value-of select=
"$seealso"/>
629 <xsl:variable name=
"seealsotarget" select=
"key('primaryonly', $seealsoprimary)[1]"/>
631 <xsl:variable name=
"linkend">
632 <xsl:if test=
"$seealsotarget">
633 <!-- pgsql-docs: begin -->
634 <xsl:text>#ientry-
</xsl:text>
635 <xsl:call-template name=
"object.id">
636 <xsl:with-param name=
"object" select=
"$seealsotarget"/>
638 <!-- pgsql-docs: end -->
643 <xsl:text>(
</xsl:text>
644 <xsl:call-template name=
"gentext">
645 <xsl:with-param name=
"key" select=
"'seealso'"/>
647 <xsl:text> </xsl:text>
649 <!-- manual links have precedence -->
650 <xsl:when test=
"@linkend or see/@xlink:href">
651 <xsl:call-template name=
"simple.xlink">
652 <xsl:with-param name=
"node" select=
"."/>
653 <xsl:with-param name=
"content" select=
"$seealso"/>
656 <xsl:when test=
"$autolink.index.see = 0">
657 <xsl:value-of select=
"$seealso"/>
659 <xsl:when test=
"$seealsotarget">
660 <a href=
"{$linkend}">
661 <xsl:value-of select=
"$seealso"/>
665 <xsl:value-of select=
"$seealso"/>
668 <xsl:text>)
</xsl:text>
671 <xsl:if test=
"$div.element = 'section'">