Mercurial > repos > ecology > xmlstarlet
comparison test-data/iso2eml_all_in_one.xsl @ 0:4a9ac1df3278 draft default tip
"planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/main/tools-ecology/tools/xmlstarlet commit 6ebe0c98dd0d727b9202422e64f6d5f7697743fb"
author | ecology |
---|---|
date | Sun, 06 Mar 2022 22:10:31 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a9ac1df3278 |
---|---|
1 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" | |
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
3 xmlns:eml="eml://ecoinformatics.org/eml-2.1.1" | |
4 xmlns:stmml="http://www.xml-cml.org/schema/stmml" | |
5 xmlns:sw="eml://ecoinformatics.org/software-2.1.1" | |
6 xmlns:cit="eml://ecoinformatics.org/literature-2.1.1" | |
7 xmlns:ds="eml://ecoinformatics.org/dataset-2.1.1" | |
8 xmlns:prot="eml://ecoinformatics.org/protocol-2.1.1" | |
9 xmlns:doc="eml://ecoinformatics.org/documentation-2.1.1" | |
10 xmlns:res="eml://ecoinformatics.org/resource-2.1.1" | |
11 xmlns:gmd="http://www.isotc211.org/2005/gmd" | |
12 xmlns:gco="http://www.isotc211.org/2005/gco" | |
13 xmlns:gml="http://www.opengis.net/gml/3.2" | |
14 xmlns:gmx="http://www.isotc211.org/2005/gmx" | |
15 xmlns:xlink="http://www.w3.org/1999/xlink" | |
16 xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
17 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > | |
18 | |
19 <!--xsl:import href="iso2eml-party.xsl"/> | |
20 <xsl:import href="iso2eml-coverage.xsl"/> | |
21 <xsl:import href="iso2eml-project.xsl"/--> | |
22 | |
23 <xsl:output method="xml" encoding="UTF-8" indent="yes" /> | |
24 <xsl:strip-space elements="*" /> | |
25 | |
26 <xsl:template match="/gmd:MD_Metadata"> | |
27 <eml:eml> | |
28 <xsl:attribute name="xsi:schemaLocation">eml://ecoinformatics.org/eml-2.1.1 ~/development/eml/eml.xsd</xsl:attribute> | |
29 <!-- Add the packageId --> | |
30 <xsl:attribute name="packageId"><xsl:value-of select="normalize-space(gmd:fileIdentifier/gco:CharacterString)"/></xsl:attribute> | |
31 <xsl:attribute name="system"><xsl:value-of select="'knb'"/></xsl:attribute> | |
32 <xsl:attribute name="scope"><xsl:value-of select="'system'"/></xsl:attribute> | |
33 <dataset> | |
34 <!-- Add the title --> | |
35 <xsl:for-each select="gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString"> | |
36 <title><xsl:value-of select="normalize-space(.)"/></title> | |
37 </xsl:for-each> | |
38 | |
39 <!-- Add creators --> | |
40 <xsl:call-template name="creators"> | |
41 <xsl:with-param name="doc" select="." /> | |
42 </xsl:call-template> | |
43 | |
44 <!-- Add additional parties --> | |
45 <xsl:call-template name="additional-parties"> | |
46 <xsl:with-param name="doc" select="." /> | |
47 </xsl:call-template> | |
48 | |
49 <!-- Add the pubDate if available --> | |
50 <xsl:if test="gmd:dateStamp/gco:DateTime != ''"> | |
51 <pubDate> | |
52 <xsl:choose> | |
53 <xsl:when test="contains(gmd:dateStamp/gco:DateTime, 'T')"> | |
54 <xsl:value-of select="normalize-space(substring-before(gmd:dateStamp/gco:DateTime, 'T'))" /> | |
55 </xsl:when> | |
56 <xsl:otherwise> | |
57 <xsl:value-of select="normalize-space(gmd:dateStamp/gco:DateTime)" /> | |
58 </xsl:otherwise> | |
59 </xsl:choose> | |
60 </pubDate> | |
61 </xsl:if> | |
62 | |
63 <!-- Add the language --> | |
64 <xsl:if test="gmd:language/gco:CharacterString != ''"> | |
65 <language><xsl:value-of select="normalize-space(gmd:language/gco:CharacterString)" /></language> | |
66 </xsl:if> | |
67 | |
68 <!-- Add the abstract --> | |
69 <abstract> | |
70 <para><xsl:value-of select="normalize-space(gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString)" /></para> | |
71 </abstract> | |
72 | |
73 <!-- Add keywords --> | |
74 <xsl:if test="gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords != ''"> | |
75 <xsl:call-template name="keywords"> | |
76 <xsl:with-param name="keys" select="gmd:identificationInfo/gmd:MD_DataIdentification/gmd:descriptiveKeywords" /> | |
77 </xsl:call-template> | |
78 </xsl:if> | |
79 | |
80 <!-- Add any gmd:topicCategory fields as keywords too --> | |
81 <xsl:if test="gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory != ''"> | |
82 <xsl:call-template name="topics"> | |
83 <xsl:with-param name="topics" select="gmd:identificationInfo/gmd:MD_DataIdentification/gmd:topicCategory" /> | |
84 </xsl:call-template> | |
85 </xsl:if> | |
86 | |
87 <!-- Add intellectual rights --> | |
88 <!-- | |
89 Note these rules are specific to the arcticdata.io content, | |
90 and will need to be generalized | |
91 --> | |
92 <xsl:choose> | |
93 <xsl:when test="gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceConstraints/gmd:MD_Constraints/gmd:useLimitation"> | |
94 <!-- Transfer MD_Constraints/useLimitation directly --> | |
95 <intellectualRights> | |
96 <para> | |
97 <xsl:value-of select="normalize-space(gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceConstraints/gmd:MD_Constraints/gmd:useLimitation/gco:CharacterString)" /> | |
98 </para> | |
99 </intellectualRights> | |
100 </xsl:when> | |
101 <xsl:otherwise> | |
102 | |
103 <!-- Assign a CC-BY license --> | |
104 <intellectualRights> | |
105 <para> | |
106 <xsl:text>This work is licensed under the Creative Commons Attribution 4.0 International License.To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.</xsl:text> | |
107 </para> | |
108 </intellectualRights> | |
109 | |
110 </xsl:otherwise> | |
111 </xsl:choose> | |
112 | |
113 <!-- Add distribution --> | |
114 | |
115 <!-- Add coverage --> | |
116 <xsl:call-template name="coverage" /> | |
117 | |
118 <!-- Add contacts --> | |
119 <xsl:call-template name="contacts"> | |
120 <xsl:with-param name="doc" select="." /> | |
121 </xsl:call-template> | |
122 | |
123 | |
124 <!-- Add the publisher --> | |
125 <xsl:call-template name="publishers"> | |
126 <xsl:with-param name="doc" select="." /> | |
127 </xsl:call-template> | |
128 | |
129 | |
130 <!-- Add the pubPlace --> | |
131 | |
132 <!-- Add the methods --> | |
133 | |
134 <!-- Add the project --> | |
135 <xsl:call-template name="project"> | |
136 <xsl:with-param name="doc" select="." /> | |
137 </xsl:call-template> | |
138 | |
139 <!-- Add entities --> | |
140 | |
141 </dataset> | |
142 </eml:eml> | |
143 </xsl:template> | |
144 | |
145 <!-- Process Keywords and associated thesuarus entries --> | |
146 <xsl:template name="keywords"> | |
147 <xsl:param name = "keys" /> | |
148 <xsl:for-each select="$keys"> | |
149 <xsl:variable name="kw-type" select="./gmd:MD_Keywords/gmd:type/gmd:MD_KeywordTypeCode/@codeListValue" /> | |
150 <keywordSet> | |
151 <xsl:for-each select="./gmd:MD_Keywords/gmd:keyword/gco:CharacterString"> | |
152 <keyword> | |
153 <!-- ISO: discipline, place, stratum, temporal, theme --> | |
154 <!-- EML: place, stratum, temporal, theme, taxonomic --> | |
155 <xsl:if test="$kw-type != '' and ( | |
156 $kw-type = 'place' or $kw-type = 'stratum' or | |
157 $kw-type = 'temporal' or $kw-type = 'theme')"> | |
158 <xsl:attribute name="keywordType"><xsl:value-of select="normalize-space($kw-type)"/></xsl:attribute> | |
159 </xsl:if> | |
160 <xsl:value-of select="normalize-space(.)" /> | |
161 </keyword> | |
162 </xsl:for-each> | |
163 <xsl:if test="./gmd:MD_Keywords/gmd:thesaurusName != ''"> | |
164 <xsl:choose> | |
165 <xsl:when test="./gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:collectiveTitle != ''"> | |
166 <keywordThesaurus> | |
167 <xsl:value-of select="normalize-space(./gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:collectiveTitle/gco:CharacterString)" /> | |
168 </keywordThesaurus> | |
169 </xsl:when> | |
170 <xsl:otherwise> | |
171 <keywordThesaurus> | |
172 <xsl:value-of select="normalize-space(./gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString)" /> | |
173 </keywordThesaurus> | |
174 </xsl:otherwise> | |
175 </xsl:choose> | |
176 </xsl:if> | |
177 </keywordSet> | |
178 </xsl:for-each> | |
179 </xsl:template> | |
180 | |
181 <!-- Process Topics --> | |
182 <xsl:template name="topics"> | |
183 <xsl:param name = "topics" /> | |
184 <xsl:for-each select="$topics"> | |
185 <keywordSet> | |
186 <xsl:for-each select="./gmd:MD_TopicCategoryCode"> | |
187 <keyword> | |
188 <xsl:value-of select="normalize-space(.)" /> | |
189 </keyword> | |
190 </xsl:for-each> | |
191 <keywordThesaurus>ISO 19115:2003 MD_TopicCategoryCode</keywordThesaurus> | |
192 </keywordSet> | |
193 </xsl:for-each> | |
194 </xsl:template> | |
195 | |
196 <!-- Match any geographic or temporal coverage elements --> | |
197 <xsl:template name="coverage" match="gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent"> | |
198 <!-- Add EML geographic and temporal coverages, if available --> | |
199 <!-- Add geographic coverages --> | |
200 <xsl:variable name="bboxCount" select="count(.//gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox)" /> | |
201 <xsl:variable name="temporalCount" select="count(.//gmd:EX_Extent/gmd:temporalElement)" /> | |
202 <xsl:variable name="descriptionCount" select="count(.//gmd:EX_Extent/gmd:description)" /> | |
203 <xsl:variable name="exDescCount" select="count(.//gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicDescription)" /> | |
204 <xsl:if test="$temporalCount + $bboxCount > 0"> | |
205 <coverage> | |
206 <xsl:choose> | |
207 <xsl:when test="($descriptionCount + $exDescCount) >= $bboxCount"> | |
208 | |
209 <xsl:variable name="descriptions" > | |
210 <xsl:if test="//gmd:EX_Extent/gmd:description"> | |
211 <xsl:for-each select=".//gmd:EX_Extent"> | |
212 <xsl:copy-of select="gmd:description" /> | |
213 <xsl:value-of select="'. '" /> | |
214 </xsl:for-each> | |
215 </xsl:if> | |
216 </xsl:variable> | |
217 | |
218 <xsl:variable name="codeDescriptions" > | |
219 <xsl:for-each select=".//gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicDescription"> | |
220 <xsl:value-of select="gmd:geographicIdentifier/gmd:MD_Identifier/gmd:code/gco:CharacterString" /> | |
221 <xsl:if test="count(//gmd:EX_GeographicDescription) > 1"> | |
222 <xsl:value-of select="', '" /> | |
223 </xsl:if> | |
224 </xsl:for-each> | |
225 </xsl:variable> | |
226 | |
227 <xsl:apply-templates select=".//gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox"> | |
228 <xsl:with-param name="allDescriptions" select="concat($descriptions, $codeDescriptions)" /> | |
229 </xsl:apply-templates> | |
230 </xsl:when> | |
231 <xsl:otherwise> | |
232 <xsl:comment>No geographic description provided</xsl:comment> | |
233 <xsl:apply-templates select=".//gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox"> | |
234 <xsl:with-param name="allDescriptions" select="'No geographic description provided.'" /> | |
235 </xsl:apply-templates> | |
236 </xsl:otherwise> | |
237 </xsl:choose> | |
238 | |
239 <!-- Add temporal coverages --> | |
240 <xsl:apply-templates select=".//gmd:EX_Extent/gmd:temporalElement" /> | |
241 </coverage> | |
242 </xsl:if> | |
243 | |
244 </xsl:template> | |
245 | |
246 <!-- Handle geographic bounding boxes --> | |
247 <xsl:template match="gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox"> | |
248 <xsl:param name="allDescriptions" /> | |
249 <xsl:comment>Geographic coverage</xsl:comment> | |
250 <!-- Handle geographic description --> | |
251 <xsl:choose> | |
252 <xsl:when test="$allDescriptions != ''"> | |
253 | |
254 <geographicCoverage> | |
255 <geographicDescription> | |
256 <xsl:value-of select="$allDescriptions" /> | |
257 </geographicDescription> | |
258 <xsl:apply-templates select="../gmd:geographicElement/gmd:EX_GeographicBoundingBox" /> | |
259 <!-- Add bounding coordinates --> | |
260 <boundingCoordinates> | |
261 <westBoundingCoordinate> | |
262 <xsl:value-of select="normalize-space(gmd:westBoundLongitude/gco:Decimal)" /> | |
263 </westBoundingCoordinate> | |
264 <eastBoundingCoordinate> | |
265 <xsl:value-of select="normalize-space(gmd:eastBoundLongitude/gco:Decimal)" /> | |
266 </eastBoundingCoordinate> | |
267 <northBoundingCoordinate> | |
268 <xsl:value-of select="normalize-space(gmd:northBoundLatitude/gco:Decimal)" /> | |
269 </northBoundingCoordinate> | |
270 <southBoundingCoordinate> | |
271 <xsl:value-of select="normalize-space(gmd:southBoundLatitude/gco:Decimal)" /> | |
272 </southBoundingCoordinate> | |
273 </boundingCoordinates> | |
274 </geographicCoverage> | |
275 | |
276 </xsl:when> | |
277 <xsl:otherwise> | |
278 | |
279 <!-- Make up a description from the bounding box --> | |
280 <xsl:if test=".//gmd:EX_GeographicBoundingBox"> | |
281 | |
282 <geographicCoverage> | |
283 <geographicDescription> | |
284 <xsl:text>This research took place in the area bounded by: </xsl:text> | |
285 <xsl:value-of select="normalize-space(gmd:EX_GeographicBoundingBox/gmd:westBoundLongitude/gco:Decimal)" /> | |
286 <xsl:text> West,</xsl:text> | |
287 <xsl:value-of select="normalize-space(gmd:EX_GeographicBoundingBox/gmd:eastBoundLongitude/gco:Decimal)" /> | |
288 <xsl:text> East,</xsl:text> | |
289 <xsl:value-of select="normalize-space(gmd:EX_GeographicBoundingBox/gmd:northBoundLatitude/gco:Decimal)" /> | |
290 <xsl:text> North,</xsl:text> | |
291 <xsl:value-of select="normalize-space(gmd:EX_GeographicBoundingBox/gmd:southBoundLatitude/gco:Decimal)" /> | |
292 <xsl:text> South.</xsl:text> | |
293 </geographicDescription> | |
294 <!-- Add bounding coordinates --> | |
295 <boundingCoordinates> | |
296 <westBoundingCoordinate> | |
297 <xsl:value-of select="normalize-space(gmd:westBoundLongitude/gco:Decimal)" /> | |
298 </westBoundingCoordinate> | |
299 <eastBoundingCoordinate> | |
300 <xsl:value-of select="normalize-space(gmd:eastBoundLongitude/gco:Decimal)" /> | |
301 </eastBoundingCoordinate> | |
302 <northBoundingCoordinate> | |
303 <xsl:value-of select="normalize-space(gmd:northBoundLatitude/gco:Decimal)" /> | |
304 </northBoundingCoordinate> | |
305 <southBoundingCoordinate> | |
306 <xsl:value-of select="normalize-space(gmd:southBoundLatitude/gco:Decimal)" /> | |
307 </southBoundingCoordinate> | |
308 </boundingCoordinates> | |
309 </geographicCoverage> | |
310 | |
311 </xsl:if> | |
312 </xsl:otherwise> | |
313 </xsl:choose> | |
314 </xsl:template> | |
315 | |
316 <!-- Handle temporal coverage elements --> | |
317 <xsl:template name="temporalCoverage" match="gmd:EX_Extent/gmd:temporalElement"> | |
318 <xsl:comment>Temporal coverage</xsl:comment> | |
319 <xsl:choose> | |
320 <xsl:when test="gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod"> | |
321 | |
322 <!-- We have a period, use rangeOfDates --> | |
323 <temporalCoverage> | |
324 <rangeOfDates> | |
325 <beginDate> | |
326 <xsl:choose> | |
327 <xsl:when test="contains(gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition, 'T')"> | |
328 <calendarDate> | |
329 <xsl:value-of select="normalize-space(substring-before(gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition, 'T'))" /> | |
330 </calendarDate> | |
331 <time> | |
332 <xsl:value-of select="normalize-space(substring-after(gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition, 'T'))" /> | |
333 </time> | |
334 </xsl:when> | |
335 <xsl:otherwise> | |
336 <calendarDate> | |
337 <xsl:value-of select="normalize-space(gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition)" /> | |
338 </calendarDate> | |
339 </xsl:otherwise> | |
340 </xsl:choose> | |
341 </beginDate> | |
342 <endDate> | |
343 <xsl:choose> | |
344 <xsl:when test="contains(gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition, 'T')"> | |
345 <calendarDate> | |
346 <xsl:value-of select="normalize-space(substring-before(gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition, 'T'))" /> | |
347 </calendarDate> | |
348 <time> | |
349 <xsl:value-of select="normalize-space(substring-after(gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition, 'T'))" /> | |
350 </time> | |
351 </xsl:when> | |
352 <xsl:otherwise> | |
353 <calendarDate> | |
354 <xsl:value-of select="normalize-space(gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition)" /> | |
355 </calendarDate> | |
356 </xsl:otherwise> | |
357 </xsl:choose> | |
358 </endDate> | |
359 </rangeOfDates> | |
360 </temporalCoverage> | |
361 </xsl:when> | |
362 <xsl:otherwise> | |
363 | |
364 <!-- No time period, look for time instant --> | |
365 <xsl:if test="gmd:EX_TemporalExtent/gmd:extent/gml:TimeInstant"> | |
366 | |
367 <temporalCoverage> | |
368 <singleDateTime> | |
369 <calendarDate> | |
370 <xsl:value-of select="normalize-space(gmd:EX_TemporalExtent/gmd:extent/gml:TimeInstant/gml:timePosition)" /> | |
371 </calendarDate> | |
372 </singleDateTime> | |
373 </temporalCoverage> | |
374 | |
375 </xsl:if> | |
376 </xsl:otherwise> | |
377 </xsl:choose> | |
378 </xsl:template> | |
379 | |
380 <!-- Match any gmd:credit elements, and if they are present, add a project entry with funding fields --> | |
381 <xsl:template name="project"> | |
382 <xsl:param name = "doc" /> | |
383 <xsl:variable name="awardCount" select="count(./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:credit)" /> | |
384 <!-- Add funding elements --> | |
385 <xsl:if test="$awardCount > 0"> | |
386 <project> | |
387 <!-- Add the project title --> | |
388 <title><xsl:value-of select="normalize-space(./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title[1]/gco:CharacterString)"/></title> | |
389 | |
390 <!-- Add the project abstract --> | |
391 <xsl:if test='./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract[1]/gco:CharacterString != ""'> | |
392 <abstract><xsl:value-of select="normalize-space(./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract[1]/gco:CharacterString)"/></abstract> | |
393 </xsl:if> | |
394 | |
395 <!-- Add personnel from the PI list or the author list --> | |
396 <xsl:choose> | |
397 <!-- Select PIs from the citation --> | |
398 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator" or @codeListValue="coPrincipalInvestigator" or @codeListValue="collaboratingPrincipalInvestigator"]]!=""'> | |
399 <xsl:for-each select='gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator" or @codeListValue="coPrincipalInvestigator" or @codeListValue="collaboratingPrincipalInvestigator"]]'> | |
400 <personnel> | |
401 <xsl:call-template name="party"> | |
402 <xsl:with-param name="party" select = "." /> | |
403 </xsl:call-template> | |
404 <role>principalInvestigator</role> | |
405 </personnel> | |
406 </xsl:for-each> | |
407 </xsl:when> | |
408 <!-- Alternatively, select PIs from anywhere in the doc --> | |
409 <xsl:when test='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator" or @codeListValue="coPrincipalInvestigator" or @codeListValue="collaboratingPrincipalInvestigator"]] != ""'> | |
410 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator" or @codeListValue="coPrincipalInvestigator" or @codeListValue="collaboratingPrincipalInvestigator"]]'> | |
411 <personnel> | |
412 <xsl:call-template name="party"> | |
413 <xsl:with-param name="party" select = "." /> | |
414 </xsl:call-template> | |
415 <role>principalInvestigator</role> | |
416 </personnel> | |
417 </xsl:for-each> | |
418 </xsl:when> | |
419 <!-- Otherwise, select the author anywhere in the document --> | |
420 <xsl:otherwise> | |
421 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="author"]]'> | |
422 <personnel> | |
423 <xsl:call-template name="party"> | |
424 <xsl:with-param name="party" select = "." /> | |
425 </xsl:call-template> | |
426 <role>principalInvestigator</role> | |
427 </personnel> | |
428 </xsl:for-each> | |
429 </xsl:otherwise> | |
430 </xsl:choose> | |
431 | |
432 <!-- Add all of the funding from gmd:credit --> | |
433 <funding> | |
434 <xsl:for-each select="./gmd:identificationInfo/gmd:MD_DataIdentification/gmd:credit"> | |
435 <para><xsl:value-of select="."/></para> | |
436 </xsl:for-each> | |
437 </funding> | |
438 </project> | |
439 </xsl:if> | |
440 | |
441 </xsl:template> | |
442 | |
443 <!-- Add creator --> | |
444 <xsl:template name="creators"> | |
445 <xsl:param name = "doc" /> | |
446 <xsl:choose> | |
447 <!-- First add any authors from the gmd:citation --> | |
448 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="author"]]!=""'> | |
449 <xsl:for-each select='gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="author"]]'> | |
450 <creator> | |
451 <xsl:call-template name="party"> | |
452 <xsl:with-param name="party" select = "." /> | |
453 </xsl:call-template> | |
454 </creator> | |
455 </xsl:for-each> | |
456 </xsl:when> | |
457 <!-- Alternatively, add authors from anywhere in the document --> | |
458 <xsl:when test='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="author"]] != "" '> | |
459 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="author"]]'> | |
460 <creator> | |
461 <xsl:call-template name="party"> | |
462 <xsl:with-param name="party" select = "." /> | |
463 </xsl:call-template> | |
464 </creator> | |
465 </xsl:for-each> | |
466 </xsl:when> | |
467 <!-- Alternatively, add principalInvestigators from anywhere in the document --> | |
468 <xsl:when test='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator"]] != "" '> | |
469 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator"]]'> | |
470 <creator> | |
471 <xsl:call-template name="party"> | |
472 <xsl:with-param name="party" select = "." /> | |
473 </xsl:call-template> | |
474 </creator> | |
475 </xsl:for-each> | |
476 </xsl:when> | |
477 <!-- Alternatively, add pointOfContact from the citation in the document --> | |
478 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="pointOfContact"]] != "" '> | |
479 <xsl:for-each select='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="pointOfContact"]]'> | |
480 <creator> | |
481 <xsl:call-template name="party"> | |
482 <xsl:with-param name="party" select = "." /> | |
483 </xsl:call-template> | |
484 </creator> | |
485 </xsl:for-each> | |
486 </xsl:when> | |
487 <!-- Alternatively, add pointOfContact from anywhere in the document --> | |
488 <xsl:when test='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="pointOfContact"]] != "" '> | |
489 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="pointOfContact"]]'> | |
490 <creator> | |
491 <xsl:call-template name="party"> | |
492 <xsl:with-param name="party" select = "." /> | |
493 </xsl:call-template> | |
494 </creator> | |
495 </xsl:for-each> | |
496 </xsl:when> | |
497 <!-- Finally, if all else fails, add the Arctic Data Center --> | |
498 <xsl:otherwise> | |
499 <creator> | |
500 <organizationName>NSF Arctic Data Center</organizationName> | |
501 </creator> | |
502 </xsl:otherwise> | |
503 </xsl:choose> | |
504 </xsl:template> | |
505 | |
506 <!-- Add associatedParty: principalInvestigator | |
507 First, check to see if principalInvestigators are listed in the gmd:citation, and if so, use them; | |
508 If not, then search the whole document and use any found. This avoids duplication. | |
509 --> | |
510 <xsl:template name="additional-parties"> | |
511 <xsl:param name = "doc" /> | |
512 <!-- Roles to be handled: originator|principalInvestigator|resourceProvider|distributor --> | |
513 | |
514 <!-- principalInvestigators --> | |
515 <xsl:choose> | |
516 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator"]]!=""'> | |
517 <xsl:for-each select='gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator"]]'> | |
518 <associatedParty> | |
519 <xsl:call-template name="party"> | |
520 <xsl:with-param name="party" select = "." /> | |
521 </xsl:call-template> | |
522 <role>principalInvestigator</role> | |
523 </associatedParty> | |
524 </xsl:for-each> | |
525 </xsl:when> | |
526 <xsl:otherwise> | |
527 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="principalInvestigator"]]'> | |
528 <associatedParty> | |
529 <xsl:call-template name="party"> | |
530 <xsl:with-param name="party" select = "." /> | |
531 </xsl:call-template> | |
532 <role>principalInvestigator</role> | |
533 </associatedParty> | |
534 </xsl:for-each> | |
535 </xsl:otherwise> | |
536 </xsl:choose> | |
537 | |
538 <!-- coPrincipalInvestigator --> | |
539 <xsl:choose> | |
540 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="coPrincipalInvestigator"]]!=""'> | |
541 <xsl:for-each select='gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="coPrincipalInvestigator"]]'> | |
542 <associatedParty> | |
543 <xsl:call-template name="party"> | |
544 <xsl:with-param name="party" select = "." /> | |
545 </xsl:call-template> | |
546 <role>coPrincipalInvestigator</role> | |
547 </associatedParty> | |
548 </xsl:for-each> | |
549 </xsl:when> | |
550 <xsl:otherwise> | |
551 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="coPrincipalInvestigator"]]'> | |
552 <associatedParty> | |
553 <xsl:call-template name="party"> | |
554 <xsl:with-param name="party" select = "." /> | |
555 </xsl:call-template> | |
556 <role>coPrincipalInvestigator</role> | |
557 </associatedParty> | |
558 </xsl:for-each> | |
559 </xsl:otherwise> | |
560 </xsl:choose> | |
561 | |
562 <!-- collaboratingPrincipalInvestigator --> | |
563 <xsl:choose> | |
564 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="collaboratingPrincipalInvestigator"]]!=""'> | |
565 <xsl:for-each select='gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="collaboratingPrincipalInvestigator"]]'> | |
566 <associatedParty> | |
567 <xsl:call-template name="party"> | |
568 <xsl:with-param name="party" select = "." /> | |
569 </xsl:call-template> | |
570 <role>collaboratingPrincipalInvestigator</role> | |
571 </associatedParty> | |
572 </xsl:for-each> | |
573 </xsl:when> | |
574 <xsl:otherwise> | |
575 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="collaboratingPrincipalInvestigator"]]'> | |
576 <associatedParty> | |
577 <xsl:call-template name="party"> | |
578 <xsl:with-param name="party" select = "." /> | |
579 </xsl:call-template> | |
580 <role>collaboratingPrincipalInvestigator</role> | |
581 </associatedParty> | |
582 </xsl:for-each> | |
583 </xsl:otherwise> | |
584 </xsl:choose> | |
585 | |
586 <!-- originators --> | |
587 <xsl:choose> | |
588 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="originator"]]!=""'> | |
589 <xsl:for-each select='gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="originator"]]'> | |
590 <associatedParty> | |
591 <xsl:call-template name="party"> | |
592 <xsl:with-param name="party" select = "." /> | |
593 </xsl:call-template> | |
594 <role>originator</role> | |
595 </associatedParty> | |
596 </xsl:for-each> | |
597 </xsl:when> | |
598 <xsl:otherwise> | |
599 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="originator"]]'> | |
600 <associatedParty> | |
601 <xsl:call-template name="party"> | |
602 <xsl:with-param name="party" select = "." /> | |
603 </xsl:call-template> | |
604 <role>originator</role> | |
605 </associatedParty> | |
606 </xsl:for-each> | |
607 </xsl:otherwise> | |
608 </xsl:choose> | |
609 </xsl:template> | |
610 | |
611 | |
612 <!-- Add contacts --> | |
613 <xsl:template name="contacts"> | |
614 <xsl:param name = "doc" /> | |
615 <xsl:choose> | |
616 <!-- Add contacts from the citation in the document --> | |
617 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:pointOfContact/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="pointOfContact"]]!=""'> | |
618 <xsl:for-each select='gmd:identificationInfo/gmd:MD_DataIdentification/gmd:pointOfContact/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="pointOfContact"]]'> | |
619 <contact> | |
620 <xsl:call-template name="party"> | |
621 <xsl:with-param name="party" select = "." /> | |
622 </xsl:call-template> | |
623 </contact> | |
624 </xsl:for-each> | |
625 </xsl:when> | |
626 <!-- Alternatively, add contacts from anywhere in the document --> | |
627 <xsl:when test='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="pointOfContact"]] != "" '> | |
628 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="pointOfContact"]]'> | |
629 <contact> | |
630 <xsl:call-template name="party"> | |
631 <xsl:with-param name="party" select = "." /> | |
632 </xsl:call-template> | |
633 </contact> | |
634 </xsl:for-each> | |
635 </xsl:when> | |
636 <!-- Alternatively, add the first author as a contact --> | |
637 <!-- | |
638 <xsl:when test='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="author"]] != "" '> | |
639 <contact> | |
640 <xsl:call-template name="party"> | |
641 <xsl:with-param name="party" select = '$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="author"]][1]' /> | |
642 </xsl:call-template> | |
643 </contact> | |
644 </xsl:when> | |
645 --> | |
646 <!-- Finally, if all else fails, add the Arctic Data Center --> | |
647 <xsl:otherwise> | |
648 <contact> | |
649 <organizationName>NSF Arctic Data Center</organizationName> | |
650 </contact> | |
651 </xsl:otherwise> | |
652 </xsl:choose> | |
653 </xsl:template> | |
654 | |
655 <!-- Add publishers | |
656 First, check to see if publishers are listed in the gmd:citation, and if so, use them; | |
657 If not, then search the whole document and use any found. This avoids duplication. | |
658 --> | |
659 <xsl:template name="publishers"> | |
660 <xsl:param name = "doc" /> | |
661 <!-- publisher --> | |
662 <xsl:choose> | |
663 <xsl:when test='$doc/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="publisher"]]!=""'> | |
664 <xsl:for-each select='gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="publisher"]]'> | |
665 <publisher> | |
666 <xsl:call-template name="party"> | |
667 <xsl:with-param name="party" select = "." /> | |
668 </xsl:call-template> | |
669 </publisher> | |
670 </xsl:for-each> | |
671 </xsl:when> | |
672 <xsl:otherwise> | |
673 <xsl:for-each select='$doc//gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode[@codeListValue="publisher"]]'> | |
674 <publisher> | |
675 <xsl:call-template name="party"> | |
676 <xsl:with-param name="party" select = "." /> | |
677 </xsl:call-template> | |
678 </publisher> | |
679 </xsl:for-each> | |
680 </xsl:otherwise> | |
681 </xsl:choose> | |
682 </xsl:template> | |
683 | |
684 <!-- Handle eml-party fields --> | |
685 <xsl:template name="party"> | |
686 <xsl:param name = "party" /> | |
687 <xsl:apply-templates /> | |
688 <xsl:if test="$party//gmd:voice/gco:CharacterString!=''"> | |
689 <phone><xsl:value-of select="normalize-space($party//gmd:voice/gco:CharacterString)"/></phone> | |
690 </xsl:if> | |
691 <xsl:if test="$party//gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString!=''"> | |
692 <electronicMailAddress><xsl:value-of select="normalize-space($party//gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString)"/></electronicMailAddress> | |
693 </xsl:if> | |
694 <xsl:if test="$party//gmd:onlineResource/gmd:CI_OnlineResource/gmd:linkage/gmd:URL!=''"> | |
695 <onlineUrl><xsl:value-of select="normalize-space($party//gmd:onlineResource/gmd:CI_OnlineResource/gmd:linkage/gmd:URL)"/></onlineUrl> | |
696 </xsl:if> | |
697 </xsl:template> | |
698 | |
699 <!-- Add an individualName --> | |
700 <xsl:template match="gmd:individualName"> | |
701 <individualName> | |
702 <surName><xsl:value-of select="normalize-space(gco:CharacterString)"/></surName> | |
703 </individualName> | |
704 </xsl:template> | |
705 | |
706 <!-- Add an organizationName --> | |
707 <xsl:template match="gmd:organisationName"> | |
708 <organizationName><xsl:value-of select="normalize-space(gco:CharacterString)"/></organizationName> | |
709 </xsl:template> | |
710 | |
711 <!-- Add a positionName --> | |
712 <xsl:template match="gmd:positionName"> | |
713 <positionName><xsl:value-of select="normalize-space(gco:CharacterString)"/></positionName> | |
714 </xsl:template> | |
715 | |
716 <!-- voice, email, and role are all noops so they can be reordered correctly --> | |
717 <xsl:template match="gmd:voice" /> | |
718 <xsl:template match="gmd:electronicMailAddress" /> | |
719 <xsl:template match="gmd:role" /> | |
720 <xsl:template match="gmd:onlineResource" /> | |
721 | |
722 <!-- Add an Address --> | |
723 <xsl:template match="gmd:CI_Address"> | |
724 <xsl:if test="gmd:deliveryPoint/gco:CharacterString!='' or gmd:city/gco:CharacterString!='' or gmd:administrativeArea/gco:CharacterString!='' or gmd:postalCode/gco:CharacterString!='' or gmd:country/gco:CharacterString!=''"> | |
725 <address> | |
726 <xsl:if test="gmd:deliveryPoint/gco:CharacterString!=''"> | |
727 <deliveryPoint><xsl:value-of select="normalize-space(gmd:deliveryPoint/gco:CharacterString)"/></deliveryPoint> | |
728 </xsl:if> | |
729 <xsl:if test="gmd:city/gco:CharacterString!=''"> | |
730 <city><xsl:value-of select="normalize-space(gmd:city/gco:CharacterString)"/></city> | |
731 </xsl:if> | |
732 <xsl:if test="gmd:administrativeArea/gco:CharacterString!=''"> | |
733 <administrativeArea><xsl:value-of select="normalize-space(gmd:administrativeArea/gco:CharacterString)"/></administrativeArea> | |
734 </xsl:if> | |
735 <xsl:if test="gmd:postalCode/gco:CharacterString!=''"> | |
736 <postalCode><xsl:value-of select="normalize-space(gmd:postalCode/gco:CharacterString)"/></postalCode> | |
737 </xsl:if> | |
738 <xsl:if test="gmd:country/gco:CharacterString!=''"> | |
739 <country><xsl:value-of select="normalize-space(gmd:country/gco:CharacterString)"/></country> | |
740 </xsl:if> | |
741 </address> | |
742 </xsl:if> | |
743 </xsl:template> | |
744 | |
745 </xsl:stylesheet> |