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