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