source: stylesheets/xhtml/lfs-mixed.xsl@ cf6c97c

Last change on this file since cf6c97c was 3815390, checked in by Jim Gifford <clfs@…>, 19 years ago

r3442@server (orig r1581): manuel | 2006-05-13 10:05:45 -0700
Automatized "Total size of these packages" calculation.

  • Property mode set to 100644
File size: 11.5 KB
Line 
1<?xml version='1.0' encoding='ISO-8859-1'?>
2
3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns="http://www.w3.org/1999/xhtml"
5 version="1.0">
6
7 <!-- para -->
8 <xsl:template match="para">
9 <xsl:choose>
10 <xsl:when test="child::ulink[@url=' ']"/>
11 <xsl:otherwise>
12 <xsl:call-template name="paragraph">
13 <xsl:with-param name="class">
14 <xsl:if test="@role and $para.propagates.style != 0">
15 <xsl:value-of select="@role"/>
16 </xsl:if>
17 </xsl:with-param>
18 <xsl:with-param name="content">
19 <xsl:if test="position() = 1 and parent::listitem">
20 <xsl:call-template name="anchor">
21 <xsl:with-param name="node" select="parent::listitem"/>
22 </xsl:call-template>
23 </xsl:if>
24 <xsl:call-template name="anchor"/>
25 <xsl:apply-templates/>
26 </xsl:with-param>
27 </xsl:call-template>
28 </xsl:otherwise>
29 </xsl:choose>
30 </xsl:template>
31
32 <!-- screen -->
33 <xsl:template match="screen">
34 <xsl:choose>
35 <xsl:when test="child::* = userinput">
36 <pre class="userinput">
37 <xsl:apply-templates/>
38 </pre>
39 </xsl:when>
40 <xsl:otherwise>
41 <pre class="{name(.)}">
42 <xsl:apply-templates/>
43 </pre>
44 </xsl:otherwise>
45 </xsl:choose>
46 </xsl:template>
47
48 <xsl:template match="userinput">
49 <xsl:choose>
50 <xsl:when test="ancestor::screen">
51 <kbd class="command">
52 <xsl:apply-templates/>
53 </kbd>
54 </xsl:when>
55 <xsl:otherwise>
56 <xsl:apply-imports/>
57 </xsl:otherwise>
58 </xsl:choose>
59 </xsl:template>
60
61 <!-- segementedlist -->
62 <xsl:template match="seg">
63 <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
64 <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
65 <xsl:variable name="segtitles" select="$seglist/segtitle"/>
66 <!-- Note: segtitle is only going to be the right thing in a well formed
67 SegmentedList. If there are too many Segs or too few SegTitles,
68 you'll get something odd...maybe an error -->
69 <div class="seg">
70 <strong>
71 <span class="segtitle">
72 <xsl:apply-templates select="$segtitles[$segnum=position()]" mode="segtitle-in-seg"/>
73 <xsl:text>: </xsl:text>
74 </span>
75 </strong>
76 <span class="seg">
77 <xsl:apply-templates/>
78 </span>
79 </div>
80 </xsl:template>
81
82
83 <!-- variablelist -->
84 <xsl:template match="variablelist">
85 <xsl:choose>
86 <xsl:when test="@role">
87 <div class="{@role}">
88 <xsl:apply-imports/>
89 </div>
90 </xsl:when>
91 <xsl:otherwise>
92 <xsl:apply-imports/>
93 </xsl:otherwise>
94 </xsl:choose>
95 </xsl:template>
96
97
98 <!-- Body attributes -->
99 <xsl:template name="body.attributes">
100 <xsl:attribute name="id">
101 <xsl:text>lfs</xsl:text>
102 </xsl:attribute>
103 <xsl:attribute name="class">
104 <xsl:value-of select="substring-after(/book/bookinfo/subtitle, ' ')"/>
105 </xsl:attribute>
106 </xsl:template>
107
108 <!-- External URLs in italic font -->
109 <xsl:template match="ulink" name="ulink">
110 <a>
111 <xsl:if test="@id">
112 <xsl:attribute name="id">
113 <xsl:value-of select="@id"/>
114 </xsl:attribute>
115 </xsl:if>
116 <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
117 <i>
118 <xsl:choose>
119 <xsl:when test="count(child::node())=0">
120 <xsl:value-of select="@url"/>
121 </xsl:when>
122 <xsl:otherwise>
123 <xsl:apply-templates/>
124 </xsl:otherwise>
125 </xsl:choose>
126 </i>
127 </a>
128 </xsl:template>
129
130 <!-- The <code> xhtml tag have look issues in some browsers, like Konqueror and.
131 isn't semantically correct (a filename isn't a code fragment) We will use <tt> for now. -->
132 <xsl:template name="inline.monoseq">
133 <xsl:param name="content">
134 <xsl:call-template name="anchor"/>
135 <xsl:call-template name="simple.xlink">
136 <xsl:with-param name="content">
137 <xsl:apply-templates/>
138 </xsl:with-param>
139 </xsl:call-template>
140 </xsl:param>
141 <tt class="{local-name(.)}">
142 <xsl:if test="@dir">
143 <xsl:attribute name="dir">
144 <xsl:value-of select="@dir"/>
145 </xsl:attribute>
146 </xsl:if>
147 <xsl:copy-of select="$content"/>
148 </tt>
149 </xsl:template>
150
151 <xsl:template name="inline.boldmonoseq">
152 <xsl:param name="content">
153 <xsl:call-template name="anchor"/>
154 <xsl:call-template name="simple.xlink">
155 <xsl:with-param name="content">
156 <xsl:apply-templates/>
157 </xsl:with-param>
158 </xsl:call-template>
159 </xsl:param>
160 <!-- don't put <strong> inside figure, example, or table titles -->
161 <!-- or other titles that may already be represented with <strong>'s. -->
162 <xsl:choose>
163 <xsl:when test="local-name(..) = 'title' and (local-name(../..) = 'figure'
164 or local-name(../..) = 'example' or local-name(../..) = 'table' or local-name(../..) = 'formalpara')">
165 <tt class="{local-name(.)}">
166 <xsl:if test="@dir">
167 <xsl:attribute name="dir">
168 <xsl:value-of select="@dir"/>
169 </xsl:attribute>
170 </xsl:if>
171 <xsl:copy-of select="$content"/>
172 </tt>
173 </xsl:when>
174 <xsl:otherwise>
175 <strong class="{local-name(.)}">
176 <tt>
177 <xsl:if test="@dir">
178 <xsl:attribute name="dir">
179 <xsl:value-of select="@dir"/>
180 </xsl:attribute>
181 </xsl:if>
182 <xsl:copy-of select="$content"/>
183 </tt>
184 </strong>
185 </xsl:otherwise>
186 </xsl:choose>
187 </xsl:template>
188
189 <xsl:template name="inline.italicmonoseq">
190 <xsl:param name="content">
191 <xsl:call-template name="anchor"/>
192 <xsl:call-template name="simple.xlink">
193 <xsl:with-param name="content">
194 <xsl:apply-templates/>
195 </xsl:with-param>
196 </xsl:call-template>
197 </xsl:param>
198 <em class="{local-name(.)}">
199 <tt>
200 <xsl:if test="@dir">
201 <xsl:attribute name="dir">
202 <xsl:value-of select="@dir"/>
203 </xsl:attribute>
204 </xsl:if>
205 <xsl:copy-of select="$content"/>
206 </tt>
207 </em>
208 </xsl:template>
209
210 <!-- Adding bibliosource to titlepage -->
211 <xsl:template name="book.titlepage.recto">
212 <xsl:choose>
213 <xsl:when test="bookinfo/title">
214 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/title"/>
215 </xsl:when>
216 <xsl:when test="info/title">
217 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/title"/>
218 </xsl:when>
219 <xsl:when test="title">
220 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="title"/>
221 </xsl:when>
222 </xsl:choose>
223
224 <xsl:choose>
225 <xsl:when test="bookinfo/subtitle">
226 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/subtitle"/>
227 </xsl:when>
228 <xsl:when test="info/subtitle">
229 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/subtitle"/>
230 </xsl:when>
231 <xsl:when test="subtitle">
232 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="subtitle"/>
233 </xsl:when>
234 </xsl:choose>
235
236 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/corpauthor"/>
237 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/corpauthor"/>
238 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/authorgroup"/>
239 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/authorgroup"/>
240 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/author"/>
241 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/author"/>
242 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/othercredit"/>
243 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/othercredit"/>
244 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/releaseinfo"/>
245 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/releaseinfo"/>
246 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/copyright"/>
247 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/copyright"/>
248 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/bibliosource"/>
249 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/legalnotice"/>
250 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/legalnotice"/>
251 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/pubdate"/>
252 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/pubdate"/>
253 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/revision"/>
254 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/revision"/>
255 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/revhistory"/>
256 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/revhistory"/>
257 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/abstract"/>
258 <xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="info/abstract"/>
259 </xsl:template>
260
261 <xsl:template match="bibliosource" mode="book.titlepage.recto.auto.mode">
262 <div>
263 <p class="copyright">
264 <xsl:apply-templates/>
265 </p>
266 </div>
267 </xsl:template>
268
269 <!-- Total packages size calculation -->
270 <xsl:template match="returnvalue">
271 <xsl:call-template name="calculation">
272 <xsl:with-param name="scope" select="../../variablelist"/>
273 </xsl:call-template>
274 </xsl:template>
275
276 <xsl:template name="calculation">
277 <xsl:param name="scope"/>
278 <xsl:param name="total">0</xsl:param>
279 <xsl:param name="position">1</xsl:param>
280 <xsl:variable name="tokens" select="count($scope/varlistentry)"/>
281 <xsl:variable name="token" select="$scope/varlistentry[$position]/term/token"/>
282 <xsl:variable name="size" select="substring-before($token,' KB')"/>
283 <xsl:variable name="rawsize">
284 <xsl:choose>
285 <xsl:when test="contains($size,',')">
286 <xsl:value-of select="concat(substring-before($size,','),substring-after($size,','))"/>
287 </xsl:when>
288 <xsl:otherwise>
289 <xsl:value-of select="$size"/>
290 </xsl:otherwise>
291 </xsl:choose>
292 </xsl:variable>
293 <xsl:choose>
294 <xsl:when test="$position &lt;= $tokens">
295 <xsl:call-template name="calculation">
296 <xsl:with-param name="scope" select="$scope"/>
297 <xsl:with-param name="position" select="$position +1"/>
298 <xsl:with-param name="total" select="$total + $rawsize"/>
299 </xsl:call-template>
300 </xsl:when>
301 <xsl:otherwise>
302 <xsl:choose>
303 <xsl:when test="$total &lt; '1000'">
304 <xsl:value-of select="$total"/>
305 <xsl:text> KB</xsl:text>
306 </xsl:when>
307 <xsl:when test="$total &gt; '1000' and $total &lt; '5000'">
308 <xsl:value-of select="substring($total,1,1)"/>
309 <xsl:text>,</xsl:text>
310 <xsl:value-of select="substring($total,2)"/>
311 <xsl:text> KB</xsl:text>
312 </xsl:when>
313 <xsl:otherwise>
314 <xsl:value-of select="round($total div 1024)"/>
315 <xsl:text> MB</xsl:text>
316 </xsl:otherwise>
317 </xsl:choose>
318 </xsl:otherwise>
319 </xsl:choose>
320 </xsl:template>
321
322</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.