comparison flys-artifacts/contrib/fixoverview2html.xsl @ 3427:5f47e68a1130

FixA: Bring XSLT in sync with flys-client to ease development. flys-artifacts/trunk@5084 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 20 Jul 2012 09:43:55 +0000
parents d6e32ae72da6
children 3353672f9ba2
comparison
equal deleted inserted replaced
3426:e7a67407dea1 3427:5f47e68a1130
7 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" 7 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
8 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/> 8 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/>
9 9
10 <xsl:param name="project-uuid">de3f3307-3429-4ff9-8f43-3fb2fcf21b27</xsl:param> 10 <xsl:param name="project-uuid">de3f3307-3429-4ff9-8f43-3fb2fcf21b27</xsl:param>
11 <xsl:param name="render-checkboxes" select="true()"/> 11 <xsl:param name="render-checkboxes" select="true()"/>
12 <xsl:param name="callback"/>
13
14 <xsl:template match="@*" mode="min">
15 <xsl:if test="position() = 1">
16 <xsl:value-of select="number(.)"/>
17 </xsl:if>
18 </xsl:template>
19
20 <xsl:template match="@*" mode="max">
21 <xsl:if test="position() = last()">
22 <xsl:value-of select="number(.)"/>
23 </xsl:if>
24 </xsl:template>
25
26 <xsl:variable name="events-min">
27 <xsl:choose>
28 <xsl:when test="count(/fixings/events/event/sector) &gt; 0">
29 <xsl:apply-templates mode="min" select="/fixings/events/event/sector/@from">
30 <xsl:sort data-type="number" select="."/>
31 </xsl:apply-templates>
32 </xsl:when>
33 <xsl:otherwise>
34 <xsl:value-of select="number(/fixings/river/@from)"/>
35 </xsl:otherwise>
36 </xsl:choose>
37 </xsl:variable>
38
39 <xsl:variable name="events-max">
40 <xsl:choose>
41 <xsl:when test="count(/fixings/events/event/sector) &gt; 0">
42 <xsl:apply-templates mode="max" select="/fixings/events/event/sector/@to">
43 <xsl:sort data-type="number" select="."/>
44 </xsl:apply-templates>
45 </xsl:when>
46 <xsl:otherwise>
47 <xsl:value-of select="number(/fixings/river/@to)"/>
48 </xsl:otherwise>
49 </xsl:choose>
50 </xsl:variable>
12 51
13 <xsl:template name="percent"> 52 <xsl:template name="percent">
14 <xsl:param name="sector"/> 53 <xsl:param name="sector"/>
15 <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> 54 <xsl:variable name="rfrom" select="number($events-min)"/>
16 <xsl:variable name="rto" select="number(/fixings/river/@to)"/> 55 <xsl:variable name="rto" select="number($events-max)"/>
17 <xsl:variable name="rlength" select="$rto - $rfrom"/> 56 <xsl:variable name="rlength" select="$rto - $rfrom"/>
18 57
19 <xsl:variable name="sfrom" select="number($sector/@from)"/> 58 <xsl:variable name="sfrom" select="number($sector/@from)"/>
20 <xsl:variable name="sto" select="number($sector/@to)"/> 59 <xsl:variable name="sto" select="number($sector/@to)"/>
21 <xsl:variable name="slength" select="$sto - $sfrom"/> 60 <xsl:variable name="slength" select="$sto - $sfrom"/>
27 <xsl:variable name="preds" select="$sector/preceding-sibling::sector"/> 66 <xsl:variable name="preds" select="$sector/preceding-sibling::sector"/>
28 <xsl:variable name="num-preds" select="count($preds)"/> 67 <xsl:variable name="num-preds" select="count($preds)"/>
29 <xsl:variable name="glength"> 68 <xsl:variable name="glength">
30 <xsl:choose> 69 <xsl:choose>
31 <xsl:when test="$num-preds &lt; 1"> 70 <xsl:when test="$num-preds &lt; 1">
32 <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> 71 <xsl:variable name="rfrom" select="number($events-min)"/>
33 <xsl:value-of select="number($sector/@from) - $rfrom"/> 72 <xsl:value-of select="number($sector/@from) - $rfrom"/>
34 </xsl:when> 73 </xsl:when>
35 <xsl:otherwise> 74 <xsl:otherwise>
36 <xsl:variable name="bend" select="number($preds[last()]/@to)"/> 75 <xsl:variable name="bend" select="number($preds[last()]/@to)"/>
37 <xsl:value-of select="number($sector/@from) - $bend"/> 76 <xsl:value-of select="number($sector/@from) - $bend"/>
42 <xsl:when test="number($glength) &lt; 0.05 "/> 81 <xsl:when test="number($glength) &lt; 0.05 "/>
43 <xsl:otherwise> 82 <xsl:otherwise>
44 <div> 83 <div>
45 <xsl:attribute name="style"> 84 <xsl:attribute name="style">
46 <xsl:text>width:</xsl:text> 85 <xsl:text>width:</xsl:text>
47 <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> 86 <xsl:variable name="rfrom" select="number($events-min)"/>
48 <xsl:variable name="rto" select="number(/fixings/river/@to)"/> 87 <xsl:variable name="rto" select="number($events-max)"/>
49 <xsl:variable name="rlength" select="$rto - $rfrom"/> 88 <xsl:variable name="rlength" select="$rto - $rfrom"/>
50 <xsl:value-of select="100.0 * ($glength div $rlength)"/> 89 <xsl:value-of select="100.0 * ($glength div $rlength)"/>
51 <xsl:text>%;float:left</xsl:text> 90 <xsl:text>%;float:left</xsl:text>
52 </xsl:attribute> 91 </xsl:attribute>
53 <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text> 92 <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
80 <xsl:attribute name="title"> 119 <xsl:attribute name="title">
81 <xsl:text>km </xsl:text> 120 <xsl:text>km </xsl:text>
82 <xsl:value-of select="@from"/> 121 <xsl:value-of select="@from"/>
83 <xsl:text> - </xsl:text> 122 <xsl:text> - </xsl:text>
84 <xsl:value-of select="@to"/> 123 <xsl:value-of select="@to"/>
124 <xsl:choose>
125 <xsl:when test="@class = '0'"> / Q um MNQ</xsl:when>
126 <xsl:when test="@class = '1'"> / Q um MQ</xsl:when>
127 <xsl:when test="@class = '2'"> / Q um MHQ</xsl:when>
128 <xsl:when test="@class = '3'"> / Q über HQ5</xsl:when>
129 </xsl:choose>
85 </xsl:attribute> 130 </xsl:attribute>
86 <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text> 131 <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
87 </div> 132 </div>
88 </xsl:template> 133 </xsl:template>
89 134
90 <xsl:template match="event"> 135 <xsl:template match="event">
91 <tr> 136 <tr id="{@cid}">
92 <xsl:if test="$render-checkboxes"> 137 <xsl:if test="$render-checkboxes">
93 <td> 138 <td>
94 <input type="checkbox" name="{$project-uuid}:{@cid}"/> 139 <input type="checkbox" name="{$project-uuid}:{@cid}" checked="true" onclick="{$callback}"/>
95 </td> 140 </td>
96 </xsl:if> 141 </xsl:if>
97 <td> 142 <td>
98 <xsl:apply-templates mode="sectors"/> 143 <xsl:apply-templates mode="sectors"/>
99 </td> 144 </td>
103 </td> 148 </td>
104 </tr> 149 </tr>
105 </xsl:template> 150 </xsl:template>
106 151
107 <xsl:template match="events"> 152 <xsl:template match="events">
108 <table width="95%" border="1" cellspacing="0" cellpadding="0" style="font-size: 11pt;font-family:Arial;Verdana,sans-serif"> 153 <table width="97%" border="1" cellspacing="0" cellpadding="0"
154 style="font-size: 10pt;font-family:Arial;Verdana,sans-serif">
109 <colgroup> 155 <colgroup>
110 <xsl:if test="$render-checkboxes"> 156 <xsl:if test="$render-checkboxes">
111 <col width="1em"/> 157 <col width="20px"/>
112 </xsl:if> 158 </xsl:if>
113 <col width="*"/> 159 <col width="*"/>
114 <col width="11em"/> 160 <col width="75px"/>
115 </colgroup> 161 </colgroup>
162 <tr>
163 <xsl:if test="$render-checkboxes">
164 <th>&#160;</th>
165 </xsl:if>
166 <th>km <xsl:value-of select="$events-min"/> - <xsl:value-of select="$events-max"/></th>
167 <th>Ereignis</th>
168 </tr>
116 <xsl:apply-templates/> 169 <xsl:apply-templates/>
117 </table> 170 </table>
118 </xsl:template> 171 </xsl:template>
119 172
120 <xsl:template match="/"> 173 <xsl:template match="/">
122 <head> 175 <head>
123 <title>Fixierungen:</title> 176 <title>Fixierungen:</title>
124 </head> 177 </head>
125 <body> 178 <body>
126 <xsl:apply-templates/> 179 <xsl:apply-templates/>
180 <hr/>
181 <table border="1" cellspacing="0" cellpadding="0">
182 <caption>Legende</caption>
183 <tr>
184 <th>Farbe</th>
185 <th colspan="2">Bedeutung</th>
186 </tr>
187 <xsl:if test="count(/fixings/events/event/sector[@class = '0']) &gt; 0">
188 <tr>
189 <td style="background: green">&#160;</td>
190 <td>um MNQ</td>
191 <td>Q &#8712; [0, (MNQ+MQ)/2)</td>
192 </tr>
193 </xsl:if>
194 <xsl:if test="count(/fixings/events/event/sector[@class = '1']) &gt; 0">
195 <tr>
196 <td style="background: blue">&#160;</td>
197 <td>um MQ</td>
198 <td>Q &#8712; [(MNQ+MQ)/2, (MQ+MHQ)/2)</td>
199 </tr>
200 </xsl:if>
201 <xsl:if test="count(/fixings/events/event/sector[@class = '2']) &gt; 0">
202 <tr>
203 <td style="background: magenta">&#160;</td>
204 <td>um MHQ</td>
205 <td>Q &#8712; [(MQ+MHQ)/2, HQ5)</td>
206 </tr>
207 </xsl:if>
208 <xsl:if test="count(/fixings/events/event/sector[@class = '3']) &gt; 0">
209 <tr>
210 <td style="background: red">&#160;</td>
211 <td>über HQ5</td>
212 <td>Q &#8712; [HQ5, &#8734;)</td>
213 </tr>
214 </xsl:if>
215 </table>
127 </body> 216 </body>
128 </html> 217 </html>
129 </xsl:template> 218 </xsl:template>
130 219
131 <xsl:template match="text()"/> 220 <xsl:template match="text()"/>

http://dive4elements.wald.intevation.org