Revision 60112
Added by Alessia Bardi over 3 years ago
xslt_cleaning_datarepo_datacite.xml | ||
---|---|---|
4 | 4 |
<RESOURCE_TYPE value="TransformationRuleDSResourceType"/> |
5 | 5 |
<RESOURCE_KIND value="TransformationRuleDSResources"/> |
6 | 6 |
<RESOURCE_URI value=""/> |
7 |
<DATE_OF_CREATION value="2020-11-19T11:35:27+00:00"/>
|
|
7 |
<DATE_OF_CREATION value="2020-09-19T18:24:53+00:00"/>
|
|
8 | 8 |
</HEADER> |
9 | 9 |
<BODY> |
10 | 10 |
<CONFIGURATION> |
... | ... | |
12 | 12 |
<SCRIPT> |
13 | 13 |
<TITLE>xslt_cleaning_datarepo_datacite</TITLE> |
14 | 14 |
<CODE> |
15 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:oai="http://www.openarchives.org/OAI/2.0/" xmlns:TransformationFunction="eu.dnetlib.data.collective.transformation.core.xsl.ext.TransformationFunctionProxy" xmlns:dr="http://www.driver-repository.eu/namespace/dr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="TransformationFunction" extension-element-prefixes="TransformationFunction" version="1.1"> |
|
15 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
16 |
xmlns:oaf="http://namespace.openaire.eu/oaf" |
|
17 |
xmlns:oai="http://www.openarchives.org/OAI/2.0/" |
|
18 |
xmlns:datacite="http://datacite.org/schema/kernel-3" |
|
19 |
xmlns:TransformationFunction="eu.dnetlib.data.collective.transformation.core.xsl.ext.TransformationFunctionProxy" |
|
20 |
xmlns:dr="http://www.driver-repository.eu/namespace/dr" |
|
21 |
exclude-result-prefixes="TransformationFunction" |
|
22 |
extension-element-prefixes="TransformationFunction" |
|
23 |
version="2.0"> |
|
16 | 24 |
<xsl:param name="varOfficialName"/> |
17 | 25 |
<xsl:param name="varDsType"/> |
18 | 26 |
<xsl:param name="varDataSourceId"/> |
... | ... | |
31 | 39 |
<xsl:param name="varNIH" select="'nih_________::'"/> |
32 | 40 |
<xsl:param name="varNSF" select="'nsf_________::'"/> |
33 | 41 |
<xsl:param name="varNWO" select="'nwo_________::'"/> |
34 |
<xsl:param name="varUKRI" select="'ukri________::'"/>
|
|
42 |
<xsl:param name="varRCUK" select="'rcuk________::'"/>
|
|
35 | 43 |
<xsl:param name="varSFI" select="'sfi_________::'"/> |
36 | 44 |
<xsl:param name="varSGOV" select="'sgov________::'"/><!-- SGOV to be added, awaiting DOI from Pilar, found project ids not in CSV list? --> |
37 | 45 |
<xsl:param name="varSNSF" select="'snsf________::'"/> |
... | ... | |
41 | 49 |
<xsl:param name="index" select="0"/> |
42 | 50 |
<xsl:param name="transDate" select="current-dateTime()"/> |
43 | 51 |
<xsl:variable name="tf" select="TransformationFunction:getInstance()"/> |
52 |
<xsl:variable name="datasourcePrefix" select="normalize-space(//oaf:datasourceprefix)"/> |
|
44 | 53 |
<xsl:template match="/"> |
45 |
<xsl:variable name="datasourcePrefix" select="normalize-space(//oaf:datasourceprefix)"/> |
|
46 | 54 |
<xsl:call-template name="validRecord"/> |
47 | 55 |
</xsl:template> |
48 | 56 |
<xsl:template name="terminate"> |
... | ... | |
176 | 184 |
</xsl:when> |
177 | 185 |
</xsl:choose> |
178 | 186 |
<oaf:dateAccepted> |
179 |
<xsl:value-of select="TransformationFunction:convertString($tf, normalize-space(//*[local-name()='publicationYear']), 'DateISO8601')"/> |
|
187 |
<xsl:variable name="theDate"> |
|
188 |
<xsl:choose> |
|
189 |
<xsl:when test="string-length(normalize-space(//*[local-name()='date'][@dateType='Issued'])) > 3"> |
|
190 |
<xsl:value-of select="//*[local-name()='date'][@dateType='Issued']"/> |
|
191 |
</xsl:when> |
|
192 |
<xsl:otherwise> |
|
193 |
<xsl:value-of select="//*[local-name()='publicationYear']"/> |
|
194 |
</xsl:otherwise> |
|
195 |
</xsl:choose> |
|
196 |
</xsl:variable> |
|
197 |
<xsl:value-of select="TransformationFunction:convertString($tf, normalize-space($theDate), 'DateISO8601')"/> |
|
180 | 198 |
</oaf:dateAccepted> |
181 | 199 |
<xsl:choose><!-- |
182 | 200 |
<xsl:if test="//*[local-name() = 'datasourceprefix'][.='r310e4cd113d'] and not(boolean(//*[local-name() = 'rights']/@rightsURI ) )]"> |
... | ... | |
227 | 245 |
</xsl:for-each> |
228 | 246 |
<oaf:language> |
229 | 247 |
<xsl:value-of select="TransformationFunction:convert($tf, //*[local-name()='language'], 'Languages')"/> |
230 |
</oaf:language><!-- |
|
248 |
</oaf:language> |
|
249 |
<!-- country DE for items from TextGrid --> |
|
250 |
<xsl:if test="$varDataSourceId = 're3data_____::r3d100011365'"> |
|
251 |
<oaf:country>DE</oaf:country> |
|
252 |
</xsl:if> |
|
253 |
<!-- |
|
231 | 254 |
<xsl:if test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics/embargoedAccess')]"> |
232 | 255 |
<oaf:embargoenddate> |
233 | 256 |
<xsl:value-of select="//*[local-name()='date']/@dateType='Available'"/> |
... | ... | |
281 | 304 |
</xsl:copy> |
282 | 305 |
</xsl:template> |
283 | 306 |
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers']"> |
284 |
<xsl:element name="alternateIdentifiers" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
307 |
<xsl:element name="alternateIdentifiers" namespace="http://datacite.org/schema/kernel-3">
|
|
285 | 308 |
<xsl:copy-of select="./*"/> |
286 | 309 |
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='Handle']"> |
287 |
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
310 |
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
|
|
288 | 311 |
<xsl:attribute name="alternateIdentifierType"> |
289 | 312 |
<xsl:value-of select="'URL'"/> |
290 | 313 |
</xsl:attribute> |
... | ... | |
292 | 315 |
</xsl:element> |
293 | 316 |
</xsl:if> |
294 | 317 |
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='URN']"> |
295 |
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
318 |
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
|
|
296 | 319 |
<xsl:attribute name="alternateIdentifierType"> |
297 | 320 |
<xsl:value-of select="'URL'"/> |
298 | 321 |
</xsl:attribute> |
... | ... | |
300 | 323 |
</xsl:element> |
301 | 324 |
</xsl:if> |
302 | 325 |
<xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='DOI']"> |
303 |
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
326 |
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
|
|
304 | 327 |
<xsl:attribute name="alternateIdentifierType"> |
305 | 328 |
<xsl:value-of select="'URL'"/> |
306 | 329 |
</xsl:attribute><!-- |
... | ... | |
314 | 337 |
</xsl:template> |
315 | 338 |
<xsl:template match="//*[local-name() = 'resource']/*[local-name()='identifier']"><!-- cut off DOI resolver prefix to just get the number part --> |
316 | 339 |
<xsl:if test=".[@identifierType='DOI'][contains(., '://dx.doi.org/')]"> |
317 |
<xsl:element name="identifier" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
340 |
<xsl:element name="identifier" namespace="http://datacite.org/schema/kernel-3">
|
|
318 | 341 |
<xsl:attribute name="identifierType"> |
319 | 342 |
<xsl:value-of select="'DOI'"/> |
320 | 343 |
</xsl:attribute> |
... | ... | |
325 | 348 |
<xsl:copy-of select="."/> |
326 | 349 |
--> |
327 | 350 |
<xsl:if test="not(//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers'])"> |
328 |
<xsl:element name="alternateIdentifiers" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
351 |
<xsl:element name="alternateIdentifiers" namespace="http://datacite.org/schema/kernel-3">
|
|
329 | 352 |
<xsl:if test=".[@identifierType='Handle']"> |
330 |
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
353 |
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
|
|
331 | 354 |
<xsl:attribute name="alternateIdentifierType"> |
332 | 355 |
<xsl:value-of select="'URL'"/> |
333 | 356 |
</xsl:attribute> |
... | ... | |
335 | 358 |
</xsl:element> |
336 | 359 |
</xsl:if> |
337 | 360 |
<xsl:if test=".[@identifierType='URN']"> |
338 |
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
361 |
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
|
|
339 | 362 |
<xsl:attribute name="alternateIdentifierType"> |
340 | 363 |
<xsl:value-of select="'URL'"/> |
341 | 364 |
</xsl:attribute> |
... | ... | |
343 | 366 |
</xsl:element> |
344 | 367 |
</xsl:if> |
345 | 368 |
<xsl:if test=".[@identifierType='DOI']"> |
346 |
<xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
|
|
369 |
<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-3">
|
|
347 | 370 |
<xsl:attribute name="alternateIdentifierType"> |
348 | 371 |
<xsl:value-of select="'URL'"/> |
349 | 372 |
</xsl:attribute> |
... | ... | |
390 | 413 |
</xsl:if><!-- FWF --> |
391 | 414 |
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100002428') or contains(./*[local-name()='funderName'], 'Fonds zur Förderung der Wissenschaftlichen Forschung') or contains(./*[local-name()='funderName'], 'Austrian Science Fund')"> |
392 | 415 |
<oaf:projectid> |
393 |
<xsl:value-of select="concat($varFCT, ./*[local-name()='awardNumber'])"/>
|
|
416 |
<xsl:value-of select="concat($varFWF, ./*[local-name() = 'awardNumber'])"/>
|
|
394 | 417 |
</oaf:projectid> |
395 | 418 |
</xsl:if><!-- MESTD --> |
396 | 419 |
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001871') or (contains(./*[local-name()='funderName'], 'Ministarstvo Prosvete, Nauke i Tehnolo') and contains(./*[local-name()='funderName'], 'kog Razvoja')) or contains(./*[local-name()='funderName'], 'MESTD')"> |
... | ... | |
422 | 445 |
<oaf:projectid> |
423 | 446 |
<xsl:value-of select="concat($varNWO, ./*[local-name()='awardNumber'])"/> |
424 | 447 |
</oaf:projectid> |
425 |
</xsl:if><!-- UKRI -->
|
|
426 |
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000690') or contains(./*[local-name()='funderName'], 'Research Councils UK') or contains(./*[local-name()='funderName'], 'RCUK') or substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/100014013') or contains(./*[local-name()='funderName'], 'UKRI'), contains(./*[local-name()='funderName'], 'UK Research and Innovation')">
|
|
448 |
</xsl:if><!-- RCUK -->
|
|
449 |
<xsl:if test="substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100000690') or contains(./*[local-name()='funderName'], 'Research Councils UK') or contains(./*[local-name()='funderName'], 'RCUK')"> |
|
427 | 450 |
<oaf:projectid> |
428 |
<xsl:value-of select="concat($varUKRI, ./*[local-name()='awardNumber'])"/>
|
|
451 |
<xsl:value-of select="concat($varRCUK, ./*[local-name()='awardNumber'])"/>
|
|
429 | 452 |
</oaf:projectid> |
430 | 453 |
</xsl:if><!-- SFI --> |
431 | 454 |
<xsl:if test="(substring-after(normalize-space(./*[local-name()='funderIdentifier']), 'doi.org/') = ('10.13039/501100001602') or contains(./*[local-name()='funderName'], 'Science Foundation Ireland')) and matches(./*[local-name()='awardNumber'], '.*([\dA-Za-z\.\-]+/)+[\dA-Za-z\.\-]+.*')"> |
... | ... | |
449 | 472 |
</oaf:projectid> |
450 | 473 |
</xsl:if> |
451 | 474 |
</xsl:for-each> |
452 |
</xsl:template><!-- |
|
453 |
<xsl:template match="//*[local-name()='language']"> |
|
454 |
<oaf:language> |
|
455 |
<xsl:value-of select="TransformationFunction:convert($tf, //*[local-name()='language'], 'Languages')" /> |
|
456 |
</oaf:language> |
|
457 |
</xsl:template> |
|
458 |
--> |
|
475 |
</xsl:template> |
|
476 |
<xsl:template match="//*[local-name() = 'resource']/*[local-name() = 'relatedIdentifier' and @relatedIdentifierType = 'Handle']"> |
|
477 |
<datacite:relatedIdentifier relatedIdentifierType="OPENAIRE" relationType="{./@relationType}"> |
|
478 |
<xsl:value-of select="concat($datasourcePrefix, '::', ./text())"/> |
|
479 |
</datacite:relatedIdentifier> |
|
480 |
</xsl:template> |
|
459 | 481 |
<xsl:template match="//*[local-name() = 'header']"> |
460 | 482 |
<xsl:copy> |
461 | 483 |
<xsl:apply-templates select="node()|@*"/> |
Also available in: Unified diff
RCUK: this rule goes to production.
More precision for dateAccepted.
Set DE country for TextGrid
Fix namespacePrefix for some generated elements: datacite prefix, not oai
Fixed FWF variable for project links
Attempt to handle the relatedIdentifiers