/
eea-migrate-201908.xsl
360 lines (321 loc) · 19.4 KB
/
eea-migrate-201908.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2001-2016 Food and Agriculture Organization of the
~ United Nations (FAO-UN), United Nations World Food Programme (WFP)
~ and United Nations Environment Programme (UNEP)
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or (at
~ your option) any later version.
~
~ This program is distributed in the hope that it will be useful, but
~ WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
~
~ Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
~ Rome - Italy. email: geonetwork@osgeo.org
-->
<!--
Stylesheet used to update metadata to improve validation.
https://taskman.eionet.europa.eu/issues/104851
Restore a backup
UPDATE metadata a SET data = (SELECT data FROM metadata20181010 b WHERE a.uuid= b.uuid);
-->
<xsl:stylesheet xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:srv="http://www.isotc211.org/2005/srv"
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:util="java:org.fao.geonet.util.XslUtil"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:geonet="http://www.fao.org/geonetwork"
exclude-result-prefixes="#all"
version="2.0">
<xsl:output indent="yes"/>
<xsl:variable name="uuid"
select="//gmd:fileIdentifier/gco:CharacterString"/>
<xsl:variable name="hasSpatialScope"
select="count(//gmd:MD_Metadata/gmd:identificationInfo/*/gmd:descriptiveKeywords[*/gmd:thesaurusName/*/gmd:title/*/text() = 'Spatial scope']) > 0"/>
<xsl:template match="gmd:thesaurusName/*[gmd:title/* = 'EEA keyword list']/gmd:date/*/gmd:dateType/*/@codeListValue">
<xsl:attribute name="codeListValue">publication</xsl:attribute>
</xsl:template>
<xsl:template match="gmd:thesaurusName/*[gmd:title/* = 'EEA categories']/gmd:date/*/gmd:dateType/*/@codeListValue">
<xsl:attribute name="codeListValue">publication</xsl:attribute>
</xsl:template>
<!-- Convert CRS to TG2 encoding
See D.4 Default Coordinate Reference Systems
List comes from TG2 + some value used in GeoNetwork
To be completed depending on the past usage for CRS encoding.
-->
<xsl:variable name="crsMap">
<crs code="http://www.opengis.net/def/crs/EPSG/0/4258" label="EPSG:4258">EPSG:4258</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4258" label="EPSG:4258">ETRS89-GRS80</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4258" label="EPSG:4258">ETRS 89 (EPSG:4258)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4936" label="EPSG:4936">ETRS89-XYZ</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4937" label="EPSG:4937">ETRS89-GRS80h</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4258" label="EPSG:4258">ETRS89 (EPSG:4258)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3034" label="EPSG:3034">ETRS89-LCC</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3035" label="EPSG:3035">ETRS89-LAEA</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3035" label="EPSG:3035">ETRS89-LAEA (EPSG:3035)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3035" label="EPSG:3035">ETRS 89 / LAEA Europe (EPSG:3035)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3035" label="EPSG:3035">ETRS89 / LAEA Europe (EPSG:3035)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3038" label="EPSG:3038">ETRS89-TM26N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3039" label="EPSG:3039">ETRS89-TM27N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3040" label="EPSG:3040">ETRS89-TM28N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3041" label="EPSG:3041">ETRS89-TM29N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3042" label="EPSG:3042">ETRS89-TM30N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3043" label="EPSG:3043">ETRS89-TM31N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3044" label="EPSG:3044">ETRS89-TM32N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3045" label="EPSG:3045">ETRS89-TM33N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3046" label="EPSG:3046">ETRS89-TM34N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3047" label="EPSG:3047">ETRS89-TM35N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3048" label="EPSG:3048">ETRS89-TM36N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3049" label="EPSG:3049">ETRS89-TM37N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3050" label="EPSG:3050">ETRS89-TM38N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3051" label="EPSG:3051">ETRS89-TM39N</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/7409" label="EPSG:7409">ETRS89-GRS80-EVRS</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/5730" label="EPSG:5730">EVRS</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/5861" label="EPSG:5861">LAT</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/5715" label="EPSG:5715">MSL</crs>
<!-- It is not clear what label should be in this case? -->
<crs code="http://codes.wmo.int/grib2/codeflag/4.2/_0-3-3" label="WMO:ISO">ISA</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">WGS 1984</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">WGS1984</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">WGS 84 (EPSG:4326)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">WGS84 (EPSG:4326)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">WGS 84 (EPSG:4326)::EPSG</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">WGS84 (EPSG:4326)::EPSG</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32628" label="EPSG:32628">WGS 84 / UTM zone 28N (EPSG:32628)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32628" label="EPSG:32628">WGS84 / UTM zone 28N (EPSG:32628)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32740" label="EPSG:32740">WGS 84 / UTM zone 40S (EPSG:32740)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32740" label="EPSG:32740">WGS84 / UTM zone 40S (EPSG:32740)</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4258" label="EPSG:4258">urn:ogc:def:crs:EPSG:7.1:EPSG:4258</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4258" label="EPSG:4258">urn:ogc:def:crs:EPSG:4258</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3035" label="EPSG:3035">urn:ogc:def:crs:EPSG:7.1:3035</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3035" label="EPSG:3035">urn:ogc:def:crs:EPSG:7.1:EPSG:3035</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/3035" label="EPSG:3035">urn:ogc:def:crs:EPSG::3035</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">urn:ogc:def:crs:EPSG:7.1:4326</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">urn:ogc:def:crs:EPSG:7.1:EPSG:4326</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/4326" label="EPSG:4326">urn:ogc:def:crs:EPSG::4326</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32628" label="EPSG:32628">urn:ogc:def:crs:EPSG:7.1:EPSG:32628</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32628" label="EPSG:32628">urn:ogc:def:crs:EPSG:7.1:32628</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32628" label="EPSG:32628">urn:ogc:def:crs:EPSG:32628</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32740" label="EPSG:32740">urn:ogc:def:crs:EPSG:7.1:EPSG:32740</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32740" label="EPSG:32740">urn:ogc:def:crs:EPSG:7.1:32740</crs>
<crs code="http://www.opengis.net/def/crs/EPSG/0/32740" label="EPSG:32740">urn:ogc:def:crs:EPSG:32740</crs>
</xsl:variable>
<xsl:variable name="isEuOrEEA"
select="count(//gmd:descriptiveKeywords/*[gmd:thesaurusName/*/gmd:title/*/text() = 'Continents, countries, sea regions of the world.']/gmd:keyword[starts-with(*/text(), 'EU')
or starts-with(*/text(), 'EEA')
or starts-with(*/text(), 'EFTA')]) > 0"/>
<xsl:variable name="isUrbanAtlas"
select="count(//gmd:identificationInfo/*/gmd:citation/*/gmd:title[starts-with(*/text(), 'Urban Atlas - ')]) > 0"/>
<xsl:variable name="isEUGrid"
select="count(//gmd:identificationInfo/*/gmd:citation/*/gmd:title[starts-with(*/text(), 'EEA reference grid for Europe')]) > 0"/>
<xsl:variable name="isNationalGrid"
select="count(//gmd:identificationInfo/*/gmd:citation/*/gmd:title[starts-with(*/text(), 'EEA reference grid for')]) > 0"/>
<xsl:variable name="isGlobal"
select="count(//gmd:identificationInfo/*/gmd:citation/*/gmd:title[
contains(*/text(), '(GAUL)')
or contains(*/text(), 'Natural Earth')
or contains(*/text(), 'EGM EuroGlobalMap')
or contains(*/text(), 'Global Soil Organic Carbon')
or contains(*/text(), 'Offshore wind farms')
or contains(*/text(), 'LandScan Global Population Database')
or contains(*/text(), 'Natural Earth cultural and physical data')
or contains(*/text(), 'GISCO - Administrative units')
or contains(*/text(), 'GISCO - Coastlines and sea regions 2010')
or contains(*/text(), 'GISCO - Exclusive Economic Zones (EEZ)')]) > 0"/>
<xsl:template match="gmd:descriptiveKeywords[
not($hasSpatialScope)
and following-sibling::*[1]/name(.) != 'gmd:descriptiveKeywords']">
<xsl:copy>
<xsl:apply-templates select="*"/>
</xsl:copy>
<gmd:descriptiveKeywords>
<gmd:MD_Keywords>
<gmd:keyword>
<xsl:choose>
<xsl:when test="$isGlobal">
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/SpatialScope/global">Global</gmx:Anchor>
</xsl:when>
<xsl:when test="$isEuOrEEA or $isEUGrid">
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/SpatialScope/european">European</gmx:Anchor>
</xsl:when>
<xsl:when test="$isNationalGrid">
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/SpatialScope/national">National</gmx:Anchor>
</xsl:when>
<xsl:when test="$isUrbanAtlas">
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/SpatialScope/local">Local</gmx:Anchor>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="gco:nilReason" select="'missing'"/>
<gmx:Anchor/>
</xsl:otherwise>
</xsl:choose>
<!--<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/SpatialScope/regional">Regional</gmx:Anchor>-->
</gmd:keyword>
<gmd:type>
<gmd:MD_KeywordTypeCode codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_KeywordTypeCode"
codeListValue="theme"/>
</gmd:type>
<gmd:thesaurusName>
<gmd:CI_Citation>
<gmd:title>
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/SpatialScope#">Spatial scope</gmx:Anchor>
</gmd:title>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>2019-11-20</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_DateTypeCode"
codeListValue="publication"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
<gmd:identifier>
<gmd:MD_Identifier>
<gmd:code>
<gmx:Anchor xlink:href="https://sdi.eea.europa.eu/catalogue/srv/eng/thesaurus.download?ref=external.theme.httpinspireeceuropaeumetadatacodelistSpatialScope-SpatialScope">geonetwork.thesaurus.external.theme.httpinspireeceuropaeumetadatacodelistSpatialScope-SpatialScope</gmx:Anchor>
</gmd:code>
</gmd:MD_Identifier>
</gmd:identifier>
</gmd:CI_Citation>
</gmd:thesaurusName>
</gmd:MD_Keywords>
</gmd:descriptiveKeywords>
</xsl:template>
<!-- Coordinate reference system
Validator error report:
* The metadata record references none of the expected coordinate reference systems.
The following reference system code have been referenced:
'urn:ogc:def:crs:EPSG::4326'. Please refer to table 2 of the data specification
for the list of expected coordinate reference system codes.
Replace CharacterString with Anchor.
Replace old label by EPSG:code only
-->
<xsl:template match="gmd:referenceSystemIdentifier/gmd:RS_Identifier[gmd:code/gco:CharacterString = $crsMap/crs/text()]">
<xsl:variable name="code" select="gmd:code/gco:CharacterString"/>
<xsl:variable name="newCrs" select="$crsMap/crs[text() = $code]"/>
<gmd:RS_Identifier>
<xsl:choose>
<xsl:when test="$newCrs != ''">
<gmd:code>
<gmx:Anchor xlink:href="{$newCrs/@code}"><xsl:value-of select="$newCrs/@label"/></gmx:Anchor>
</gmd:code>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="gmd:code|gmd:codeSpace"/>
</xsl:otherwise>
</xsl:choose>
</gmd:RS_Identifier>
</xsl:template>
<!-- update use limitation
<xsl:template match="gmd:resourceConstraints">
<xsl:if test="preceding-sibling::*[1]/name() != 'gmd:resourceConstraints'">
<gmd:resourceConstraints>
<gmd:MD_Constraints>
<gmd:useLimitation>
<gco:CharacterString>EEA standard re-use policy: unless otherwise indicated, re-use of content on the EEA website for commercial or non-commercial purposes is permitted free of charge, provided that the source is acknowledged (http://www.eea.europa.eu/legal/copyright). Copyright holder: European Environment Agency (EEA).</gco:CharacterString>
</gmd:useLimitation>
</gmd:MD_Constraints>
</gmd:resourceConstraints>
<gmd:resourceConstraints>
<gmd:MD_LegalConstraints>
<gmd:useConstraints>
<gmd:MD_RestrictionCode codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_RestrictionCode"
codeListValue="otherRestrictions"/>
</gmd:useConstraints>
<gmd:otherConstraints>
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/ConditionsApplyingToAccessAndUse/noConditionsApply">No conditions apply to access and use</gmx:Anchor>
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
<gmd:resourceConstraints>
<gmd:MD_LegalConstraints>
<gmd:accessConstraints>
<gmd:MD_RestrictionCode codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_RestrictionCode"
codeListValue="otherRestrictions"/>
</gmd:accessConstraints>
<gmd:otherConstraints>
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/LimitationsOnPublicAccess/noLimitations">No limitations to public access</gmx:Anchor>
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
</xsl:if>
</xsl:template> -->
<xsl:template match="gmd:resourceConstraints/*/gmd:otherConstraints[gco:CharacterString = 'no limitation' or gco:CharacterString = 'no limitations' or gco:CharacterString = 'No limitations']">
<gmd:otherConstraints>
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/LimitationsOnPublicAccess/noLimitations">No limitations to public access</gmx:Anchor>
</gmd:otherConstraints>
</xsl:template>
<xsl:template match="gmd:resourceConstraints/*/gmd:otherConstraints[gco:CharacterString = 'no conditions apply' or gco:CharacterString = 'No conditions apply']">
<gmd:otherConstraints>
<gmx:Anchor xlink:href="http://inspire.ec.europa.eu/metadata-codelist/ConditionsApplyingToAccessAndUse/noConditionsApply">No conditions apply to access and use</gmx:Anchor>
</gmd:otherConstraints>
</xsl:template>
<!-- Add the 2 inspire decimals ... -->
<xsl:template match="gmd:EX_GeographicBoundingBox/*/gco:Decimal[matches(., '^(-?[0-9]+|[0-9]+.[0-9]{1})$')]">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:value-of select="format-number(., '#0.00')"/>
</xsl:copy>
</xsl:template>
<xsl:template match="gmd:MD_Metadata/gmd:contact[*/gmd:organisationName/* = 'European Environment Agency']">
<gmd:contact>
<gmd:CI_ResponsibleParty>
<gmd:organisationName>
<gco:CharacterString>European Environment Agency</gco:CharacterString>
</gmd:organisationName>
<gmd:contactInfo>
<gmd:CI_Contact>
<gmd:address>
<gmd:CI_Address>
<gmd:deliveryPoint>
<gco:CharacterString>Kongens Nytorv 6</gco:CharacterString>
</gmd:deliveryPoint>
<gmd:city>
<gco:CharacterString>Copenhagen</gco:CharacterString>
</gmd:city>
<gmd:administrativeArea>
<gco:CharacterString>K</gco:CharacterString>
</gmd:administrativeArea>
<gmd:postalCode>
<gco:CharacterString>1050</gco:CharacterString>
</gmd:postalCode>
<gmd:country>
<gco:CharacterString>Denmark</gco:CharacterString>
</gmd:country>
<gmd:electronicMailAddress>
<gco:CharacterString>sdi@eea.europa.eu</gco:CharacterString>
</gmd:electronicMailAddress>
</gmd:CI_Address>
</gmd:address>
</gmd:CI_Contact>
</gmd:contactInfo>
<gmd:role>
<gmd:CI_RoleCode codeList="http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#CI_RoleCode"
codeListValue="pointOfContact"/>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:contact>
</xsl:template>
<!-- Do a copy of every nodes and attributes -->
<xsl:template match="@*|node()|comment()">
<xsl:copy>
<xsl:apply-templates select="@*|node()|comment()"/>
</xsl:copy>
</xsl:template>
<!-- Remove geonet:* elements. -->
<xsl:template match="geonet:*" priority="2"/>
</xsl:stylesheet>