1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
3
|
xmlns:dnet="eu.dnetlib.actionmanager.actions.infopackage.DataciteInfoPackageToHbaseXsltFunctions"
|
4
|
xmlns:oaf="http://namespace.openaire.eu/oaf"
|
5
|
xmlns:dri="http://www.driver-repository.eu/namespace/dri"
|
6
|
xmlns:dr="http://www.driver-repository.eu/namespace/dr"
|
7
|
xmlns:exslt="http://exslt.org/common" version="1.0"
|
8
|
extension-element-prefixes="exslt" exclude-result-prefixes="xsl dnet exslt oaf dr dri">
|
9
|
|
10
|
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
11
|
|
12
|
<xsl:param name="trust" select="string('0.9')"/>
|
13
|
<xsl:param name="provenance" select="string('UNKNOWN')"/>
|
14
|
<xsl:param name="namespaceprefix" select="string('datacite____')"/>
|
15
|
|
16
|
<xsl:template match="/*">
|
17
|
<xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
|
18
|
<xsl:variable name="metadata" select="exslt:node-set(/*[local-name()='record']/*[local-name()='metadata']/*[local-name()='resource'])"/>
|
19
|
<xsl:variable name="rightNSPrefix">
|
20
|
<xsl:choose>
|
21
|
<xsl:when test="not($namespaceprefix)">
|
22
|
<xsl:value-of select="//oaf:datasourceprefix"/>
|
23
|
</xsl:when>
|
24
|
<xsl:otherwise>
|
25
|
<xsl:value-of select="$namespaceprefix"/>
|
26
|
</xsl:otherwise>
|
27
|
</xsl:choose>
|
28
|
</xsl:variable>
|
29
|
|
30
|
<xsl:choose>
|
31
|
<xsl:when test="count($metadata) = 0">
|
32
|
<ACTIONS/>
|
33
|
</xsl:when>
|
34
|
<xsl:otherwise>
|
35
|
<xsl:variable name="originalId" select="/record/metadata/*[local-name() = 'identifier' and ./@identifierType='DOI']"/>
|
36
|
<xsl:variable name="resultId" select="dnet:oafSimpleId('result', //dri:objIdentifier)"/>
|
37
|
|
38
|
<xsl:variable name="creators" select="//*[local-name() = 'creator']"/>
|
39
|
<xsl:variable name="titles" select="//*[local-name() = 'title']"/>
|
40
|
<xsl:variable name="subjects" select="//*[local-name() = 'subject']"/>
|
41
|
<xsl:variable name="publisher" select="//*[local-name() = 'publisher']"/>
|
42
|
<xsl:variable name="descriptions" select="//*[local-name() = 'description']"/>
|
43
|
<xsl:variable name="dates" select="//*[local-name() = 'date']"/>
|
44
|
<xsl:variable name="dateaccepted" select="//oaf:dateAccepted"/>
|
45
|
<xsl:variable name="resourceType" select="//*[local-name() = 'resourceType']"/>
|
46
|
<xsl:variable name="formats" select="//*[local-name() = 'format']"/>
|
47
|
<xsl:variable name="sizes" select="//*[local-name() = 'size']"/>
|
48
|
<xsl:variable name="rights" select="//oaf:accessrights"/>
|
49
|
<xsl:variable name="version" select="//*[local-name() = 'version']"/>
|
50
|
<xsl:variable name="pids" select="//*[local-name() = 'resource']/*[local-name()='identifier']"/>
|
51
|
<xsl:variable name="instanceURI" select="concat('http://dx.doi.org', '/', //*[local-name() = 'resource']/*[local-name() = 'identifier'])"/>
|
52
|
<xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
|
53
|
<xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name"/>
|
54
|
<xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
|
55
|
<xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name"/>
|
56
|
<xsl:variable name="dateOfCollection" select="//dr:dateOfCollection"/>
|
57
|
<xsl:variable name="language" select="//oaf:language"/>
|
58
|
<xsl:variable name="cobjcategory" select="//dr:CobjCategory"/>
|
59
|
|
60
|
<ACTIONS>
|
61
|
<ACTION targetKey="{$resultId}" targetColumnFamily="result"
|
62
|
targetColumn="body">
|
63
|
<xsl:value-of
|
64
|
select="dnet:oafDataCiteResultFromInfoPackage($resultId, $about, $metadata, $titles,
|
65
|
$subjects, $publisher, $descriptions, $dates, $dateaccepted, $resourceType,
|
66
|
$formats, $sizes, $language, $cobjcategory, $rights, $version, $pids, $provenance, $trust, $hostedbyid, $hostedbyname,
|
67
|
$collectedfromid, $collectedfromname, $originalId, $instanceURI, $dateOfCollection)"
|
68
|
/>
|
69
|
</ACTION>
|
70
|
|
71
|
<xsl:for-each select="//*[local-name() = 'creator']">
|
72
|
<xsl:variable name="personIdTemp">
|
73
|
<xsl:choose>
|
74
|
<xsl:when test="string-length(./*[local-name() = 'nameIdentifier']) > 0">
|
75
|
<xsl:value-of
|
76
|
select="translate(normalize-space(./*[local-name() = 'nameIdentifier']),' .,','___')"
|
77
|
/>
|
78
|
</xsl:when>
|
79
|
<xsl:otherwise>
|
80
|
<xsl:value-of
|
81
|
select="translate(normalize-space(./*[local-name() = 'creatorName']),' .,','___')"
|
82
|
/>
|
83
|
</xsl:otherwise>
|
84
|
</xsl:choose>
|
85
|
|
86
|
</xsl:variable>
|
87
|
|
88
|
<xsl:variable name="personId"
|
89
|
select="dnet:oafId('person', $namespaceprefix, concat($originalId, '::', normalize-space($personIdTemp)))"/>
|
90
|
|
91
|
<xsl:variable name="originalPersonId" select="./*[local-name() = 'nameIdentifier']"/>
|
92
|
<xsl:if test="string-length($personId) > 0">
|
93
|
<ACTION targetKey="{$personId}" targetColumnFamily="person" targetColumn="body">
|
94
|
<xsl:value-of
|
95
|
select="dnet:oafDataCitePersonFromInfoPackage($personId, $about, normalize-space(./*[local-name() = 'creatorName']), $provenance, $trust, $collectedfromid, $collectedfromname,$originalPersonId, $dateOfCollection)"
|
96
|
/>
|
97
|
</ACTION>
|
98
|
<ACTION targetKey="{$personId}" targetColumnFamily="personResult_authorship_isAuthorOf"
|
99
|
targetColumn="{$resultId}">
|
100
|
<xsl:value-of
|
101
|
select="dnet:oafDataCitePersonResultFromInfoPackage($personId, $resultId, position(), 'isAuthorOf', $provenance, $trust, $about)"
|
102
|
/>
|
103
|
</ACTION>
|
104
|
<ACTION targetKey="{$resultId}" targetColumnFamily="personResult_authorship_hasAuthor"
|
105
|
targetColumn="{$personId}">
|
106
|
<xsl:value-of
|
107
|
select="dnet:oafDataCitePersonResultFromInfoPackage($resultId, $personId, position(), 'hasAuthor', $provenance, $trust, $about)"
|
108
|
/>
|
109
|
</ACTION>
|
110
|
</xsl:if>
|
111
|
</xsl:for-each>
|
112
|
<xsl:for-each select="//*[local-name()='relatedPublication']">
|
113
|
|
114
|
<!-- relatedDataset ids must be in the openaire format -->
|
115
|
<xsl:variable name="publicationId" select="dnet:oafSimpleId('result', normalize-space(./@id))"/>
|
116
|
|
117
|
<xsl:if test="string-length($publicationId) > 0">
|
118
|
|
119
|
<xsl:variable name="resultDataset"
|
120
|
select="dnet:oafDataCitePublicationDatasetFromInfoPackage($resultId, $publicationId, 'isRelatedTo', $provenance, $trust, $about)"/>
|
121
|
<xsl:variable name="datasetResult"
|
122
|
select="dnet:oafDataCitePublicationDatasetFromInfoPackage($publicationId, $resultId, 'isRelatedTo', $provenance, $trust, $about)"/>
|
123
|
|
124
|
<ACTION targetKey="{$resultId}" targetColumnFamily="resultResult_publicationDataset_isRelatedTo"
|
125
|
targetColumn="{$publicationId}">
|
126
|
<xsl:value-of select="$resultDataset"/>
|
127
|
</ACTION>
|
128
|
<ACTION targetKey="{$publicationId}" targetColumnFamily="resultResult_publicationDataset_isRelatedTo"
|
129
|
targetColumn="{$resultId}">
|
130
|
<xsl:value-of select="$datasetResult"/>
|
131
|
</ACTION>
|
132
|
</xsl:if>
|
133
|
</xsl:for-each>
|
134
|
</ACTIONS>
|
135
|
</xsl:otherwise>
|
136
|
</xsl:choose>
|
137
|
</xsl:template>
|
138
|
</xsl:stylesheet>
|