source: clfs-sysroot/BOOK/stylesheets/xhtml/lfs-index.xsl@ 33bdda8

Last change on this file since 33bdda8 was 02095ae, checked in by Jim Gifford <clfs@…>, 19 years ago

r3633@server (orig r1649): jciccone | 2006-05-25 16:48:42 -0700
Added the Initial clfs-2.0 branch using sysroot builds.

  • Property mode set to 100644
File size: 8.4 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 <xsl:call-template name="gentext">
50 <xsl:with-param name="key">Packages</xsl:with-param>
51 </xsl:call-template>
52 </xsl:when>
53 <xsl:when test="$divtitle = 'B'">
54 <xsl:call-template name="gentext">
55 <xsl:with-param name="key">Programs</xsl:with-param>
56 </xsl:call-template>
57 </xsl:when>
58 <xsl:when test="$divtitle = 'C'">
59 <xsl:call-template name="gentext">
60 <xsl:with-param name="key">Libraries</xsl:with-param>
61 </xsl:call-template>
62 </xsl:when>
63 <xsl:when test="$divtitle = 'D'">
64 <xsl:call-template name="gentext">
65 <xsl:with-param name="key">Scripts</xsl:with-param>
66 </xsl:call-template>
67 </xsl:when>
68 <xsl:when test="$divtitle = 'E'">
69 <xsl:call-template name="gentext">
70 <xsl:with-param name="key">Others</xsl:with-param>
71 </xsl:call-template>
72 </xsl:when>
73 <xsl:otherwise>
74 <xsl:value-of select="$divtitle"/>
75 </xsl:otherwise>
76 </xsl:choose>
77 </h2>
78 </xsl:if>
79 <ul>
80 <xsl:apply-templates select="key('letter', $key)[&scope;]
81 [count(.|key('primary', &primary;)[&scope;][1])=1]" mode="index-primary">
82 <xsl:with-param name="scope" select="$scope"/>
83 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
84 </xsl:apply-templates>
85 </ul>
86 </div>
87 </xsl:if>
88 </xsl:template>
89
90 <!-- Dropping the separator from here-->
91 <xsl:template match="indexterm" mode="reference">
92 <xsl:param name="scope" select="."/>
93 <xsl:call-template name="reference">
94 <xsl:with-param name="zones" select="normalize-space(@zone)"/>
95 <xsl:with-param name="scope" select="$scope"/>
96 </xsl:call-template>
97 </xsl:template>
98
99 <!-- Changing the output tags and re-addind the separator-->
100 <xsl:template match="indexterm" mode="index-primary">
101 <xsl:param name="scope" select="."/>
102 <xsl:variable name="key" select="&primary;"/>
103 <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
104 <li>
105 <strong class="item">
106 <xsl:value-of select="primary"/>
107 <xsl:text>: </xsl:text>
108 </strong>
109 <xsl:for-each select="$refs[generate-id() = generate-id(key('primary-section',
110 concat($key, &#34; &#34;, generate-id((ancestor-or-self::book |ancestor-or-self::part
111 |ancestor-or-self::chapter |ancestor-or-self::appendix |ancestor-or-self::preface
112 |ancestor-or-self::sect1 |ancestor-or-self::sect2 |ancestor-or-self::sect3
113 |ancestor-or-self::sect4 |ancestor-or-self::sect5 |ancestor-or-self::index)[last()])))[&scope;][1])]">
114 <xsl:apply-templates select="." mode="reference">
115 <xsl:with-param name="scope" select="$scope"/>
116 </xsl:apply-templates>
117 </xsl:for-each>
118 <xsl:if test="$refs/secondary">
119 <ul>
120 <xsl:apply-templates select="$refs[secondary and count(.|key('secondary',
121 concat($key, &#34; &#34;, normalize-space(concat(secondary/@sortas,
122 secondary[not(@sortas)]))))[&scope;][1]) = 1]" mode="index-secondary">
123 <xsl:with-param name="scope" select="$scope"/>
124 <xsl:sort select="translate(normalize-space(concat(secondary/@sortas,
125 secondary[not(@sortas)])), &lowercase;, &uppercase;)"/>
126 </xsl:apply-templates>
127 </ul>
128 </xsl:if>
129 </li>
130 </xsl:template>
131
132 <xsl:template match="indexterm" mode="index-secondary">
133 <xsl:param name="scope" select="."/>
134 <xsl:variable name="key" select="concat(&primary;, &#34; &#34;,
135 normalize-space(concat(secondary/@sortas, secondary[not(@sortas)])))"/>
136 <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
137 <li>
138 <strong class="secitem">
139 <xsl:value-of select="secondary"/>
140 <xsl:text>: </xsl:text>
141 </strong>
142 <xsl:for-each select="$refs[generate-id() = generate-id(key('secondary-section',
143 concat($key, &#34; &#34;, generate-id((ancestor-or-self::book |ancestor-or-self::part
144 |ancestor-or-self::chapter |ancestor-or-self::appendix |ancestor-or-self::preface
145 |ancestor-or-self::sect1 |ancestor-or-self::sect2 |ancestor-or-self::sect3
146 |ancestor-or-self::sect4 |ancestor-or-self::sect5 |ancestor-or-self::index)[last()])))[&scope;][1])]">
147 <xsl:apply-templates select="." mode="reference">
148 <xsl:with-param name="scope" select="$scope"/>
149 </xsl:apply-templates>
150 </xsl:for-each>
151 </li>
152 </xsl:template>
153
154 <!--Links (This template also fix a bug in the original code)-->
155 <xsl:template name="reference">
156 <xsl:param name="scope" select="."/>
157 <xsl:param name="zones"/>
158 <xsl:choose>
159 <xsl:when test="contains($zones, ' ')">
160 <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
161 <xsl:variable name="zone2" select="substring-after($zones, ' ')"/>
162 <xsl:variable name="target" select="key('sections', $zone)[&scope;]"/>
163 <xsl:variable name="target2" select="key('sections', $zone2)[&scope;]"/>
164 <a>
165 <xsl:attribute name="href">
166 <xsl:call-template name="href.target.uri">
167 <xsl:with-param name="object" select="$target[1]"/>
168 </xsl:call-template>
169 </xsl:attribute>
170 <xsl:apply-templates select="$target[1]" mode="index-title-content"/>
171 </a>
172 <xsl:text> -- </xsl:text>
173 <a>
174 <xsl:attribute name="href">
175 <xsl:call-template name="href.target.uri">
176 <xsl:with-param name="object" select="$target2[1]"/>
177 </xsl:call-template>
178 </xsl:attribute>
179 <xsl:call-template name="gentext">
180 <xsl:with-param name="key">description</xsl:with-param>
181 </xsl:call-template>
182 </a>
183 </xsl:when>
184 <xsl:otherwise>
185 <xsl:variable name="zone" select="$zones"/>
186 <xsl:variable name="target" select="key('sections', $zone)[&scope;]"/>
187 <a>
188 <xsl:attribute name="href">
189 <xsl:call-template name="href.target.uri">
190 <xsl:with-param name="object" select="$target[1]"/>
191 </xsl:call-template>
192 </xsl:attribute>
193 <xsl:apply-templates select="$target[1]" mode="index-title-content"/>
194 </a>
195 </xsl:otherwise>
196 </xsl:choose>
197 </xsl:template>
198
199 <!-- Dropping unneeded anchors -->
200 <xsl:template match="indexterm"/>
201
202</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.