1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
---|
3 | |
---|
4 | <!-- |
---|
5 | |
---|
6 | **************************************************************************************** |
---|
7 | Task result template 2.0 by SCDBob |
---|
8 | |
---|
9 | Changelog: |
---|
10 | -center align for competition name and title |
---|
11 | -red font for task status (i.e. Provisional) |
---|
12 | -result table width 100% |
---|
13 | |
---|
14 | ***************************************************************************************** |
---|
15 | |
---|
16 | --> |
---|
17 | |
---|
18 | <!-- To see the input used for this xslt, check the "Create source.xml file |
---|
19 | when creating report" menu item under the "Reports" menu in FsComp. |
---|
20 | When checked a .source.xml file is created each time you create a report. |
---|
21 | It shows the actual xml input to the xslt processor. |
---|
22 | This is helpfull if you like to modify this file. |
---|
23 | --> |
---|
24 | |
---|
25 | <xsl:output method="html" encoding="utf-8" indent="yes" /> |
---|
26 | |
---|
27 | <!-- Set the decimal separator to be used (. or ,) when decimal data is displayed. |
---|
28 | All decimal data in the source is with . and will be displayed with . unless |
---|
29 | formated otherwise using format-number() function. |
---|
30 | --> |
---|
31 | <xsl:variable name="decimal_separator" select="','"/> |
---|
32 | <xsl:decimal-format decimal-separator=',' grouping-separator=' ' /> |
---|
33 | <!-- note! make sure both above use same, ie either . or ,!! --> |
---|
34 | |
---|
35 | <!-- All <xsl:param ... elements will show as a field in a report dialog in |
---|
36 | FS when creating reports. This means you can define param elements here |
---|
37 | with a default value and set the value from FS when creating report. |
---|
38 | Some is used simply to display text at the top of the report (ie status), |
---|
39 | others is used to filter the results (ie women_only, nation, ...). |
---|
40 | If you add filter params you must of course also change the "filter" |
---|
41 | definition below so that the filter params is applied. |
---|
42 | 20080518 FS 1.2.3: |
---|
43 | Removed all "filter" params. |
---|
44 | Moved filtering inside FS so the xml input to the xslt is already filtered. |
---|
45 | the filter_info attribute of FsTaskResults element shows what filter(s) is applied. |
---|
46 | --> |
---|
47 | <xsl:param name="title"></xsl:param> |
---|
48 | <xsl:param name="status">Provisional</xsl:param> |
---|
49 | <!-- filter params --> |
---|
50 | <!-- No of best tasks to use the sum of for each pilot. |
---|
51 | Default is 'all' which is normally used. --> |
---|
52 | <xsl:param name="top_x_tasks">all</xsl:param> |
---|
53 | |
---|
54 | <!-- The node-set that this variable returns is what is used |
---|
55 | to create the result list. |
---|
56 | Here some of the params above is used. |
---|
57 | --> |
---|
58 | <xsl:variable name="filter" select="/Fs/FsCompetition[1]/FsCompetitionResults[@top=$top_x_tasks]/FsParticipant"/> |
---|
59 | <xsl:variable name="filter_info" select="/Fs/FsCompetition[1]/FsCompetitionResults[@top=$top_x_tasks]/@filter_info"/> |
---|
60 | |
---|
61 | <!-- Returns a ranking number based on the @points attribute in the element given by the item param. |
---|
62 | Will give same ranking to elements with equal points. |
---|
63 | NOTE! does NOT work when called inside a sorted node-list!!! |
---|
64 | NOTE! Likly to give wrong rank for some pilots when applied to a filtered node-list. |
---|
65 | --> |
---|
66 | <xsl:template name="calc_rank_from_points" > |
---|
67 | <xsl:param name="item"/> |
---|
68 | <xsl:param name="points"/> |
---|
69 | <xsl:param name="sub" select="0"/> |
---|
70 | <xsl:variable name="found" select="boolean($item/preceding-sibling::node()[1]/@points = $points)"/> |
---|
71 | <xsl:choose> |
---|
72 | <xsl:when test="$found = true()"> |
---|
73 | <xsl:call-template name="calc_rank_from_points"> |
---|
74 | <xsl:with-param name="item" select="$item/preceding-sibling::node()[1]"/> |
---|
75 | <xsl:with-param name="points" select="$points"/> |
---|
76 | <xsl:with-param name="sub" select="$sub+1"/> |
---|
77 | </xsl:call-template> |
---|
78 | </xsl:when> |
---|
79 | <xsl:otherwise> |
---|
80 | <xsl:value-of select="position()-$sub"/> |
---|
81 | </xsl:otherwise> |
---|
82 | </xsl:choose> |
---|
83 | </xsl:template> |
---|
84 | |
---|
85 | <!-- list of tasks --> |
---|
86 | <xsl:template name="FsTask_list"> |
---|
87 | <table class="fs_res"> |
---|
88 | <thead> |
---|
89 | <tr class="fs_res_res_row" onmouseover="this.className = 'hover'" onmouseout="this.className='fs_res_res_row'" > |
---|
90 | <th class="fs_res">Task</th> |
---|
91 | <th class="fs_res">Date</th> |
---|
92 | <th class="fs_res">Distance</th> |
---|
93 | <th class="fs_res"></th> |
---|
94 | </tr> |
---|
95 | </thead> |
---|
96 | <tbody> |
---|
97 | <xsl:for-each select="/Fs/FsCompetition/FsCompetitionResults[@top=$top_x_tasks]/FsParticipant[1]/FsTask"> |
---|
98 | <xsl:variable name="task_id" select="@id"/> |
---|
99 | <xsl:variable name="es" select="/Fs/FsCompetition/FsTasks/FsTask[@id=$task_id]/FsTaskDefinition/@es"/> |
---|
100 | <xsl:variable name="no_of_startgates" select="count(/Fs/FsCompetition/FsTasks/FsTask[@id=$task_id]/FsTaskDefinition/FsStartGate)"/> |
---|
101 | <xsl:variable name="task_distance" select="/Fs/FsCompetition/FsTasks/FsTask[@id=$task_id]/FsTaskScoreParams/@task_distance"/> |
---|
102 | <tr class="fs_res_res_row" onmouseover="this.className = 'hover'" onmouseout="this.className='fs_res_res_row'" > |
---|
103 | <td class="fs_res"> |
---|
104 | T<xsl:value-of select="position()"/> |
---|
105 | <xsl:text> </xsl:text> |
---|
106 | <xsl:value-of select="/Fs/FsCompetition/FsTasks/FsTask[@id=$task_id]/@name"/> |
---|
107 | </td> |
---|
108 | <td class="fs_res"> |
---|
109 | <xsl:value-of select="translate(substring(/Fs/FsCompetition/FsTasks/FsTask[@id=$task_id]/FsTaskDefinition/FsTurnpoint[1]/@open, 1, 16), 'T', ' ')"/>  <xsl:value-of select="@name"/> |
---|
110 | </td> |
---|
111 | <td class="fs_res"> |
---|
112 | <xsl:if test="$es"> |
---|
113 | <xsl:text> </xsl:text> |
---|
114 | <xsl:value-of select="format-number($task_distance, concat('#0', $decimal_separator, '0'))"/> |
---|
115 | <xsl:text> km</xsl:text> |
---|
116 | </xsl:if> |
---|
117 | </td> |
---|
118 | <td class="fs_res"> |
---|
119 | <xsl:choose> |
---|
120 | <xsl:when test="$es and $no_of_startgates > 0"> |
---|
121 | <xsl:text>Race to Goal with </xsl:text> |
---|
122 | <xsl:value-of select="$no_of_startgates"/> |
---|
123 | <xsl:text> startgate(s)</xsl:text> |
---|
124 | </xsl:when> |
---|
125 | <xsl:when test="$es and $no_of_startgates = 0"> |
---|
126 | <xsl:text>Elapsed time</xsl:text> |
---|
127 | </xsl:when> |
---|
128 | <xsl:otherwise> |
---|
129 | <xsl:text>Open Distance</xsl:text> |
---|
130 | </xsl:otherwise> |
---|
131 | </xsl:choose> |
---|
132 | </td> |
---|
133 | </tr> |
---|
134 | </xsl:for-each> |
---|
135 | </tbody> |
---|
136 | </table> |
---|
137 | </xsl:template> |
---|
138 | |
---|
139 | <!-- record template, used for each pilot in the ranked list of pilots --> |
---|
140 | <xsl:template name="record"> |
---|
141 | <xsl:variable name="pilot_id" select="@id"/> |
---|
142 | <tr class="fs_res_res_row" onmouseover="this.className = 'hover'" onmouseout="this.className='fs_res_res_row'" > |
---|
143 | <td class="fs_res" align="right"> |
---|
144 | <xsl:call-template name="calc_rank_from_points"> |
---|
145 | <xsl:with-param name="item" select="."/> |
---|
146 | <xsl:with-param name="points" select="@points"/> |
---|
147 | </xsl:call-template> |
---|
148 | </td> |
---|
149 | <td class="fs_res"> |
---|
150 | <xsl:value-of select="@id"/> |
---|
151 | </td> |
---|
152 | <td class="fs_res"> |
---|
153 | <xsl:value-of select="/Fs/FsCompetition/FsParticipants/FsParticipant[@id=$pilot_id]/@name"/> |
---|
154 | </td> |
---|
155 | <td class="fs_res"> |
---|
156 | <xsl:choose> |
---|
157 | <xsl:when test="/Fs/FsCompetition/FsParticipants/FsParticipant[@id=$pilot_id]/@female=1">F</xsl:when> |
---|
158 | <xsl:otherwise>M</xsl:otherwise> |
---|
159 | </xsl:choose> |
---|
160 | </td> |
---|
161 | <td class="fs_res"> |
---|
162 | <xsl:value-of select="/Fs/FsCompetition/FsParticipants/FsParticipant[@id=$pilot_id]/@nat_code_3166_a3"/> |
---|
163 | </td> |
---|
164 | <td class="fs_res"> |
---|
165 | <xsl:value-of select="/Fs/FsCompetition/FsParticipants/FsParticipant[@id=$pilot_id]/@glider"/> |
---|
166 | </td> |
---|
167 | <td class="fs_res"> |
---|
168 | <xsl:value-of select="/Fs/FsCompetition/FsParticipants/FsParticipant[@id=$pilot_id]/@sponsor"/> |
---|
169 | </td> |
---|
170 | <xsl:for-each select="FsTask"> |
---|
171 | <xsl:variable name="task_id" select="@id"/> |
---|
172 | <xsl:choose> |
---|
173 | <xsl:when test="@counts='1'"> |
---|
174 | <td class="fs_res" style="text-align: right"> |
---|
175 | <xsl:value-of select="/Fs/FsCompetition/FsTasks/FsTask[@id=$task_id]/FsParticipants/FsParticipant[@id=$pilot_id]/FsResult/@points"/> |
---|
176 | </td> |
---|
177 | </xsl:when> |
---|
178 | <xsl:otherwise> |
---|
179 | <td class="fs_res" style="text-align: right; text-decoration: line-through;"> |
---|
180 | <xsl:value-of select="/Fs/FsCompetition/FsTasks/FsTask[@id=$task_id]/FsParticipants/FsParticipant[@id=$pilot_id]/FsResult/@points"/> |
---|
181 | </td> |
---|
182 | </xsl:otherwise> |
---|
183 | </xsl:choose> |
---|
184 | </xsl:for-each> |
---|
185 | <td class="fs_res" style="font-weight: bold; text-align: right"> |
---|
186 | <xsl:value-of select="@points"/> |
---|
187 | </td> |
---|
188 | </tr> |
---|
189 | </xsl:template> |
---|
190 | |
---|
191 | <xsl:template match="/"> |
---|
192 | <html> |
---|
193 | <head> |
---|
194 | <style> |
---|
195 | .hover |
---|
196 | { /* for IE using onmouseover and onmouseout */ |
---|
197 | background: yellow; |
---|
198 | } |
---|
199 | tr.fs_res_res_row:hover |
---|
200 | { |
---|
201 | background: yellow; |
---|
202 | } |
---|
203 | div.fs_res |
---|
204 | { |
---|
205 | font-family: Verdana, Arial, Helvetica, sans-serif; |
---|
206 | font-size: xx-small; |
---|
207 | } |
---|
208 | table.fs_res |
---|
209 | { |
---|
210 | border:solid 1px gray; |
---|
211 | border-collapse:collapse; |
---|
212 | font-size: xx-small; |
---|
213 | } |
---|
214 | td.fs_res |
---|
215 | { |
---|
216 | border:solid 1px gray; |
---|
217 | vertical-align:top; |
---|
218 | padding:5px; |
---|
219 | } |
---|
220 | th.fs_res |
---|
221 | { |
---|
222 | border:solid 1px gray; |
---|
223 | vertical-align:center; |
---|
224 | } |
---|
225 | </style> |
---|
226 | </head> |
---|
227 | <body> |
---|
228 | <div> |
---|
229 | <div class="fs_res"> |
---|
230 | <div class="fs_res" style="width:100%;font-size: xx-small;text-align:right;" > |
---|
231 | <i> |
---|
232 | Report created: <xsl:value-of select="/Fs/FsCompetition/FsCompetitionResults[@top=$top_x_tasks]/@ts"/> |
---|
233 | </i> |
---|
234 | </div> |
---|
235 | <div style="width:100%;text-align:center;"> |
---|
236 | <h1> |
---|
237 | <xsl:value-of select="/Fs/FsCompetition/@name"/> |
---|
238 | </h1> |
---|
239 | <p style="font-size:xx-small"> |
---|
240 | <xsl:value-of select="/Fs/FsCompetition/@from"/> to <xsl:value-of select="/Fs/FsCompetition/@to"/> |
---|
241 | </p> |
---|
242 | <xsl:if test="string-length($title) > 0"> |
---|
243 | <h2> |
---|
244 | <xsl:value-of select="$title"/> |
---|
245 | </h2> |
---|
246 | </xsl:if> |
---|
247 | <p> |
---|
248 | <strong style="color:red;"><xsl:value-of select="$status"/></strong> |
---|
249 | </p> |
---|
250 | </div> |
---|
251 | <xsl:choose> |
---|
252 | <xsl:when test="$top_x_tasks='all'"> |
---|
253 | <h3> |
---|
254 | Total results |
---|
255 | </h3> |
---|
256 | </xsl:when> |
---|
257 | <xsl:otherwise> |
---|
258 | <h3> |
---|
259 | Results using top <xsl:value-of select="$top_x_tasks"/> tasks for each pilot |
---|
260 | </h3> |
---|
261 | </xsl:otherwise> |
---|
262 | </xsl:choose> |
---|
263 | <xsl:if test="string-length($filter_info) > 0"> |
---|
264 | <p> |
---|
265 | <b> |
---|
266 | Results includes only those pilots where <xsl:value-of select="$filter_info"/> |
---|
267 | </b> |
---|
268 | </p> |
---|
269 | </xsl:if> |
---|
270 | <xsl:if test="$top_x_tasks != 'all'"> |
---|
271 | <p> |
---|
272 | <b> |
---|
273 | <xsl:choose> |
---|
274 | <xsl:when test="$top_x_tasks = 1"> |
---|
275 | Only the score from the best task of each pilot is used for total score. |
---|
276 | </xsl:when> |
---|
277 | <xsl:otherwise> |
---|
278 | Only the scores from the best <xsl:value-of select="$top_x_tasks"/> tasks of each pilot is used for total score. |
---|
279 | </xsl:otherwise> |
---|
280 | </xsl:choose> |
---|
281 | </b> |
---|
282 | </p> |
---|
283 | </xsl:if> |
---|
284 | <xsl:call-template name="FsTask_list"></xsl:call-template> |
---|
285 | <br/> |
---|
286 | <table class="fs_res" style="width:100%"> |
---|
287 | <thead> |
---|
288 | <tr class="fs_res_res_row" onmouseover="this.className = 'hover'" onmouseout="this.className='fs_res_res_row'" > |
---|
289 | <th class="fs_res">#</th> |
---|
290 | <th class="fs_res">Id</th> |
---|
291 | <th class="fs_res">Name</th> |
---|
292 | <th class="fs_res"></th> |
---|
293 | <th class="fs_res">Nat</th> |
---|
294 | <th class="fs_res">Glider</th> |
---|
295 | <th class="fs_res">Sponsor</th> |
---|
296 | <xsl:for-each select="/Fs/FsCompetition/FsCompetitionResults[@top=$top_x_tasks]/FsParticipant[1]/FsTask"> |
---|
297 | <th class="fs_res"> |
---|
298 | <xsl:text>T </xsl:text> |
---|
299 | <xsl:value-of select="position()"/> |
---|
300 | </th> |
---|
301 | </xsl:for-each> |
---|
302 | <th class="fs_res">Total</th> |
---|
303 | </tr> |
---|
304 | </thead> |
---|
305 | <xsl:for-each select="$filter"> |
---|
306 | <!-- participant rows --> |
---|
307 | <xsl:call-template name="record"/> |
---|
308 | </xsl:for-each> |
---|
309 | </table> |
---|
310 | <p> |
---|
311 | <div style="text-align:center; font-size:xxxx-small;"> |
---|
312 | Competition scored with <a href="http://fs.fai.org/">FS</a><br/> |
---|
313 | Template powered by SCDBob |
---|
314 | </div> |
---|
315 | </p> |
---|
316 | </div> |
---|
317 | </div> |
---|
318 | </body> |
---|
319 | </html> |
---|
320 | </xsl:template> |
---|
321 | </xsl:stylesheet> |
---|