-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path19139-to-gvq.xsl
338 lines (296 loc) · 15 KB
/
19139-to-gvq.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:gmi="http://www.isotc211.org/2005/gmi"
xmlns:gmx="http://www.isotc211.org/2005/gmx"
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:gmd="http://www.isotc211.org/2005/gmd"
xmlns:updated19115="http://www.geoviqua.org/19115_updates"
xmlns:gvq="http://www.geoviqua.org/QualityInformationModel/4.0"
xmlns:gmd19157="http://www.geoviqua.org/gmd19157"
xmlns:un="http://www.uncertml.org/2.0"
exclude-result-prefixes="#all">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!--<xsl:strip-space elements="*"/>-->
<!-- ===============================================
Begin processing
==================================================== -->
<!-- start with root element -->
<xsl:template match="/">
<xsl:apply-templates select="gmd:MD_Metadata"/>
</xsl:template>
<!-- identity transform -->
<xsl:template match="@*|node()" name="identity">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- ===============================================
gmd:MD_Metadata to gvq:GVQ_Metadata and update namespaces/schema locations
==================================================== -->
<xsl:template match="gmd:MD_Metadata" priority="200">
<xsl:element name="gvq:GVQ_Metadata">
<xsl:namespace name="updated19115" select="'http://www.geoviqua.org/19115_updates'"/>
<xsl:namespace name="gmx" select="'http://www.isotc211.org/2005/gmx'"/>
<xsl:namespace name="xlink" select="'http://www.w3.org/1999/xlink'"/>
<xsl:namespace name="xsi" select="'http://www.w3.org/2001/XMLSchema-instance'"/>
<xsl:namespace name="gmd" select="'http://www.isotc211.org/2005/gmd'"/>
<xsl:namespace name="gco" select="'http://www.isotc211.org/2005/gco'"/>
<xsl:namespace name="gvq" select="'http://www.geoviqua.org/QualityInformationModel/4.0'"/>
<xsl:namespace name="gml" select="'http://www.opengis.net/gml/3.2'"/>
<xsl:namespace name="gmd19157" select="'http://www.geoviqua.org/gmd19157'"/>
<xsl:namespace name="un" select="'http://www.uncertml.org/2.0'"/>
<xsl:copy-of select="@*[name()!='xsi:schemaLocation']"/>
<xsl:attribute name="xsi:schemaLocation">
<xsl:text>http://www.geoviqua.org/QualityInformationModel/4.0 http://schemas.geoviqua.org/GVQ/4.0/GeoViQua_PQM_UQM.xsd </xsl:text>
<xsl:text>http://www.uncertml.org/2.0 http://www.uncertml.org/uncertml.xsd</xsl:text>
</xsl:attribute>
<xsl:apply-templates select="child::*"/>
</xsl:element>
</xsl:template>
<!-- ===============================================
gmd:MD_DataIdentification to gvq:GVQ_DataIdentification
==================================================== -->
<xsl:template match="gmd:MD_DataIdentification">
<xsl:element name="gvq:GVQ_DataIdentification">
<xsl:apply-templates select="@*|node()"/>
<!-- insert gvq:referenceDoc skeleton -->
<xsl:call-template name="gvqReferenceDoc"/>
</xsl:element>
</xsl:template>
<!-- ===============================================
gmd:MD_Identifier to updated19115:MD_Identifier
==================================================== -->
<xsl:template match="gmd:MD_Identifier">
<xsl:element name="updated19115:MD_Identifier">
<xsl:apply-templates select="@*|node()"/>
<!-- add updated19115:codeSpace skeleton -->
<updated19115:codeSpace gco:nilReason="missing">
<gco:CharacterString/>
</updated19115:codeSpace>
</xsl:element>
</xsl:template>
<!-- ===============================================
gmd:CI_OnlineResource under gmd:MD_DigitalTransferOptions parent to updated19115:CI_OnlineResource
==================================================== -->
<xsl:template match="gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource">
<xsl:element name="updated19115:CI_OnlineResource">
<xsl:apply-templates select="@*|node()"/>
<updated19115:protocolRequest gco:nilReason="missing">
<gco:CharacterString/>
</updated19115:protocolRequest>
</xsl:element>
</xsl:template>
<!-- ===============================================
Insert gmd:describes after gmd:distributionInfo
==================================================== -->
<xsl:template match="gmd:MD_Metadata/gmd:distributionInfo">
<xsl:call-template name="identity"/>
<xsl:choose>
<xsl:when test="/gmd:MD_Metadata/gmd:describes">
<!-- copy all gmd:describes nodes to the right location -->
<xsl:copy-of select="/gmd:MD_Metadata/gmd:describes"/>
</xsl:when>
<xsl:otherwise>
<!-- insert gmd:describes skeleton -->
<xsl:call-template name="gmdDescribes"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- remove all original gmd:describes nodes after copy -->
<xsl:template match="gmd:MD_Metadata/gmd:describes"/>
<!-- ===============================================
GVQ data quality changes
==================================================== -->
<!-- gmd:dataQualityInfo to gvq:dataQualityInfo -->
<xsl:template match="gmd:dataQualityInfo">
<xsl:element name="gvq:dataQualityInfo">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<!-- gmd:DQ_DataQuality to gvq:GVQ_DataQuality -->
<xsl:template match="gmd:DQ_DataQuality" priority="500">
<xsl:element name="gvq:GVQ_DataQuality">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<!-- add gmd19157:resultScope to the first child of gmd:result (e.g. gmd:DQ_QuantitativeResult) -->
<xsl:template match="gmd:report//gmd:result/*[1]" priority="300">
<xsl:element name="gmd19157:{local-name()}">
<xsl:copy-of select="@*"/>
<gmd19157:resultScope xlink:href="#"/>
<xsl:apply-templates select="child::*"/>
</xsl:element>
</xsl:template>
<!-- update the first child of a gmd:report (e.g. gmd:DQ_QuantitativeAttributeAccuracy) to match AbstractDQ_Element_Type's sequence -->
<xsl:template match="gmd:report/*[1]" priority="400">
<xsl:element name="gmd19157:{local-name()}">
<xsl:copy-of select="@*"/>
<!-- move gmd:dateTime -->
<xsl:apply-templates select="gmd:dateTime"/>
<!-- move into DQ_MeasureReference -->
<gmd19157:measure>
<gmd19157:DQ_MeasureReference>
<xsl:apply-templates select="gmd:measureIdentification"/>
<xsl:apply-templates select="gmd:nameOfMeasure"/>
<xsl:apply-templates select="gmd:measureDescription"/>
</gmd19157:DQ_MeasureReference>
</gmd19157:measure>
<!-- these elements will be moved into a DQ_EvaluationMethod skeleton -->
<xsl:variable name="evaluationMethodDescription" select="gmd:evaluationMethodDescription"/>
<xsl:variable name="evaluationProcedure" select="gmd:evaluationProcedure"/>
<xsl:variable name="evaluationMethodType" select="gmd:evaluationMethodType"/>
<gmd19157:evaluation>
<!-- insert gvq:GVQ_SampleBasedInspection as a placeholder for now,
can template additional DQ_EvaluationMethod types and extend this
to test the above evaluation variables and call the most suitable template -->
<xsl:call-template name="gvqGVQ_SampleBasedInspection">
<xsl:with-param name="evaluationMethodDescription" select="$evaluationMethodDescription"/>
<xsl:with-param name="evaluationProcedure" select="$evaluationProcedure"/>
<xsl:with-param name="evaluationMethodType" select="$evaluationMethodType"/>
</xsl:call-template>
</gmd19157:evaluation>
<!-- copy all child nodes apart from those we have "moved" -->
<xsl:apply-templates select="child::*[not(self::gmd:dateTime|
self::gmd:evaluationMethodDescription|self::gmd:evaluationProcedure|self::gmd:evaluationMethodType|
self::gmd:measureIdentification|self::gmd:nameOfMeasure|self::gmd:measureDescription
)]"/>
</xsl:element>
</xsl:template>
<!-- rename gmd prefix to gmd19157 where appropriate (ancestors that contain original gmd types should not have their child elements renamed) -->
<xsl:template name="gmd_to_gmd19157" match="gmd:dataQualityInfo//gmd:*[not(ancestor-or-self::gmd:MD_Identifier|
ancestor::gmd:processor|
ancestor::gmd:scaleDenominator|
ancestor::gmd:sourceReferenceSystem|
ancestor::gmd:sourceCitation|
ancestor::gmd:sourceExtent|
ancestor::gmd:spatialRepresentationType|
ancestor::gmd:*[parent::gmd:DQ_Scope]|
ancestor::gmi:resultFile|
ancestor::gmi:resultSpatialRepresentation|
ancestor::gmi:resultContentDescription|
ancestor::gmi:resultFormat
)]" priority="200">
<xsl:element name="gmd19157:{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<!-- ===============================================
Skeletons for required/optional elements
==================================================== -->
<!-- gvq:GVQ_SampleBasedInspection skeleton -->
<xsl:template name="gvqGVQ_SampleBasedInspection">
<xsl:param name="evaluationMethodDescription"/>
<xsl:param name="evaluationProcedure"/>
<xsl:param name="evaluationMethodType"/>
<gvq:GVQ_SampleBasedInspection>
<xsl:apply-templates select="$evaluationMethodDescription"/>
<xsl:apply-templates select="$evaluationProcedure"/>
<gmd19157:referenceDoc xlink:href="#"/>
<xsl:apply-templates select="$evaluationMethodType"/>
<gmd19157:samplingScheme gco:nilReason="missing">
<gco:CharacterString/>
</gmd19157:samplingScheme>
<gmd19157:lotDescription gco:nilReason="missing">
<gco:CharacterString/>
</gmd19157:lotDescription>
<gmd19157:samplingRatio gco:nilReason="missing">
<gco:CharacterString/>
</gmd19157:samplingRatio>
</gvq:GVQ_SampleBasedInspection>
</xsl:template>
<!-- gvq:referenceDoc skeleton -->
<xsl:template name="gvqReferenceDoc">
<gvq:referenceDoc>
<gvq:GVQ_Publication>
<gmd:title gco:nilReason="missing">
<gco:CharacterString/>
</gmd:title>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>1900</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" codeListValue=""/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
<gmd:citedResponsibleParty xlink:href="#"/>
<gmd:series>
<gmd:CI_Series>
<gmd:name gco:nilReason="missing">
<gco:CharacterString/>
</gmd:name>
<gmd:issueIdentification gco:nilReason="missing">
<gco:CharacterString/>
</gmd:issueIdentification>
<gmd:page gco:nilReason="missing">
<gco:CharacterString/>
</gmd:page>
</gmd:CI_Series>
</gmd:series>
<gmd:ISSN gco:nilReason="missing">
<gco:CharacterString/>
</gmd:ISSN>
<gvq:target xlink:href="#"/>
<gvq:doi gco:nilReason="missing">
<gco:CharacterString/>
</gvq:doi>
<gvq:purpose>
<gvq:GVQ_PublicationPurposeCode codeList="http://schemas.geoviqua.org/GVQ/4.0/resources/Codelist/gvqCodelists.xml#GVQ_PublicationPurposeCode" codeListValue=""/>
</gvq:purpose>
<gvq:scope xlink:href="#"/>
<gvq:category>
<gvq:GVQ_PublicationCategoryCode codeList="http://schemas.geoviqua.org/GVQ/4.0/resources/Codelist/gvqCodelists.xml#GVQ_PublicationCategoryCode" codeListValue=""/>
</gvq:category>
<gvq:onlineResource>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL/>
</gmd:linkage>
</gmd:CI_OnlineResource>
</gvq:onlineResource>
</gvq:GVQ_Publication>
</gvq:referenceDoc>
</xsl:template>
<!-- gmd:describes skeleton -->
<xsl:template name="gmdDescribes">
<gmd:describes>
<gmx:MX_DataSet>
<gmd:has xlink:href="#"/>
<gmx:dataFile>
<gmx:MX_DataFile>
<gmx:fileName>
<gmx:FileName/>
</gmx:fileName>
<gmx:fileDescription gco:nilReason="missing">
<gco:CharacterString/>
</gmx:fileDescription>
<gmx:fileType>
<gmx:MimeFileType type=""/>
</gmx:fileType>
<gmx:featureTypes gco:nilReason="missing">
<gco:LocalName/>
</gmx:featureTypes>
<gmx:fileFormat>
<gmd:MD_Format>
<gmd:name gco:nilReason="missing">
<gco:CharacterString/>
</gmd:name>
<gmd:version gco:nilReason="missing">
<gco:CharacterString/>
</gmd:version>
<gmd:fileDecompressionTechnique gco:nilReason="missing">
<gco:CharacterString/>
</gmd:fileDecompressionTechnique>
</gmd:MD_Format>
</gmx:fileFormat>
</gmx:MX_DataFile>
</gmx:dataFile>
</gmx:MX_DataSet>
</gmd:describes>
</xsl:template>
</xsl:stylesheet>