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