source: stylesheets/xhtml/lfs-index.xsl@ 1bec700

Last change on this file since 1bec700 was 1bec700, checked in by Manuel Canales Esparcia <manuel@…>, 20 years ago

Internationalization support into the stylesheets, first phase.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/testing/BOOK@4290 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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