]> Wikimedia Canada | Git repositories - eccc_to_commons.git/blob - monthly_to_commons.xslt
Rewrite almanach merge logic
[eccc_to_commons.git] / monthly_to_commons.xslt
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!-- monthly_to_commons.xslt - Convert Environment and Climate change Canada
4 historical XML data into a JSON format suitable
5 for Wikimedia Commons.
6 Copyright (C) 2019-2020 Pierre Choffet
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 -->
21
22 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
23 <xsl:output method="text" encoding="utf-8" />
24
25 <xsl:template match="/climatedata">
26 <xsl:variable name="station-name">
27 <xsl:call-template name="camel-case">
28 <xsl:with-param name="text" select="/climatedata/stationinformation/name/text()" />
29 </xsl:call-template>
30 </xsl:variable>
31 <xsl:variable name="province-name">
32 <xsl:call-template name="camel-case">
33 <xsl:with-param name="text" select="/climatedata/stationinformation/province/text()" />
34 </xsl:call-template>
35 </xsl:variable>
36
37 <xsl:text>{
38 "license": "CC-BY-4.0",
39 "description": {
40 "en": "</xsl:text><xsl:value-of select="$station-name" /><xsl:text> Monthly Weather Data",
41 "fr": "Données météorologiques mensuelles de </xsl:text><xsl:value-of select="$station-name" /><xsl:text>"
42 },
43 "sources": "[https://climate.weather.gc.ca/ Environment and Climate Change Canada]",
44 "schema": {
45 "fields": [
46 {
47 "name": "date",
48 "type": "string",
49 "title": {
50 "ar": "تاريخ",
51 "ca": "Data",
52 "da": "Dato",
53 "de": "Datum",
54 "en": "Date",
55 "es": "Fecha",
56 "fr": "Date",
57 "ru": "Дата",
58 "sr": "Датум"
59 }
60 },
61 {
62 "name": "avgHighTemp",
63 "type": "number",
64 "title": {
65 "ca": "Mitjana de temps. altes",
66 "da": "Gennemsnitlig højeste temperatur",
67 "de": "Durchschnittliche Höchsttemperatur",
68 "en": "Average high temp",
69 "es": "Promedio de temps. altas",
70 "fr": "Température maximale moyenne",
71 "ru": "Средняя высшая темп",
72 "sr": "Просечна виша температура"
73 }
74 },
75 {
76 "name": "avgLowTemp",
77 "type": "number",
78 "title": {
79 "ca": "Mitjana de temps. baixes",
80 "da": "Gennemsnitlige laveste temperatur",
81 "de": "Durchschnittliche Tiefsttemperatur",
82 "en": "Average low temp",
83 "es": "Promedio de temps. bajas",
84 "fr": "Température minimale moyenne",
85 "ru": "Средняя нижняя темп",
86 "sr": "Просечна нижа температура"
87 }
88 },
89 {
90 "name": "avgTemp",
91 "type": "number",
92 "title": {
93 "en": "Average temperature",
94 "fr": "Température moyenne"
95 }
96 },
97 {
98 "name": "extHighTemp",
99 "type": "number",
100 "title": {
101 "en": "Highest daily maximum temperature",
102 "fr": "Température maximale quotidienne la plus élevée"
103 }
104 },
105 {
106 "name": "extLowTemp",
107 "type": "number",
108 "title": {
109 "en": "Lowest daily minimal temperature",
110 "fr": "Température minimale la plus basse"
111 }
112 },
113 {
114 "name": "precipTotalRain",
115 "type": "number",
116 "title": {
117 "en": "Total rainfall (mm)",
118 "fr": "Pluie totale (mm)"
119 }
120 },
121 {
122 "name": "precipTotalSnow",
123 "type": "number",
124 "title": {
125 "en": "Total snowfall (cm)",
126 "fr": "Neige totale (cm)"
127 }
128 },
129 {
130 "name": "precipTotal",
131 "type": "number",
132 "title": {
133 "en": "Total précipitation (mm)",
134 "fr": "Précipitations totale (mm)"
135 }
136 },
137 {
138 "name": "snowGrndLastDay",
139 "type": "number",
140 "title": {
141 "en": "Snow on the ground on the last day (cm)",
142 "fr": "Neige au sol le dernier jour (cm)"
143 }
144 },
145 {
146 "name": "windDirMaxGust",
147 "type": "number",
148 "title": {
149 "en": "Direction of maximum gust (10's deg/tens of degrees)",
150 "fr": "Direction de la rafale maximale (10's deg/dizaines de degrés)"
151 }
152 },
153 {
154 "name": "windSpeedMaxGust",
155 "type": "number",
156 "title": {
157 "en": "Speed of maximum gust (km/h)",
158 "fr": "Vitesse de la rafale maximale (km/h)"
159 }
160 }
161 ]
162 },
163 "data": [</xsl:text>
164 <xsl:apply-templates select="stationdata" />
165 <xsl:text>]}</xsl:text>
166 </xsl:template>
167
168 <xsl:template match="stationdata">
169 <!-- TODO: Check element has at least one data? -->
170 <!-- Set date -->
171 <xsl:text>["</xsl:text>
172 <xsl:value-of select="@year" />
173 <xsl:text>-</xsl:text>
174 <xsl:value-of select="format-number(@month, '00')" />
175 <xsl:text>"</xsl:text>
176
177 <!-- Set meanmaxtemp -->
178 <xsl:text>, </xsl:text>
179 <xsl:apply-templates select="meanmaxtemp" />
180
181 <!-- Set meanmintemp -->
182 <xsl:text>, </xsl:text>
183 <xsl:apply-templates select="meanmintemp" />
184
185 <!-- Set meanmonthtemp -->
186 <xsl:text>, </xsl:text>
187 <xsl:apply-templates select="meanmonthtemp" />
188
189 <!-- Set extrmaxtemp -->
190 <xsl:text>, </xsl:text>
191 <xsl:apply-templates select="extrmaxtemp" />
192
193 <!-- Set extrmintemp -->
194 <xsl:text>, </xsl:text>
195 <xsl:apply-templates select="extrmintemp" />
196
197 <!-- Set totrain -->
198 <xsl:text>, </xsl:text>
199 <xsl:apply-templates select="totrain" />
200
201 <!-- Set totsnow -->
202 <xsl:text>, </xsl:text>
203 <xsl:apply-templates select="totsnow" />
204
205 <!-- Set totprecip -->
206 <xsl:text>, </xsl:text>
207 <xsl:apply-templates select="totprecip" />
208
209 <!-- Set grndsnowlastday -->
210 <xsl:text>, </xsl:text>
211 <xsl:apply-templates select="grndsnowlastday" />
212
213 <!-- Set dirmaxgust -->
214 <xsl:text>, </xsl:text>
215 <xsl:apply-templates select="dirmaxgust" />
216
217 <!-- Set speedmaxgust -->
218 <xsl:text>, </xsl:text>
219 <xsl:apply-templates select="speedmaxgust" />
220
221
222 <xsl:text>]</xsl:text>
223 <xsl:if test="position() != last()">
224 <xsl:text>, </xsl:text>
225 </xsl:if>
226 </xsl:template>
227
228 <!-- Process meanmaxtemp -->
229 <xsl:template match="meanmaxtemp">
230 <xsl:choose>
231 <xsl:when test="not(text())">
232 <xsl:text>null</xsl:text>
233 </xsl:when>
234 <xsl:when test="@flag = 'E'">
235 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated meanmaxtemp value</xsl:message>
236 <xsl:value-of select="text()" />
237 </xsl:when>
238 <xsl:when test="@flag = 'I'">
239 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert meanmaxtemp value with undocumented "I" flag</xsl:message>
240 <xsl:value-of select="text()" />
241 </xsl:when>
242 <xsl:when test="@flag = 'M'">
243 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available meanmaxtemp marked as missing</xsl:message>
244 <xsl:value-of select="text()" />
245 </xsl:when>
246 <xsl:otherwise>
247 <xsl:value-of select="text()" />
248 </xsl:otherwise>
249 </xsl:choose>
250 </xsl:template>
251
252 <!-- Process meanmintemp -->
253 <xsl:template match="meanmintemp">
254 <xsl:choose>
255 <xsl:when test="not(text())">
256 <xsl:text>null</xsl:text>
257 </xsl:when>
258 <xsl:when test="@flag = 'E'">
259 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated meanmintemp value</xsl:message>
260 <xsl:value-of select="text()" />
261 </xsl:when>
262 <xsl:when test="@flag = 'I'">
263 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert meanmintemp value with undocumented "I" flag</xsl:message>
264 <xsl:value-of select="text()" />
265 </xsl:when>
266 <xsl:when test="@flag = 'M'">
267 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available meanmintemp marked as missing</xsl:message>
268 <xsl:value-of select="text()" />
269 </xsl:when>
270 <xsl:otherwise>
271 <xsl:value-of select="text()" />
272 </xsl:otherwise>
273 </xsl:choose>
274 </xsl:template>
275
276 <!-- Process meanmonthtemp -->
277 <xsl:template match="meanmonthtemp">
278 <xsl:choose>
279 <xsl:when test="not(text())">
280 <xsl:text>null</xsl:text>
281 </xsl:when>
282 <xsl:when test="@flag = 'E'">
283 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated meanmonthtemp value</xsl:message>
284 <xsl:value-of select="text()" />
285 </xsl:when>
286 <xsl:when test="@flag = 'I'">
287 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert meanmonthtemp value with undocumented "I" flag</xsl:message>
288 <xsl:value-of select="text()" />
289 </xsl:when>
290 <xsl:when test="@flag = 'M'">
291 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available meanmonthtemp marked as missing</xsl:message>
292 <xsl:value-of select="text()" />
293 </xsl:when>
294 <xsl:otherwise>
295 <xsl:value-of select="text()" />
296 </xsl:otherwise>
297 </xsl:choose>
298 </xsl:template>
299
300 <!-- Process extrmaxtemp -->
301 <xsl:template match="extrmaxtemp">
302 <xsl:choose>
303 <xsl:when test="not(text())">
304 <xsl:text>null</xsl:text>
305 </xsl:when>
306 <xsl:when test="@flag = 'B'">
307 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert multiple and estimated extrmaxtemp value</xsl:message>
308 <xsl:value-of select="text()" />
309 </xsl:when>
310 <xsl:when test="@flag = 'E'">
311 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated extrmaxtemp value</xsl:message>
312 <xsl:value-of select="text()" />
313 </xsl:when>
314 <xsl:when test="@flag = 'I'">
315 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert extrmaxtemp value with undocumented "I" flag</xsl:message>
316 <xsl:value-of select="text()" />
317 </xsl:when>
318 <xsl:when test="@flag = 'M'">
319 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available extrmaxtemp marked as missing</xsl:message>
320 <xsl:value-of select="text()" />
321 </xsl:when>
322 <xsl:when test="@flag = 'S'">
323 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert multiple extrmaxtemp value</xsl:message>
324 <xsl:value-of select="text()" />
325 </xsl:when>
326 <xsl:otherwise>
327 <xsl:value-of select="text()" />
328 </xsl:otherwise>
329 </xsl:choose>
330 </xsl:template>
331
332 <!-- Process extrmintemp -->
333 <xsl:template match="extrmintemp">
334 <xsl:choose>
335 <xsl:when test="not(text())">
336 <xsl:text>null</xsl:text>
337 </xsl:when>
338 <xsl:when test="@flag = 'B'">
339 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert multiple and estimated extrmintemp value</xsl:message>
340 <xsl:value-of select="text()" />
341 </xsl:when>
342 <xsl:when test="@flag = 'E'">
343 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated extrmintemp value</xsl:message>
344 <xsl:value-of select="text()" />
345 </xsl:when>
346 <xsl:when test="@flag = 'I'">
347 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert extrmintemp value with undocumented "I" flag</xsl:message>
348 <xsl:value-of select="text()" />
349 </xsl:when>
350 <xsl:when test="@flag = 'M'">
351 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available extrmintemp marked as missing</xsl:message>
352 <xsl:value-of select="text()" />
353 </xsl:when>
354 <xsl:when test="@flag = 'S'">
355 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert multiple extrmintemp value</xsl:message>
356 <xsl:value-of select="text()" />
357 </xsl:when>
358 <xsl:otherwise>
359 <xsl:value-of select="text()" />
360 </xsl:otherwise>
361 </xsl:choose>
362 </xsl:template>
363
364 <!-- Process totrain -->
365 <xsl:template match="totrain">
366 <xsl:choose>
367 <xsl:when test="not(text())">
368 <xsl:text>null</xsl:text>
369 </xsl:when>
370 <xsl:when test="contains(text(), '#')">
371 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Discard totrain containing "#"</xsl:message>
372 <xsl:text>null</xsl:text>
373 </xsl:when>
374 <xsl:when test="@flag = 'E'">
375 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated totrain value</xsl:message>
376 <xsl:value-of select="text()" />
377 </xsl:when>
378 <xsl:when test="@flag = 'I'">
379 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert totrain value with undocumented "I" flag</xsl:message>
380 <xsl:value-of select="text()" />
381 </xsl:when>
382 <xsl:when test="@flag = 'M'">
383 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available totrain marked as missing</xsl:message>
384 <xsl:value-of select="text()" />
385 </xsl:when>
386 <xsl:when test="@flag = 'T'">
387 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert traces only totrain value</xsl:message>
388 <xsl:value-of select="text()" />
389 </xsl:when>
390 <xsl:otherwise>
391 <xsl:value-of select="text()" />
392 </xsl:otherwise>
393 </xsl:choose>
394 </xsl:template>
395
396 <!-- Process totsnow -->
397 <xsl:template match="totsnow">
398 <xsl:choose>
399 <xsl:when test="not(text())">
400 <xsl:text>null</xsl:text>
401 </xsl:when>
402 <xsl:when test="text() &lt; 0">
403 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Discard negative totsnow value</xsl:message>
404 <xsl:text>null</xsl:text>
405 </xsl:when>
406 <xsl:when test="@flag = 'E'">
407 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated totsnow value</xsl:message>
408 <xsl:value-of select="text()" />
409 </xsl:when>
410 <xsl:when test="@flag = 'I'">
411 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert totsnow value with undocumented "I" flag</xsl:message>
412 <xsl:value-of select="text()" />
413 </xsl:when>
414 <xsl:when test="@flag = 'M'">
415 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available totsnow marked as missing</xsl:message>
416 <xsl:value-of select="text()" />
417 </xsl:when>
418 <xsl:when test="@flag = 'T'">
419 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert traces only totsnow value</xsl:message>
420 <xsl:value-of select="text()" />
421 </xsl:when>
422 <xsl:otherwise>
423 <xsl:value-of select="text()" />
424 </xsl:otherwise>
425 </xsl:choose>
426 </xsl:template>
427
428 <!-- Process totprecip -->
429 <xsl:template match="totprecip">
430 <xsl:choose>
431 <xsl:when test="not(text())">
432 <xsl:text>null</xsl:text>
433 </xsl:when>
434 <xsl:when test="contains(text(), '#')">
435 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Discard totprecip containing "#"</xsl:message>
436 <xsl:text>null</xsl:text>
437 </xsl:when>
438 <xsl:when test="@flag = 'E'">
439 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated totprecip value</xsl:message>
440 <xsl:value-of select="text()" />
441 </xsl:when>
442 <xsl:when test="@flag = 'I'">
443 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert totprecip value with undocumented "I" flag</xsl:message>
444 <xsl:value-of select="text()" />
445 </xsl:when>
446 <xsl:when test="@flag = 'M'">
447 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available totprecip marked as missing</xsl:message>
448 <xsl:value-of select="text()" />
449 </xsl:when>
450 <xsl:when test="@flag = 'T'">
451 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert traces only totprecip value</xsl:message>
452 <xsl:value-of select="text()" />
453 </xsl:when>
454 <xsl:otherwise>
455 <xsl:value-of select="text()" />
456 </xsl:otherwise>
457 </xsl:choose>
458 </xsl:template>
459
460 <!-- Process grndsnowlastday -->
461 <xsl:template match="grndsnowlastday">
462 <xsl:choose>
463 <xsl:when test="not(text())">
464 <xsl:text>null</xsl:text>
465 </xsl:when>
466 <xsl:when test="@flag = 'E'">
467 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated grndsnowlastday value</xsl:message>
468 <xsl:value-of select="text()" />
469 </xsl:when>
470 <xsl:when test="@flag = 'M'">
471 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available grndsnowlastday marked as missing</xsl:message>
472 <xsl:value-of select="text()" />
473 </xsl:when>
474 <xsl:when test="@flag = 'T'">
475 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert traces only grndsnowlastday value</xsl:message>
476 <xsl:value-of select="text()" />
477 </xsl:when>
478 <xsl:otherwise>
479 <xsl:value-of select="text()" />
480 </xsl:otherwise>
481 </xsl:choose>
482 </xsl:template>
483
484 <!-- Process dirmaxgust -->
485 <xsl:template match="dirmaxgust">
486 <xsl:choose>
487 <xsl:when test="not(text())">
488 <xsl:text>null</xsl:text>
489 </xsl:when>
490 <xsl:when test="@flag = 'B'">
491 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert multiple and estimated dirmaxgust value</xsl:message>
492 <xsl:value-of select="text()" />
493 </xsl:when>
494 <xsl:when test="@flag = 'E'">
495 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated dirmaxgust value</xsl:message>
496 <xsl:value-of select="text()" />
497 </xsl:when>
498 <xsl:when test="@flag = 'I'">
499 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert dirmaxgust value with undocumented "I" flag</xsl:message>
500 <xsl:value-of select="text()" />
501 </xsl:when>
502 <xsl:when test="@flag = 'M'">
503 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available dirmaxgust marked as missing</xsl:message>
504 <xsl:value-of select="text()" />
505 </xsl:when>
506 <xsl:when test="@flag = 'S'">
507 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert multiple dirmaxgust value</xsl:message>
508 <xsl:value-of select="text()" />
509 </xsl:when>
510 <xsl:when test="text() = '36'">
511 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert dirmaxgust with a value of "36"</xsl:message>
512 <xsl:value-of select="text()" />
513 </xsl:when>
514 <xsl:otherwise>
515 <xsl:value-of select="text()" />
516 </xsl:otherwise>
517 </xsl:choose>
518 </xsl:template>
519
520 <!-- Process speedmaxgust -->
521 <xsl:template match="speedmaxgust">
522 <xsl:choose>
523 <xsl:when test="not(text())">
524 <xsl:text>null</xsl:text>
525 </xsl:when>
526 <xsl:when test="text() = '&lt;31'">
527 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Discard speedmaxgust with value "&lt;31"</xsl:message>
528 <xsl:text>null</xsl:text>
529 </xsl:when>
530 <xsl:when test="@flag = 'B'">
531 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert multiple and estimated speedmaxgust value</xsl:message>
532 <xsl:value-of select="text()" />
533 </xsl:when>
534 <xsl:when test="@flag = 'E'">
535 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert estimated speedmaxgust value</xsl:message>
536 <xsl:value-of select="text()" />
537 </xsl:when>
538 <xsl:when test="@flag = 'I'">
539 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert speedmaxgust value with undocumented "I" flag</xsl:message>
540 <xsl:value-of select="text()" />
541 </xsl:when>
542 <xsl:when test="@flag = 'M'">
543 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert available speedmaxgust marked as missing</xsl:message>
544 <xsl:value-of select="text()" />
545 </xsl:when>
546 <xsl:when test="@flag = 'S'">
547 <xsl:message>WARNING: <xsl:value-of select="../@year" />-<xsl:value-of select="format-number(../@month, '00')" />: Insert multiple speedmaxgust value</xsl:message>
548 <xsl:value-of select="text()" />
549 </xsl:when>
550 <xsl:otherwise>
551 <xsl:value-of select="text()" />
552 </xsl:otherwise>
553 </xsl:choose>
554 </xsl:template>
555
556 <!-- Camel case -->
557 <xsl:template name="camel-case">
558 <xsl:param name="text" select="."/>
559 <xsl:variable name="uppercase">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
560 <xsl:variable name="lowercase">abcdefghijklmnopqrstuvwxyz</xsl:variable>
561 <xsl:variable name="word" select="substring-before(concat($text, ' '), ' ')" />
562
563 <xsl:value-of select="translate(substring($word, 1, 1), $lowercase, $uppercase)" />
564 <xsl:value-of select="translate(substring($word, 2), $uppercase, $lowercase)" />
565
566 <xsl:if test="contains($text, ' ')">
567 <xsl:text> </xsl:text>
568 <xsl:call-template name="camel-case">
569 <xsl:with-param name="text" select="substring-after($text, ' ')"/>
570 </xsl:call-template>
571 </xsl:if>
572 </xsl:template>
573 </xsl:stylesheet>