Skip to content

Commit 97f16b8

Browse files
committed
doc: Add index letter links to XSLT HTML build
This matches what was already implemented in the DSSSL HTML build.
1 parent 1f87181 commit 97f16b8

File tree

1 file changed

+187
-0
lines changed

1 file changed

+187
-0
lines changed

doc/src/sgml/stylesheet.xsl

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?xml version='1.0'?>
2+
<!DOCTYPE xsl:stylesheet [
3+
<!ENTITY % common.entities SYSTEM "http://docbook.sourceforge.net/release/xsl/current/common/entities.ent">
4+
%common.entities;
5+
]>
26
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
37
version='1.0'
48
xmlns="http://www.w3.org/TR/xhtml1/transitional"
@@ -59,4 +63,187 @@ section toc
5963
set toc,title
6064
</xsl:param>
6165

66+
67+
<!-- Put index "quicklinks" (A | B | C | ...) at the top of the bookindex page. -->
68+
69+
<!-- from html/autoidx.xsl -->
70+
71+
<xsl:template name="generate-basic-index">
72+
<xsl:param name="scope" select="NOTANODE"/>
73+
74+
<xsl:variable name="role">
75+
<xsl:if test="$index.on.role != 0">
76+
<xsl:value-of select="@role"/>
77+
</xsl:if>
78+
</xsl:variable>
79+
80+
<xsl:variable name="type">
81+
<xsl:if test="$index.on.type != 0">
82+
<xsl:value-of select="@type"/>
83+
</xsl:if>
84+
</xsl:variable>
85+
86+
<xsl:variable name="terms"
87+
select="//indexterm
88+
[count(.|key('letter',
89+
translate(substring(&primary;, 1, 1),
90+
&lowercase;,
91+
&uppercase;))
92+
[&scope;][1]) = 1
93+
and not(@class = 'endofrange')]"/>
94+
95+
<xsl:variable name="alphabetical"
96+
select="$terms[contains(concat(&lowercase;, &uppercase;),
97+
substring(&primary;, 1, 1))]"/>
98+
99+
<xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;,
100+
&uppercase;),
101+
substring(&primary;, 1, 1)))]"/>
102+
103+
<div class="index">
104+
<!-- pgsql-docs: begin added stuff -->
105+
<p class="indexdiv-quicklinks">
106+
<a href="#indexdiv-Symbols">
107+
<xsl:call-template name="gentext">
108+
<xsl:with-param name="key" select="'index symbols'"/>
109+
</xsl:call-template>
110+
</a>
111+
<xsl:apply-templates select="$alphabetical[count(.|key('letter',
112+
translate(substring(&primary;, 1, 1),
113+
&lowercase;,&uppercase;))[&scope;][1]) = 1]"
114+
mode="index-div-quicklinks">
115+
<xsl:with-param name="position" select="position()"/>
116+
<xsl:with-param name="scope" select="$scope"/>
117+
<xsl:with-param name="role" select="$role"/>
118+
<xsl:with-param name="type" select="$type"/>
119+
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
120+
</xsl:apply-templates>
121+
</p>
122+
<!-- pgsql-docs: end added stuff -->
123+
124+
<xsl:if test="$others">
125+
<xsl:choose>
126+
<xsl:when test="normalize-space($type) != '' and
127+
$others[@type = $type][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
128+
<!-- pgsql-docs: added id attribute here for linking to it -->
129+
<div class="indexdiv" id="indexdiv-Symbols">
130+
<h3>
131+
<xsl:call-template name="gentext">
132+
<xsl:with-param name="key" select="'index symbols'"/>
133+
</xsl:call-template>
134+
</h3>
135+
<dl>
136+
<xsl:apply-templates select="$others[count(.|key('primary', &primary;)[&scope;][1]) = 1]"
137+
mode="index-symbol-div">
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"/>
142+
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
143+
</xsl:apply-templates>
144+
</dl>
145+
</div>
146+
</xsl:when>
147+
<xsl:when test="normalize-space($type) != ''">
148+
<!-- Output nothing, as there isn't a match for $other using this $type -->
149+
</xsl:when>
150+
<xsl:otherwise>
151+
<!-- pgsql-docs: added id attribute here for linking to it -->
152+
<div class="indexdiv" id="indexdiv-Symbols">
153+
<h3>
154+
<xsl:call-template name="gentext">
155+
<xsl:with-param name="key" select="'index symbols'"/>
156+
</xsl:call-template>
157+
</h3>
158+
<dl>
159+
<xsl:apply-templates select="$others[count(.|key('primary',
160+
&primary;)[&scope;][1]) = 1]"
161+
mode="index-symbol-div">
162+
<xsl:with-param name="position" select="position()"/>
163+
<xsl:with-param name="scope" select="$scope"/>
164+
<xsl:with-param name="role" select="$role"/>
165+
<xsl:with-param name="type" select="$type"/>
166+
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
167+
</xsl:apply-templates>
168+
</dl>
169+
</div>
170+
</xsl:otherwise>
171+
</xsl:choose>
172+
</xsl:if>
173+
174+
<xsl:apply-templates select="$alphabetical[count(.|key('letter',
175+
translate(substring(&primary;, 1, 1),
176+
&lowercase;,&uppercase;))[&scope;][1]) = 1]"
177+
mode="index-div-basic">
178+
<xsl:with-param name="position" select="position()"/>
179+
<xsl:with-param name="scope" select="$scope"/>
180+
<xsl:with-param name="role" select="$role"/>
181+
<xsl:with-param name="type" select="$type"/>
182+
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
183+
</xsl:apply-templates>
184+
</div>
185+
</xsl:template>
186+
187+
<xsl:template match="indexterm" mode="index-div-basic">
188+
<xsl:param name="scope" select="."/>
189+
<xsl:param name="role" select="''"/>
190+
<xsl:param name="type" select="''"/>
191+
192+
<xsl:variable name="key"
193+
select="translate(substring(&primary;, 1, 1),
194+
&lowercase;,&uppercase;)"/>
195+
196+
<xsl:if test="key('letter', $key)[&scope;]
197+
[count(.|key('primary', &primary;)[&scope;][1]) = 1]">
198+
<div class="indexdiv">
199+
<!-- pgsql-docs: added id attribute here for linking to it -->
200+
<xsl:attribute name="id">
201+
<xsl:value-of select="concat('indexdiv-', $key)"/>
202+
</xsl:attribute>
203+
204+
<xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
205+
<h3>
206+
<xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
207+
</h3>
208+
</xsl:if>
209+
<dl>
210+
<xsl:apply-templates select="key('letter', $key)[&scope;]
211+
[count(.|key('primary', &primary;)
212+
[&scope;][1])=1]"
213+
mode="index-primary">
214+
<xsl:with-param name="position" select="position()"/>
215+
<xsl:with-param name="scope" select="$scope"/>
216+
<xsl:with-param name="role" select="$role"/>
217+
<xsl:with-param name="type" select="$type"/>
218+
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
219+
</xsl:apply-templates>
220+
</dl>
221+
</div>
222+
</xsl:if>
223+
</xsl:template>
224+
225+
<!-- pgsql-docs -->
226+
<xsl:template match="indexterm" mode="index-div-quicklinks">
227+
<xsl:param name="scope" select="."/>
228+
<xsl:param name="role" select="''"/>
229+
<xsl:param name="type" select="''"/>
230+
231+
<xsl:variable name="key"
232+
select="translate(substring(&primary;, 1, 1),
233+
&lowercase;,&uppercase;)"/>
234+
235+
<xsl:if test="key('letter', $key)[&scope;]
236+
[count(.|key('primary', &primary;)[&scope;][1]) = 1]">
237+
<xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
238+
|
239+
<a>
240+
<xsl:attribute name="href">
241+
<xsl:value-of select="concat('#indexdiv-', $key)"/>
242+
</xsl:attribute>
243+
<xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
244+
</a>
245+
</xsl:if>
246+
</xsl:if>
247+
</xsl:template>
248+
62249
</xsl:stylesheet>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy