Mercurial > dive4elements > river
comparison flys-client/src/main/webapp/WEB-INF/stylesheets/fixoverview2html.xsl @ 2493:f905c936ffff
Added the XSL transformation to generate the fixings overview.
flys-client/trunk@4286 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 20 Apr 2012 15:23:27 +0000 |
parents | |
children | 87ac5c532523 |
comparison
equal
deleted
inserted
replaced
2492:e64e0d094843 | 2493:f905c936ffff |
---|---|
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 | |
11 <xsl:template name="percent"> | |
12 <xsl:param name="sector"/> | |
13 <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> | |
14 <xsl:variable name="rto" select="number(/fixings/river/@to)"/> | |
15 <xsl:variable name="rlength" select="$rto - $rfrom"/> | |
16 | |
17 <xsl:variable name="sfrom" select="number($sector/@from)"/> | |
18 <xsl:variable name="sto" select="number($sector/@to)"/> | |
19 <xsl:variable name="slength" select="$sto - $sfrom"/> | |
20 <xsl:value-of select="100.0 * ($slength div $rlength)"/> | |
21 </xsl:template> | |
22 | |
23 <xsl:template name="emit-gap"> | |
24 <xsl:param name="sector"/> | |
25 <xsl:variable name="preds" select="$sector/preceding-sibling::sector"/> | |
26 <xsl:variable name="num-preds" select="count($preds)"/> | |
27 <xsl:variable name="glength"> | |
28 <xsl:choose> | |
29 <xsl:when test="$num-preds < 1"> | |
30 <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> | |
31 <xsl:value-of select="number($sector/@from) - $rfrom"/> | |
32 </xsl:when> | |
33 <xsl:otherwise> | |
34 <xsl:variable name="bend" select="number($preds[last()]/@to)"/> | |
35 <xsl:value-of select="number($sector/@from) - $bend"/> | |
36 </xsl:otherwise> | |
37 </xsl:choose> | |
38 </xsl:variable> | |
39 <xsl:choose> | |
40 <xsl:when test="number($glength) < 0.05 "/> | |
41 <xsl:otherwise> | |
42 <div> | |
43 <xsl:attribute name="style"> | |
44 <xsl:text>width:</xsl:text> | |
45 <xsl:variable name="rfrom" select="number(/fixings/river/@from)"/> | |
46 <xsl:variable name="rto" select="number(/fixings/river/@to)"/> | |
47 <xsl:variable name="rlength" select="$rto - $rfrom"/> | |
48 <xsl:value-of select="100.0 * ($glength div $rlength)"/> | |
49 <xsl:text>%;float:left</xsl:text> | |
50 </xsl:attribute> | |
51 <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> | |
52 </div> | |
53 </xsl:otherwise> | |
54 </xsl:choose> | |
55 </xsl:template> | |
56 | |
57 <xsl:template match="sector" mode="sectors"> | |
58 <xsl:call-template name="emit-gap"> | |
59 <xsl:with-param name="sector" select="."/> | |
60 </xsl:call-template> | |
61 <div> | |
62 <xsl:attribute name="style"> | |
63 <xsl:text>background:</xsl:text> | |
64 <xsl:choose> | |
65 <xsl:when test="@class = '0'">green</xsl:when> | |
66 <xsl:when test="@class = '1'">blue</xsl:when> | |
67 <xsl:when test="@class = '2'">magenta</xsl:when> | |
68 <xsl:when test="@class = '3'">red</xsl:when> | |
69 <xsl:otherwise>black</xsl:otherwise> | |
70 </xsl:choose> | |
71 <xsl:text>;width:</xsl:text> | |
72 <xsl:call-template name="percent"> | |
73 <xsl:with-param name="sector" select="."/> | |
74 </xsl:call-template> | |
75 <xsl:text>%</xsl:text> | |
76 <xsl:text>;float:left</xsl:text> | |
77 </xsl:attribute> | |
78 <xsl:attribute name="title"> | |
79 <xsl:text>km </xsl:text> | |
80 <xsl:value-of select="@from"/> | |
81 <xsl:text> - </xsl:text> | |
82 <xsl:value-of select="@to"/> | |
83 </xsl:attribute> | |
84 <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> | |
85 </div> | |
86 </xsl:template> | |
87 | |
88 <xsl:template match="event"> | |
89 <tr> | |
90 <xsl:if test="$render-checkboxes"> | |
91 <td> | |
92 <input type="checkbox" name="{$project-uuid}:{@cid}"/> | |
93 </td> | |
94 </xsl:if> | |
95 <td> | |
96 <xsl:apply-templates mode="sectors"/> | |
97 </td> | |
98 <td align="center"> | |
99 <xsl:attribute name="title"><xsl:value-of select="@name"/></xsl:attribute> | |
100 <xsl:value-of select="@date"/> | |
101 </td> | |
102 </tr> | |
103 </xsl:template> | |
104 | |
105 <xsl:template match="events"> | |
106 <table width="95%" border="1" cellspacing="0" cellpadding="0" | |
107 style="font-size: 11pt;font-family:Arial;Verdana,sans-serif"> | |
108 <colgroup> | |
109 <xsl:if test="$render-checkboxes"> | |
110 <col width="1em"/> | |
111 </xsl:if> | |
112 <col width="*"/> | |
113 <col width="11em"/> | |
114 </colgroup> | |
115 <xsl:apply-templates/> | |
116 </table> | |
117 </xsl:template> | |
118 | |
119 <xsl:template match="/"> | |
120 <xsl:apply-templates/> | |
121 </xsl:template> | |
122 | |
123 <xsl:template match="text()"/> | |
124 <xsl:template match="text()" mode="sectors"/> | |
125 | |
126 </xsl:stylesheet> |