comparison gwt-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl@a3b170869c77
children 2a1dcee5e54a
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet
3 version="1.0"
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
6 <xsl:output method="html" encoding="UTF-8"/>
7
8 <xsl:param name="project-uuid">de3f3307-3429-4ff9-8f43-3fb2fcf21b27</xsl:param>
9 <xsl:param name="render-checkboxes" select="true()"/>
10 <xsl:param name="callback"/>
11
12 <xsl:param name="locale">de</xsl:param>
13
14 <xsl:decimal-format name="de" decimal-separator=',' grouping-separator='.'/>
15 <xsl:decimal-format name="en" decimal-separator='.' grouping-separator=','/>
16
17 <!-- XXX: This kind of i18n is cheesy.
18 It should be better done in an external resource. -->
19
20 <xsl:variable name="km-pattern">
21 <xsl:choose>
22 <xsl:when test="$locale = 'de'">0,##</xsl:when>
23 <xsl:otherwise>0.##</xsl:otherwise>
24 </xsl:choose>
25 </xsl:variable>
26
27 <xsl:variable name="i18n-gauge">
28 <xsl:choose>
29 <xsl:when test="$locale = 'de'">Pegel</xsl:when>
30 <xsl:otherwise>Gauge</xsl:otherwise>
31 </xsl:choose>
32 </xsl:variable>
33
34 <xsl:variable name="i18n-event">
35 <xsl:choose>
36 <xsl:when test="$locale = 'de'">Ereignis</xsl:when>
37 <xsl:otherwise>Event</xsl:otherwise>
38 </xsl:choose>
39 </xsl:variable>
40
41 <xsl:variable name="i18n-legend">
42 <xsl:choose>
43 <xsl:when test="$locale = 'de'">Legende</xsl:when>
44 <xsl:otherwise>Caption</xsl:otherwise>
45 </xsl:choose>
46 </xsl:variable>
47
48 <xsl:variable name="i18n-color">
49 <xsl:choose>
50 <xsl:when test="$locale = 'de'">Farbe</xsl:when>
51 <xsl:otherwise>Color</xsl:otherwise>
52 </xsl:choose>
53 </xsl:variable>
54
55 <xsl:variable name="i18n-meaning">
56 <xsl:choose>
57 <xsl:when test="$locale = 'de'">Bedeutung</xsl:when>
58 <xsl:otherwise>Meaning</xsl:otherwise>
59 </xsl:choose>
60 </xsl:variable>
61
62 <xsl:variable name="i18n-around-mnq">
63 <xsl:choose>
64 <xsl:when test="$locale = 'de'">um MNQ</xsl:when>
65 <xsl:otherwise>around MNQ</xsl:otherwise>
66 </xsl:choose>
67 </xsl:variable>
68
69 <xsl:variable name="i18n-around-mq">
70 <xsl:choose>
71 <xsl:when test="$locale = 'de'">um MQ</xsl:when>
72 <xsl:otherwise>around MQ</xsl:otherwise>
73 </xsl:choose>
74 </xsl:variable>
75
76 <xsl:variable name="i18n-around-mhq">
77 <xsl:choose>
78 <xsl:when test="$locale = 'de'">um MHQ</xsl:when>
79 <xsl:otherwise>around MHQ</xsl:otherwise>
80 </xsl:choose>
81 </xsl:variable>
82
83 <xsl:variable name="i18n-above-hq5">
84 <xsl:choose>
85 <xsl:when test="$locale = 'de'">über HQ5</xsl:when>
86 <xsl:otherwise>above HQ5</xsl:otherwise>
87 </xsl:choose>
88 </xsl:variable>
89
90 <!-- TODO: Format dates according locale. -->
91
92 <xsl:template match="@*" mode="min">
93 <xsl:if test="position() = 1">
94 <xsl:value-of select="number(.)"/>
95 </xsl:if>
96 </xsl:template>
97
98 <xsl:template match="@*" mode="max">
99 <xsl:if test="position() = last()">
100 <xsl:value-of select="number(.)"/>
101 </xsl:if>
102 </xsl:template>
103
104 <xsl:variable name="global-min">
105 <xsl:choose>
106 <xsl:when test="count(/fixings/events/event/sector) &gt; 0">
107 <xsl:apply-templates mode="min" select="/fixings/events/event/sector/@from">
108 <xsl:sort data-type="number" select="."/>
109 </xsl:apply-templates>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:value-of select="number(/fixings/river/@from)"/>
113 </xsl:otherwise>
114 </xsl:choose>
115 </xsl:variable>
116
117 <xsl:variable name="global-max">
118 <xsl:choose>
119 <xsl:when test="count(/fixings/events/event/sector) &gt; 0">
120 <xsl:apply-templates mode="max" select="/fixings/events/event/sector/@to">
121 <xsl:sort data-type="number" select="."/>
122 </xsl:apply-templates>
123 </xsl:when>
124 <xsl:otherwise>
125 <xsl:value-of select="number(/fixings/river/@to)"/>
126 </xsl:otherwise>
127 </xsl:choose>
128 </xsl:variable>
129
130 <xsl:template name="percent">
131 <xsl:param name="sector"/>
132
133 <xsl:variable name="start">
134 <xsl:choose>
135 <xsl:when test="number($sector/@from) &lt; $global-min">
136 <xsl:value-of select="$global-min"/>
137 </xsl:when>
138 <xsl:otherwise>
139 <xsl:value-of select="number($sector/@from)"/>
140 </xsl:otherwise>
141 </xsl:choose>
142 </xsl:variable>
143
144 <xsl:variable name="end">
145 <xsl:choose>
146 <xsl:when test="number($sector/@to) &gt; $global-max">
147 <xsl:value-of select="$global-max"/>
148 </xsl:when>
149 <xsl:otherwise>
150 <xsl:value-of select="number($sector/@to)"/>
151 </xsl:otherwise>
152 </xsl:choose>
153 </xsl:variable>
154
155 <xsl:choose>
156 <xsl:when test="$end &lt; $start">
157 <xsl:value-of select="number(0)"/>
158 </xsl:when>
159 <xsl:otherwise>
160 <xsl:value-of select="100.0 * (($end - $start) div ($global-max - $global-min))"/>
161 </xsl:otherwise>
162 </xsl:choose>
163 </xsl:template>
164
165 <xsl:template name="emit-gap-gauge">
166 <xsl:param name="gauge"/>
167 <xsl:call-template name="internal-emit-gap">
168 <xsl:with-param name="sector" select="$gauge"/>
169 <xsl:with-param name="preds" select="$gauge/preceding-sibling::gauge"/>
170 </xsl:call-template>
171 </xsl:template>
172
173 <xsl:template name="emit-gap">
174 <xsl:param name="sector"/>
175 <xsl:call-template name="internal-emit-gap">
176 <xsl:with-param name="sector" select="$sector"/>
177 <xsl:with-param name="preds" select="$sector/preceding-sibling::sector"/>
178 </xsl:call-template>
179 </xsl:template>
180
181 <xsl:template name="internal-emit-gap">
182 <xsl:param name="sector"/>
183 <xsl:param name="preds"/>
184
185 <xsl:variable name="start">
186 <xsl:choose>
187 <xsl:when test="number($sector/@from) &lt; $global-min">
188 <xsl:value-of select="$global-min"/>
189 </xsl:when>
190 <xsl:otherwise>
191 <xsl:value-of select="$sector/@from"/>
192 </xsl:otherwise>
193 </xsl:choose>
194 </xsl:variable>
195
196 <xsl:if test="$start &lt; $global-max">
197 <xsl:variable name="num-preds" select="count($preds)"/>
198 <xsl:variable name="prev-end">
199 <xsl:choose>
200 <xsl:when test="count($preds) &lt; 1">
201 <xsl:value-of select="$global-min"/>
202 </xsl:when>
203 <xsl:otherwise>
204 <xsl:variable name="prev-to" select="number($preds[last()]/@to)"/>
205 <xsl:choose>
206 <xsl:when test="$prev-to &lt; $global-min">
207 <xsl:value-of select="$global-min"/>
208 </xsl:when>
209 <xsl:otherwise>
210 <xsl:value-of select="$prev-to"/>
211 </xsl:otherwise>
212 </xsl:choose>
213 </xsl:otherwise>
214 </xsl:choose>
215 </xsl:variable>
216
217 <xsl:if test="$prev-end &lt; $global-max">
218 <xsl:variable name="gap-len" select="$start - $prev-end"/>
219 <xsl:if test="$gap-len &gt; 0.005">
220 <div>
221 <xsl:attribute name="style">
222 <xsl:text>width:</xsl:text>
223 <xsl:value-of select="100.0 * ($gap-len div ($global-max - $global-min))"/>
224 <xsl:text>%;float:left</xsl:text>
225 </xsl:attribute>
226 <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
227 </div>
228 </xsl:if>
229 </xsl:if>
230 </xsl:if>
231 </xsl:template>
232
233 <xsl:template match="sector" mode="sectors">
234 <xsl:call-template name="emit-gap">
235 <xsl:with-param name="sector" select="."/>
236 </xsl:call-template>
237 <div>
238 <xsl:attribute name="style">
239 <xsl:text>background:</xsl:text>
240 <xsl:choose>
241 <xsl:when test="@class = '0'">green</xsl:when>
242 <xsl:when test="@class = '1'">blue</xsl:when>
243 <xsl:when test="@class = '2'">magenta</xsl:when>
244 <xsl:when test="@class = '3'">red</xsl:when>
245 <xsl:otherwise>black</xsl:otherwise>
246 </xsl:choose>
247 <xsl:text>;width:</xsl:text>
248 <xsl:call-template name="percent">
249 <xsl:with-param name="sector" select="."/>
250 </xsl:call-template>
251 <xsl:text>%</xsl:text>
252 <xsl:text>;float:left</xsl:text>
253 </xsl:attribute>
254 <xsl:attribute name="title">
255 <xsl:text>km </xsl:text>
256 <xsl:value-of select="format-number(@from, $km-pattern, $locale)"/>
257 <xsl:text> - </xsl:text>
258 <xsl:value-of select="format-number(@to, $km-pattern, $locale)"/>
259 <xsl:choose>
260 <xsl:when test="@class = '0'"> / Q <xsl:value-of select="$i18n-around-mnq"/></xsl:when>
261 <xsl:when test="@class = '1'"> / Q <xsl:value-of select="$i18n-around-mq"/></xsl:when>
262 <xsl:when test="@class = '2'"> / Q <xsl:value-of select="$i18n-around-mhq"/></xsl:when>
263 <xsl:when test="@class = '3'"> / Q <xsl:value-of select="$i18n-above-hq5"/></xsl:when>
264 </xsl:choose>
265 <xsl:text>&#10;</xsl:text>
266 <xsl:value-of select="$i18n-gauge"/>
267 <xsl:text>:</xsl:text>
268 <xsl:call-template name="find-gauges">
269 <xsl:with-param name="start" select="@from"/>
270 <xsl:with-param name="stop" select="@to"/>
271 </xsl:call-template>
272 </xsl:attribute>
273 <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
274 </div>
275 </xsl:template>
276
277 <xsl:template match="event">
278 <tr id="{@cid}">
279 <xsl:if test="$render-checkboxes">
280 <td>
281 <input type="checkbox" name="{$project-uuid}:{@cid}" checked="true" onclick="{$callback}"/>
282 </td>
283 </xsl:if>
284 <td>
285 <xsl:apply-templates mode="sectors"/>
286 </td>
287 <td align="center">
288 <xsl:attribute name="title"><xsl:value-of select="@description"/></xsl:attribute>
289 <xsl:value-of select="@date"/>
290 </td>
291 </tr>
292 </xsl:template>
293
294 <xsl:template match="text()" mode="gauge-list"/>
295 <xsl:template match="gauge" mode="gauge-list">
296 <xsl:text> </xsl:text><xsl:value-of select="@name"/>
297 </xsl:template>
298
299 <xsl:template name="find-gauges">
300 <xsl:param name="start"/>
301 <xsl:param name="stop"/>
302 <xsl:apply-templates mode="gauge-list"
303 select="/fixings/gauges/gauge[not((number(@to) &lt; number($start)) or (number(@from) &gt; number($stop)))]"/>
304 </xsl:template>
305
306 <xsl:template match="gauge" mode="gauges">
307 <xsl:call-template name="emit-gap-gauge">
308 <xsl:with-param name="gauge" select="."/>
309 </xsl:call-template>
310
311 <div>
312 <xsl:attribute name="style">
313 <xsl:text>overflow:hidden;background:</xsl:text>
314 <xsl:choose>
315 <xsl:when test="(count(preceding::*) mod 2) = 0">#ada96e</xsl:when>
316 <xsl:otherwise>silver</xsl:otherwise>
317 </xsl:choose>
318 <xsl:text>;width:</xsl:text>
319 <xsl:call-template name="percent">
320 <xsl:with-param name="sector" select="."/>
321 </xsl:call-template>
322 <xsl:text>%</xsl:text>
323 <xsl:text>;float:left</xsl:text>
324 </xsl:attribute>
325
326 <xsl:attribute name="title">
327 <xsl:variable name="start">
328 <xsl:choose>
329 <xsl:when test="number(@from) &lt; $global-min">
330 <xsl:value-of select="$global-min"/>
331 </xsl:when>
332 <xsl:otherwise>
333 <xsl:value-of select="number(@from)"/>
334 </xsl:otherwise>
335 </xsl:choose>
336 </xsl:variable>
337
338 <xsl:variable name="end">
339 <xsl:choose>
340 <xsl:when test="number(@to) &gt; $global-max">
341 <xsl:value-of select="$global-max"/>
342 </xsl:when>
343 <xsl:otherwise>
344 <xsl:value-of select="number(@to)"/>
345 </xsl:otherwise>
346 </xsl:choose>
347 </xsl:variable>
348
349 <xsl:value-of select="@name"/>
350 <xsl:text>: km </xsl:text>
351 <xsl:value-of select="format-number($start, $km-pattern, $locale)"/>
352 <xsl:text> - </xsl:text>
353 <xsl:value-of select="format-number($end, $km-pattern, $locale)"/>
354 </xsl:attribute>
355 <nobr><xsl:value-of select="@name"/></nobr>
356 </div>
357 </xsl:template>
358
359 <xsl:template match="events">
360 <table width="97%" border="1" cellspacing="0" cellpadding="0"
361 style="font-size: 10pt;font-family:Arial;Verdana,sans-serif">
362 <colgroup>
363 <xsl:if test="$render-checkboxes">
364 <col width="20px"/>
365 </xsl:if>
366 <col width="*"/>
367 <col width="75px"/>
368 </colgroup>
369 <tr>
370 <xsl:if test="$render-checkboxes">
371 <th>&#160;</th>
372 </xsl:if>
373 <th><xsl:apply-templates mode="gauges" select="/fixings/gauges"/></th>
374 <th><xsl:value-of select="$i18n-event"/></th>
375 </tr>
376 <xsl:apply-templates/>
377 </table>
378 </xsl:template>
379
380 <xsl:template match="/">
381 <xsl:apply-templates/>
382 <hr/>
383 <table border="1" cellspacing="0" cellpadding="0">
384 <caption><xsl:value-of select="$i18n-legend"/></caption>
385 <tr>
386 <th><xsl:value-of select="$i18n-color"/></th>
387 <th colspan="2"><xsl:value-of select="$i18n-meaning"/></th>
388 </tr>
389 <xsl:if test="count(/fixings/events/event/sector[@class = '0']) &gt; 0">
390 <tr>
391 <td style="background: green">&#160;</td>
392 <td><xsl:value-of select="$i18n-around-mnq"/></td>
393 <td>Q &#8712; [0, (MNQ+MQ)/2)</td>
394 </tr>
395 </xsl:if>
396 <xsl:if test="count(/fixings/events/event/sector[@class = '1']) &gt; 0">
397 <tr>
398 <td style="background: blue">&#160;</td>
399 <td><xsl:value-of select="$i18n-around-mq"/></td>
400 <td>Q &#8712; [(MNQ+MQ)/2, (MQ+MHQ)/2)</td>
401 </tr>
402 </xsl:if>
403 <xsl:if test="count(/fixings/events/event/sector[@class = '2']) &gt; 0">
404 <tr>
405 <td style="background: magenta">&#160;</td>
406 <td><xsl:value-of select="$i18n-around-mhq"/></td>
407 <td>Q &#8712; [(MQ+MHQ)/2, HQ5)</td>
408 </tr>
409 </xsl:if>
410 <xsl:if test="count(/fixings/events/event/sector[@class = '3']) &gt; 0">
411 <tr>
412 <td style="background: red">&#160;</td>
413 <td><xsl:value-of select="$i18n-above-hq5"/></td>
414 <td>Q &#8712; [HQ5, &#8734;)</td>
415 </tr>
416 </xsl:if>
417 </table>
418 </xsl:template>
419
420 <xsl:template match="text()"/>
421 <xsl:template match="text()" mode="sectors"/>
422 <xsl:template match="text()" mode="gauges"/>
423
424 </xsl:stylesheet>

http://dive4elements.wald.intevation.org