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">
4%common.entities;
5]>
6<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7                version="1.0">
8
9<!--
10  This file contains XSLT stylesheet customizations that are common to
11  all HTML output variants (chunked and single-page).
12  -->
13
14<!-- Parameters -->
15<xsl:param name="make.valid.html" select="1"></xsl:param>
16<xsl:param name="generate.id.attributes" select="1"></xsl:param>
17<xsl:param name="make.graphic.viewport" select="0"/>
18<xsl:param name="link.mailto.url">pgsql-docs@lists.postgresql.org</xsl:param>
19<xsl:param name="toc.max.depth">2</xsl:param>
20
21<!--
22  The below allows the stylesheets provided by the website to be applied fully
23  to the generated HTML.
24  -->
25<xsl:template name="body.attributes">
26  <xsl:attribute name="id">docContent</xsl:attribute>
27  <xsl:attribute name="class">container-fluid col-10</xsl:attribute>
28</xsl:template>
29
30<!-- Change display of some elements -->
31
32<xsl:template match="command">
33  <xsl:call-template name="inline.monoseq"/>
34</xsl:template>
35
36<xsl:template match="confgroup" mode="bibliography.mode">
37  <span>
38    <xsl:call-template name="common.html.attributes"/>
39    <xsl:call-template name="id.attribute"/>
40    <xsl:apply-templates select="conftitle/text()" mode="bibliography.mode"/>
41    <xsl:text>, </xsl:text>
42    <xsl:apply-templates select="confdates/text()" mode="bibliography.mode"/>
43    <xsl:copy-of select="$biblioentry.item.separator"/>
44  </span>
45</xsl:template>
46
47<xsl:template match="isbn" mode="bibliography.mode">
48  <span>
49    <xsl:call-template name="common.html.attributes"/>
50    <xsl:call-template name="id.attribute"/>
51    <xsl:text>ISBN </xsl:text>
52    <xsl:apply-templates mode="bibliography.mode"/>
53    <xsl:copy-of select="$biblioentry.item.separator"/>
54  </span>
55</xsl:template>
56
57
58<!-- table of contents configuration -->
59
60<xsl:param name="generate.toc">
61appendix  toc,title
62article/appendix  nop
63article   toc,title
64book      toc,title
65chapter   toc,title
66part      toc,title
67preface   toc,title
68qandadiv  toc
69qandaset  toc
70reference toc,title
71sect1     toc
72sect2     toc
73sect3     toc
74sect4     toc
75sect5     toc
76section   toc
77set       toc,title
78</xsl:param>
79
80<xsl:param name="generate.section.toc.level" select="1"></xsl:param>
81
82<!-- include refentry under sect1 in tocs -->
83<xsl:template match="sect1" mode="toc">
84  <xsl:param name="toc-context" select="."/>
85  <xsl:call-template name="subtoc">
86    <xsl:with-param name="toc-context" select="$toc-context"/>
87    <xsl:with-param name="nodes" select="sect2|refentry
88                                         |bridgehead[$bridgehead.in.toc != 0]"/>
89  </xsl:call-template>
90</xsl:template>
91
92
93<!-- Put index "quicklinks" (A | B | C | ...) at the top of the bookindex page. -->
94
95<!-- from html/autoidx.xsl -->
96
97<xsl:template name="generate-basic-index">
98  <xsl:param name="scope" select="NOTANODE"/>
99
100  <xsl:variable name="role">
101    <xsl:if test="$index.on.role != 0">
102      <xsl:value-of select="@role"/>
103    </xsl:if>
104  </xsl:variable>
105
106  <xsl:variable name="type">
107    <xsl:if test="$index.on.type != 0">
108      <xsl:value-of select="@type"/>
109    </xsl:if>
110  </xsl:variable>
111
112  <xsl:variable name="terms"
113                select="//indexterm
114                        [count(.|key('letter',
115                          translate(substring(&primary;, 1, 1),
116                             &lowercase;,
117                             &uppercase;))
118                          [&scope;][1]) = 1
119                          and not(@class = 'endofrange')]"/>
120
121  <xsl:variable name="alphabetical"
122                select="$terms[contains(concat(&lowercase;, &uppercase;),
123                                        substring(&primary;, 1, 1))]"/>
124
125  <xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;,
126                                                 &uppercase;),
127                                             substring(&primary;, 1, 1)))]"/>
128
129  <div class="index">
130    <!-- pgsql-docs: begin added stuff -->
131    <p class="indexdiv-quicklinks">
132      <a href="#indexdiv-Symbols">
133        <xsl:call-template name="gentext">
134          <xsl:with-param name="key" select="'index symbols'"/>
135        </xsl:call-template>
136      </a>
137      <xsl:apply-templates select="$alphabetical[count(.|key('letter',
138                                   translate(substring(&primary;, 1, 1),
139                                   &lowercase;,&uppercase;))[&scope;][1]) = 1]"
140                           mode="index-div-quicklinks">
141        <xsl:with-param name="position" select="position()"/>
142        <xsl:with-param name="scope" select="$scope"/>
143        <xsl:with-param name="role" select="$role"/>
144        <xsl:with-param name="type" select="$type"/>
145        <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
146      </xsl:apply-templates>
147    </p>
148    <!-- pgsql-docs: end added stuff -->
149
150    <xsl:if test="$others">
151      <xsl:choose>
152        <xsl:when test="normalize-space($type) != '' and
153                        $others[@type = $type][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
154          <!-- pgsql-docs: added id attribute here for linking to it -->
155          <div class="indexdiv" id="indexdiv-Symbols">
156            <h3>
157              <xsl:call-template name="gentext">
158                <xsl:with-param name="key" select="'index symbols'"/>
159              </xsl:call-template>
160            </h3>
161            <dl>
162              <xsl:apply-templates select="$others[count(.|key('primary', &primary;)[&scope;][1]) = 1]"
163                                   mode="index-symbol-div">
164                <xsl:with-param name="position" select="position()"/>
165                <xsl:with-param name="scope" select="$scope"/>
166                <xsl:with-param name="role" select="$role"/>
167                <xsl:with-param name="type" select="$type"/>
168                <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
169              </xsl:apply-templates>
170            </dl>
171          </div>
172        </xsl:when>
173        <xsl:when test="normalize-space($type) != ''">
174          <!-- Output nothing, as there isn't a match for $other using this $type -->
175        </xsl:when>
176        <xsl:otherwise>
177          <!-- pgsql-docs: added id attribute here for linking to it -->
178          <div class="indexdiv" id="indexdiv-Symbols">
179            <h3>
180              <xsl:call-template name="gentext">
181                <xsl:with-param name="key" select="'index symbols'"/>
182              </xsl:call-template>
183            </h3>
184            <dl>
185              <xsl:apply-templates select="$others[count(.|key('primary',
186                                          &primary;)[&scope;][1]) = 1]"
187                                  mode="index-symbol-div">
188                <xsl:with-param name="position" select="position()"/>
189                <xsl:with-param name="scope" select="$scope"/>
190                <xsl:with-param name="role" select="$role"/>
191                <xsl:with-param name="type" select="$type"/>
192                <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
193              </xsl:apply-templates>
194            </dl>
195          </div>
196        </xsl:otherwise>
197      </xsl:choose>
198    </xsl:if>
199
200    <xsl:apply-templates select="$alphabetical[count(.|key('letter',
201                                 translate(substring(&primary;, 1, 1),
202                                           &lowercase;,&uppercase;))[&scope;][1]) = 1]"
203                         mode="index-div-basic">
204      <xsl:with-param name="position" select="position()"/>
205      <xsl:with-param name="scope" select="$scope"/>
206      <xsl:with-param name="role" select="$role"/>
207      <xsl:with-param name="type" select="$type"/>
208      <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
209    </xsl:apply-templates>
210  </div>
211</xsl:template>
212
213<xsl:template match="indexterm" mode="index-div-basic">
214  <xsl:param name="scope" select="."/>
215  <xsl:param name="role" select="''"/>
216  <xsl:param name="type" select="''"/>
217
218  <xsl:variable name="key"
219                select="translate(substring(&primary;, 1, 1),
220                         &lowercase;,&uppercase;)"/>
221
222  <xsl:if test="key('letter', $key)[&scope;]
223                [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
224    <div class="indexdiv">
225      <!-- pgsql-docs: added id attribute here for linking to it -->
226      <xsl:attribute name="id">
227        <xsl:value-of select="concat('indexdiv-', $key)"/>
228      </xsl:attribute>
229
230      <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
231        <h3>
232          <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
233        </h3>
234      </xsl:if>
235      <dl>
236        <xsl:apply-templates select="key('letter', $key)[&scope;]
237                                     [count(.|key('primary', &primary;)
238                                     [&scope;][1])=1]"
239                             mode="index-primary">
240          <xsl:with-param name="position" select="position()"/>
241          <xsl:with-param name="scope" select="$scope"/>
242          <xsl:with-param name="role" select="$role"/>
243          <xsl:with-param name="type" select="$type"/>
244          <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
245        </xsl:apply-templates>
246      </dl>
247    </div>
248  </xsl:if>
249</xsl:template>
250
251<!-- pgsql-docs -->
252<xsl:template match="indexterm" mode="index-div-quicklinks">
253  <xsl:param name="scope" select="."/>
254  <xsl:param name="role" select="''"/>
255  <xsl:param name="type" select="''"/>
256
257  <xsl:variable name="key"
258                select="translate(substring(&primary;, 1, 1),
259                        &lowercase;,&uppercase;)"/>
260
261  <xsl:if test="key('letter', $key)[&scope;]
262                [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
263    <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
264      |
265      <a>
266        <xsl:attribute name="href">
267          <xsl:value-of select="concat('#indexdiv-', $key)"/>
268        </xsl:attribute>
269        <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
270      </a>
271    </xsl:if>
272  </xsl:if>
273</xsl:template>
274
275
276<!-- upper case HTML anchors for backward compatibility -->
277
278<xsl:template name="object.id">
279  <xsl:param name="object" select="."/>
280  <xsl:choose>
281    <xsl:when test="$object/@id">
282      <xsl:value-of select="translate($object/@id, &lowercase;, &uppercase;)"/>
283    </xsl:when>
284    <xsl:when test="$object/@xml:id">
285      <xsl:value-of select="$object/@xml:id"/>
286    </xsl:when>
287    <xsl:when test="$generate.consistent.ids != 0">
288      <!-- Make $object the current node -->
289      <xsl:for-each select="$object">
290        <xsl:text>id-</xsl:text>
291        <xsl:number level="multiple" count="*"/>
292      </xsl:for-each>
293    </xsl:when>
294    <xsl:otherwise>
295      <xsl:value-of select="generate-id($object)"/>
296    </xsl:otherwise>
297  </xsl:choose>
298</xsl:template>
299
300</xsl:stylesheet>
301