source: stylesheets/xhtml/lfs-index.xsl@ 28badf4

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 6.0 6.1 6.2 6.2.0 6.2.0-rc1 6.2.0-rc2 6.3 6.3-rc1 6.3-rc2 6.3-rc3 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 28badf4 was ee1c43a, checked in by Bruce Dubbs <bdubbs@…>, 19 years ago

Update to index xsl to add anchors

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@3429 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 9.3 KB
Line 
1<?xml version='1.0' encoding='ISO-8859-1'?>
2<!DOCTYPE xsl:stylesheet [
3<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
4<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
5<!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
6<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())'>
7]>
8
9<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns="http://www.w3.org/1999/xhtml"
11 version="1.0">
12
13 <!--Filename-->
14 <xsl:template match="index" mode="recursive-chunk-filename">
15 <xsl:text>longindex.html</xsl:text>
16 </xsl:template>
17
18 <!--Title-->
19 <xsl:param name="index-title">Index</xsl:param>
20
21 <xsl:template match="index" mode="title.markup">
22 <xsl:call-template name="gentext">
23 <xsl:with-param name="key" select="$index-title"/>
24 </xsl:call-template>
25 </xsl:template>
26
27 <xsl:template name="index.titlepage">
28 <div class="titlepage">
29 <h1 class="index">
30 <xsl:call-template name="gentext">
31 <xsl:with-param name="key" select="$index-title"/>
32 </xsl:call-template>
33 </h1>
34 </div>
35 </xsl:template>
36
37 <!--Divisions-->
38 <xsl:template match="indexterm" mode="index-div">
39 <xsl:param name="scope" select="."/>
40 <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
41 <xsl:variable name="divtitle" select="translate($key, &lowercase;, &uppercase;)"/>
42 <!-- Make sure that we don't generate a div if there are no terms in scope -->
43 <xsl:if test="key('letter', $key)[&scope;] [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
44 <div class="indexdiv">
45 <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
46 <h2>
47 <xsl:choose>
48 <xsl:when test="$divtitle = 'A'">
49 <a id="package-index" name="package-index"/>
50 <xsl:call-template name="gentext">
51 <xsl:with-param name="key">Packages</xsl:with-param>
52 </xsl:call-template>
53 </xsl:when>
54 <xsl:when test="$divtitle = 'B'">
55 <a id="program-index" name="program-index"/>
56 <xsl:call-template name="gentext">
57 <xsl:with-param name="key">Programs</xsl:with-param>
58 </xsl:call-template>
59 </xsl:when>
60 <xsl:when test="$divtitle = 'C'">
61 <a id="library-index" name="library-index"/>
62 <xsl:call-template name="gentext">
63 <xsl:with-param name="key">Libraries</xsl:with-param>
64 </xsl:call-template>
65 </xsl:when>
66 <xsl:when test="$divtitle = 'D'">
67 <a id="kernel-config-index" name="kernel-config-index"/>
68 <xsl:call-template name="gentext">
69 <xsl:with-param name="key">Kernel Configuration</xsl:with-param>
70 </xsl:call-template>
71 </xsl:when>
72 <xsl:when test="$divtitle = 'E'">
73 <a id="config-file-index" name="config-file-index"/>
74 <xsl:call-template name="gentext">
75 <xsl:with-param name="key">Configuration Files</xsl:with-param>
76 </xsl:call-template>
77 </xsl:when>
78 <xsl:when test="$divtitle = 'F'">
79 <a id="bootscript-index" name="bootscript-index"/>
80 <xsl:call-template name="gentext">
81 <xsl:with-param name="key">Bootscripts</xsl:with-param>
82 </xsl:call-template>
83 </xsl:when>
84 <xsl:when test="$divtitle = 'G'">
85 <a id="other-index" name="other-index"/>
86 <xsl:call-template name="gentext">
87 <xsl:with-param name="key">Others</xsl:with-param>
88 </xsl:call-template>
89 </xsl:when>
90 <xsl:otherwise>
91 <xsl:value-of select="$divtitle"/>
92 </xsl:otherwise>
93 </xsl:choose>
94 </h2>
95 </xsl:if>
96 <ul>
97 <xsl:apply-templates select="key('letter', $key)[&scope;]
98 [count(.|key('primary', &primary;)[&scope;][1])=1]" mode="index-primary">
99 <xsl:with-param name="scope" select="$scope"/>
100 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
101 </xsl:apply-templates>
102 </ul>
103 </div>
104 </xsl:if>
105 </xsl:template>
106
107 <!-- Dropping the separator from here-->
108 <xsl:template match="indexterm" mode="reference">
109 <xsl:param name="scope" select="."/>
110 <xsl:call-template name="reference">
111 <xsl:with-param name="zones" select="normalize-space(@zone)"/>
112 <xsl:with-param name="scope" select="$scope"/>
113 </xsl:call-template>
114 </xsl:template>
115
116 <!-- Changing the output tags and re-addind the separator-->
117 <xsl:template match="indexterm" mode="index-primary">
118 <xsl:param name="scope" select="."/>
119 <xsl:variable name="key" select="&primary;"/>
120 <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
121 <li>
122 <strong class="item">
123 <xsl:value-of select="primary"/>
124 <xsl:text>: </xsl:text>
125 </strong><div class='indexref'>
126 <xsl:for-each select="$refs[generate-id() = generate-id(key('primary-section',
127 concat($key, &#34; &#34;, generate-id((ancestor-or-self::book |ancestor-or-self::part
128 |ancestor-or-self::chapter |ancestor-or-self::appendix |ancestor-or-self::preface
129 |ancestor-or-self::sect1 |ancestor-or-self::sect2 |ancestor-or-self::sect3
130 |ancestor-or-self::sect4 |ancestor-or-self::sect5 |ancestor-or-self::index)[last()])))[&scope;][1])]">
131 <xsl:apply-templates select="." mode="reference">
132 <xsl:with-param name="scope" select="$scope"/>
133 </xsl:apply-templates>
134 </xsl:for-each>
135 <xsl:if test="$refs/secondary">
136 <ul>
137 <xsl:apply-templates select="$refs[secondary and count(.|key('secondary',
138 concat($key, &#34; &#34;, normalize-space(concat(secondary/@sortas,
139 secondary[not(@sortas)]))))[&scope;][1]) = 1]" mode="index-secondary">
140 <xsl:with-param name="scope" select="$scope"/>
141 <xsl:sort select="translate(normalize-space(concat(secondary/@sortas,
142 secondary[not(@sortas)])), &lowercase;, &uppercase;)"/>
143 </xsl:apply-templates>
144 </ul>
145 </xsl:if>
146 </div></li>
147 </xsl:template>
148
149 <xsl:template match="indexterm" mode="index-secondary">
150 <xsl:param name="scope" select="."/>
151 <xsl:variable name="key" select="concat(&primary;, &#34; &#34;,
152 normalize-space(concat(secondary/@sortas, secondary[not(@sortas)])))"/>
153 <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
154 <li>
155 <strong class="secitem">
156 <xsl:value-of select="secondary"/>
157 <xsl:text>: </xsl:text>
158 </strong>
159 <xsl:for-each select="$refs[generate-id() = generate-id(key('secondary-section',
160 concat($key, &#34; &#34;, generate-id((ancestor-or-self::book |ancestor-or-self::part
161 |ancestor-or-self::chapter |ancestor-or-self::appendix |ancestor-or-self::preface
162 |ancestor-or-self::sect1 |ancestor-or-self::sect2 |ancestor-or-self::sect3
163 |ancestor-or-self::sect4 |ancestor-or-self::sect5 |ancestor-or-self::index)[last()])))[&scope;][1])]">
164 <xsl:apply-templates select="." mode="reference">
165 <xsl:with-param name="scope" select="$scope"/>
166 </xsl:apply-templates>
167 </xsl:for-each>
168 </li>
169 </xsl:template>
170
171 <!--Links (This template also fix a bug in the original code)-->
172 <xsl:template name="reference">
173 <xsl:param name="scope" select="."/>
174 <xsl:param name="zones"/>
175 <xsl:choose>
176 <xsl:when test="contains($zones, ' ')">
177 <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
178 <xsl:variable name="zone2" select="substring-after($zones, ' ')"/>
179 <xsl:variable name="target" select="key('sections', $zone)[&scope;]"/>
180 <xsl:variable name="target2" select="key('sections', $zone2)[&scope;]"/>
181 <a>
182 <xsl:attribute name="href">
183 <xsl:call-template name="href.target.uri">
184 <xsl:with-param name="object" select="$target[1]"/>
185 </xsl:call-template>
186 </xsl:attribute>
187 <xsl:apply-templates select="$target[1]" mode="index-title-content"/>
188 </a>
189 <xsl:text> -- </xsl:text>
190 <a>
191 <xsl:attribute name="href">
192 <xsl:call-template name="href.target.uri">
193 <xsl:with-param name="object" select="$target2[1]"/>
194 </xsl:call-template>
195 </xsl:attribute>
196 <xsl:call-template name="gentext">
197 <xsl:with-param name="key">description</xsl:with-param>
198 </xsl:call-template>
199 </a><br />
200 </xsl:when>
201 <xsl:otherwise>
202 <xsl:variable name="zone" select="$zones"/>
203 <xsl:variable name="target" select="key('sections', $zone)[&scope;]"/>
204 <a>
205 <xsl:attribute name="href">
206 <xsl:call-template name="href.target.uri">
207 <xsl:with-param name="object" select="$target[1]"/>
208 </xsl:call-template>
209 </xsl:attribute>
210 <xsl:apply-templates select="$target[1]" mode="index-title-content"/>
211 </a>
212 </xsl:otherwise>
213 </xsl:choose>
214 </xsl:template>
215
216 <!-- Dropping unneeded anchors -->
217 <xsl:template match="indexterm"/>
218
219</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.