Mercurial > dive4elements > river
comparison flys-artifacts/contrib/fixoverview2html.xsl @ 3429:3353672f9ba2
FixA: XSL overview transform renders the names of the gauges into the head line.
flys-artifacts/trunk@5088 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 20 Jul 2012 13:51:36 +0000 |
parents | 5f47e68a1130 |
children | 0568ffd29bb2 |
comparison
equal
deleted
inserted
replaced
3428:842b7b635701 | 3429:3353672f9ba2 |
---|---|
21 <xsl:if test="position() = last()"> | 21 <xsl:if test="position() = last()"> |
22 <xsl:value-of select="number(.)"/> | 22 <xsl:value-of select="number(.)"/> |
23 </xsl:if> | 23 </xsl:if> |
24 </xsl:template> | 24 </xsl:template> |
25 | 25 |
26 <xsl:variable name="events-min"> | 26 <xsl:variable name="global-min"> |
27 <xsl:choose> | 27 <xsl:choose> |
28 <xsl:when test="count(/fixings/events/event/sector) > 0"> | 28 <xsl:when test="count(/fixings/events/event) > 0"> |
29 <xsl:apply-templates mode="min" select="/fixings/events/event/sector/@from"> | 29 <xsl:apply-templates mode="min" select="/fixings/events/event/sector/@from"> |
30 <xsl:sort data-type="number" select="."/> | 30 <xsl:sort data-type="number" select="."/> |
31 </xsl:apply-templates> | 31 </xsl:apply-templates> |
32 </xsl:when> | 32 </xsl:when> |
33 <xsl:otherwise> | 33 <xsl:otherwise> |
34 <xsl:value-of select="number(/fixings/river/@from)"/> | 34 <xsl:value-of select="number(/fixings/river/@from)"/> |
35 </xsl:otherwise> | 35 </xsl:otherwise> |
36 </xsl:choose> | 36 </xsl:choose> |
37 </xsl:variable> | 37 </xsl:variable> |
38 | 38 |
39 <xsl:variable name="events-max"> | 39 <xsl:variable name="global-max"> |
40 <xsl:choose> | 40 <xsl:choose> |
41 <xsl:when test="count(/fixings/events/event/sector) > 0"> | 41 <xsl:when test="count(/fixings/events/event) > 0"> |
42 <xsl:apply-templates mode="max" select="/fixings/events/event/sector/@to"> | 42 <xsl:apply-templates mode="max" select="/fixings/events/event/sector/@to"> |
43 <xsl:sort data-type="number" select="."/> | 43 <xsl:sort data-type="number" select="."/> |
44 </xsl:apply-templates> | 44 </xsl:apply-templates> |
45 </xsl:when> | 45 </xsl:when> |
46 <xsl:otherwise> | 46 <xsl:otherwise> |
49 </xsl:choose> | 49 </xsl:choose> |
50 </xsl:variable> | 50 </xsl:variable> |
51 | 51 |
52 <xsl:template name="percent"> | 52 <xsl:template name="percent"> |
53 <xsl:param name="sector"/> | 53 <xsl:param name="sector"/> |
54 <xsl:variable name="rfrom" select="number($events-min)"/> | 54 |
55 <xsl:variable name="rto" select="number($events-max)"/> | 55 <xsl:variable name="start"> |
56 <xsl:variable name="rlength" select="$rto - $rfrom"/> | |
57 | |
58 <xsl:variable name="sfrom" select="number($sector/@from)"/> | |
59 <xsl:variable name="sto" select="number($sector/@to)"/> | |
60 <xsl:variable name="slength" select="$sto - $sfrom"/> | |
61 <xsl:value-of select="100.0 * ($slength div $rlength)"/> | |
62 </xsl:template> | |
63 | |
64 <xsl:template name="emit-gap"> | |
65 <xsl:param name="sector"/> | |
66 <xsl:variable name="preds" select="$sector/preceding-sibling::sector"/> | |
67 <xsl:variable name="num-preds" select="count($preds)"/> | |
68 <xsl:variable name="glength"> | |
69 <xsl:choose> | 56 <xsl:choose> |
70 <xsl:when test="$num-preds < 1"> | 57 <xsl:when test="number($sector/@from) < $global-min"> |
71 <xsl:variable name="rfrom" select="number($events-min)"/> | 58 <xsl:value-of select="$global-min"/> |
72 <xsl:value-of select="number($sector/@from) - $rfrom"/> | |
73 </xsl:when> | 59 </xsl:when> |
74 <xsl:otherwise> | 60 <xsl:otherwise> |
75 <xsl:variable name="bend" select="number($preds[last()]/@to)"/> | 61 <xsl:value-of select="number($sector/@from)"/> |
76 <xsl:value-of select="number($sector/@from) - $bend"/> | |
77 </xsl:otherwise> | 62 </xsl:otherwise> |
78 </xsl:choose> | 63 </xsl:choose> |
79 </xsl:variable> | 64 </xsl:variable> |
65 | |
66 <xsl:variable name="end"> | |
67 <xsl:choose> | |
68 <xsl:when test="number($sector/@to) > $global-max"> | |
69 <xsl:value-of select="$global-max"/> | |
70 </xsl:when> | |
71 <xsl:otherwise> | |
72 <xsl:value-of select="number($sector/@to)"/> | |
73 </xsl:otherwise> | |
74 </xsl:choose> | |
75 </xsl:variable> | |
76 | |
80 <xsl:choose> | 77 <xsl:choose> |
81 <xsl:when test="number($glength) < 0.05 "/> | 78 <xsl:when test="$end < $start"> |
79 <xsl:value-of select="number(0)"/> | |
80 </xsl:when> | |
82 <xsl:otherwise> | 81 <xsl:otherwise> |
83 <div> | 82 <xsl:value-of select="100.0 * (($end - $start) div ($global-max - $global-min))"/> |
84 <xsl:attribute name="style"> | |
85 <xsl:text>width:</xsl:text> | |
86 <xsl:variable name="rfrom" select="number($events-min)"/> | |
87 <xsl:variable name="rto" select="number($events-max)"/> | |
88 <xsl:variable name="rlength" select="$rto - $rfrom"/> | |
89 <xsl:value-of select="100.0 * ($glength div $rlength)"/> | |
90 <xsl:text>%;float:left</xsl:text> | |
91 </xsl:attribute> | |
92 <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> | |
93 </div> | |
94 </xsl:otherwise> | 83 </xsl:otherwise> |
95 </xsl:choose> | 84 </xsl:choose> |
85 </xsl:template> | |
86 | |
87 <xsl:template name="emit-gap-gauge"> | |
88 <xsl:param name="gauge"/> | |
89 <xsl:call-template name="internal-emit-gap"> | |
90 <xsl:with-param name="sector" select="$gauge"/> | |
91 <xsl:with-param name="preds" select="$gauge/preceding-sibling::gauge"/> | |
92 </xsl:call-template> | |
93 </xsl:template> | |
94 | |
95 <xsl:template name="emit-gap"> | |
96 <xsl:param name="sector"/> | |
97 <xsl:call-template name="internal-emit-gap"> | |
98 <xsl:with-param name="sector" select="$sector"/> | |
99 <xsl:with-param name="preds" select="$sector/preceding-sibling::sector"/> | |
100 </xsl:call-template> | |
101 </xsl:template> | |
102 | |
103 <xsl:template name="internal-emit-gap"> | |
104 <xsl:param name="sector"/> | |
105 <xsl:param name="preds"/> | |
106 | |
107 <xsl:variable name="start"> | |
108 <xsl:choose> | |
109 <xsl:when test="number($sector/@from) < $global-min"> | |
110 <xsl:value-of select="$global-min"/> | |
111 </xsl:when> | |
112 <xsl:otherwise> | |
113 <xsl:value-of select="$sector/@from"/> | |
114 </xsl:otherwise> | |
115 </xsl:choose> | |
116 </xsl:variable> | |
117 | |
118 <xsl:if test="$start < $global-max"> | |
119 <xsl:variable name="num-preds" select="count($preds)"/> | |
120 <xsl:variable name="prev-end"> | |
121 <xsl:choose> | |
122 <xsl:when test="count($preds) < 1"> | |
123 <xsl:value-of select="$global-min"/> | |
124 </xsl:when> | |
125 <xsl:otherwise> | |
126 <xsl:value-of select="number($preds[last()]/@to)"/> | |
127 </xsl:otherwise> | |
128 </xsl:choose> | |
129 </xsl:variable> | |
130 | |
131 <xsl:if test="$prev-end < $global-max"> | |
132 <xsl:variable name="gap-len" select="$start - $prev-end"/> | |
133 <xsl:if test="$gap-len > 0.005"> | |
134 <div> | |
135 <xsl:attribute name="style"> | |
136 <xsl:text>width:</xsl:text> | |
137 <xsl:value-of select="100.0 * ($gap-len div ($global-max - $global-min))"/> | |
138 <xsl:text>%;float:left</xsl:text> | |
139 </xsl:attribute> | |
140 <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> | |
141 </div> | |
142 </xsl:if> | |
143 </xsl:if> | |
144 </xsl:if> | |
96 </xsl:template> | 145 </xsl:template> |
97 | 146 |
98 <xsl:template match="sector" mode="sectors"> | 147 <xsl:template match="sector" mode="sectors"> |
99 <xsl:call-template name="emit-gap"> | 148 <xsl:call-template name="emit-gap"> |
100 <xsl:with-param name="sector" select="."/> | 149 <xsl:with-param name="sector" select="."/> |
147 <xsl:value-of select="@date"/> | 196 <xsl:value-of select="@date"/> |
148 </td> | 197 </td> |
149 </tr> | 198 </tr> |
150 </xsl:template> | 199 </xsl:template> |
151 | 200 |
201 <xsl:template match="gauge" mode="gauges"> | |
202 <xsl:call-template name="emit-gap-gauge"> | |
203 <xsl:with-param name="gauge" select="."/> | |
204 </xsl:call-template> | |
205 <div> | |
206 <xsl:attribute name="style"> | |
207 <xsl:text>overflow:hidden;background:</xsl:text> | |
208 <xsl:choose> | |
209 <xsl:when test="(count(preceding::*) mod 2) = 0">#ada96e</xsl:when> | |
210 <xsl:otherwise>gray</xsl:otherwise> | |
211 </xsl:choose> | |
212 <xsl:text>;width:</xsl:text> | |
213 <xsl:call-template name="percent"> | |
214 <xsl:with-param name="sector" select="."/> | |
215 </xsl:call-template> | |
216 <xsl:text>%</xsl:text> | |
217 <xsl:text>;float:left</xsl:text> | |
218 </xsl:attribute> | |
219 <xsl:attribute name="title"> | |
220 <xsl:value-of select="@name"/> | |
221 <xsl:text>: km </xsl:text> | |
222 <xsl:value-of select="@from"/> | |
223 <xsl:text> - </xsl:text> | |
224 <xsl:value-of select="@to"/> | |
225 </xsl:attribute> | |
226 <nobr><xsl:value-of select="@name"/></nobr> | |
227 </div> | |
228 </xsl:template> | |
229 | |
152 <xsl:template match="events"> | 230 <xsl:template match="events"> |
153 <table width="97%" border="1" cellspacing="0" cellpadding="0" | 231 <table width="97%" border="1" cellspacing="0" cellpadding="0" |
154 style="font-size: 10pt;font-family:Arial;Verdana,sans-serif"> | 232 style="font-size: 10pt;font-family:Arial;Verdana,sans-serif"> |
155 <colgroup> | 233 <colgroup> |
156 <xsl:if test="$render-checkboxes"> | 234 <xsl:if test="$render-checkboxes"> |
161 </colgroup> | 239 </colgroup> |
162 <tr> | 240 <tr> |
163 <xsl:if test="$render-checkboxes"> | 241 <xsl:if test="$render-checkboxes"> |
164 <th> </th> | 242 <th> </th> |
165 </xsl:if> | 243 </xsl:if> |
166 <th>km <xsl:value-of select="$events-min"/> - <xsl:value-of select="$events-max"/></th> | 244 <th><xsl:apply-templates mode="gauges" select="/fixings/gauges"/></th> |
167 <th>Ereignis</th> | 245 <th>Ereignis</th> |
168 </tr> | 246 </tr> |
169 <xsl:apply-templates/> | 247 <xsl:apply-templates/> |
170 </table> | 248 </table> |
171 </xsl:template> | 249 </xsl:template> |
217 </html> | 295 </html> |
218 </xsl:template> | 296 </xsl:template> |
219 | 297 |
220 <xsl:template match="text()"/> | 298 <xsl:template match="text()"/> |
221 <xsl:template match="text()" mode="sectors"/> | 299 <xsl:template match="text()" mode="sectors"/> |
300 <xsl:template match="text()" mode="gauges"/> | |
222 | 301 |
223 </xsl:stylesheet> | 302 </xsl:stylesheet> |