source: stylesheets/xhtml/lfs-index.xsl@ 5e363b3

10.0 10.1 11.0 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 ken/refactor-virt krejzi/svn lazarus nosym perl-modules qt5new systemd-11177 systemd-13485 trunk xry111/git-date xry111/git-date-for-trunk xry111/git-date-test
Last change on this file since 5e363b3 was 5e363b3, checked in by Bruce Dubbs <bdubbs@…>, 17 years ago

Update index formatting

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

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