1
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
2
|
xmlns:oaf="http://namespace.openaire.eu/oaf"
|
3
|
xmlns:dnet="eu.dnetlib.data.transform.xml.OdfToHbaseXsltFunctions"
|
4
|
xmlns:dri="http://www.driver-repository.eu/namespace/dri"
|
5
|
xmlns:dr="http://www.driver-repository.eu/namespace/dr" xmlns:exslt="http://exslt.org/common"
|
6
|
version="1.0" extension-element-prefixes="exslt"
|
7
|
exclude-result-prefixes="xsl oaf dr dri dnet exslt">
|
8
|
|
9
|
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
10
|
|
11
|
<xsl:param name="invisible" select="false()"/>
|
12
|
<xsl:param name="trust" select="string('0.9')"/>
|
13
|
<xsl:param name="provenance" select="string('sysimport:crosswalk:datasetarchive')"/>
|
14
|
<xsl:template match="/*">
|
15
|
<xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
|
16
|
<xsl:variable name="dateOfCollection" select="concat('', //dri:dateOfCollection)"/>
|
17
|
<xsl:variable name="dateoftransformation" select="concat('', //dr:dateOfTransformation)"/>
|
18
|
<xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)"/>
|
19
|
<xsl:variable name="namespaceprefix">
|
20
|
<xsl:choose>
|
21
|
<!-- TODO check namespaceprefix length is 12 -->
|
22
|
<xsl:when test="string-length(//oaf:datasourceprefix) > 0">
|
23
|
<xsl:value-of select="//oaf:datasourceprefix"/>
|
24
|
</xsl:when>
|
25
|
<xsl:otherwise>
|
26
|
<xsl:value-of select="unknown_____"/>
|
27
|
</xsl:otherwise>
|
28
|
</xsl:choose>
|
29
|
</xsl:variable>
|
30
|
|
31
|
<xsl:choose>
|
32
|
<xsl:when
|
33
|
test="count($metadata) = 0 or normalize-space(//oaf:skipRecord)= 'true'">
|
34
|
<ROWS/>
|
35
|
</xsl:when>
|
36
|
<xsl:otherwise>
|
37
|
|
38
|
<xsl:variable name="resultId"
|
39
|
select="dnet:oafSimpleId('result', //dri:objIdentifier)"/>
|
40
|
|
41
|
<xsl:if test="string-length($resultId) > 0">
|
42
|
<xsl:variable name="originalids"
|
43
|
select="//*[local-name() = 'resource']/*[local-name()='identifier'] | //*[local-name() = 'resource']//*[local-name()='alternateIdentifier']"/>
|
44
|
<xsl:variable name="creators" select="//*[local-name() = 'creators']/*[local-name() = 'creator']"/>
|
45
|
<xsl:variable name="titles" select="//*[local-name() = 'title']"/>
|
46
|
<xsl:variable name="subjects" select="//*[local-name() = 'subject']"/>
|
47
|
<xsl:variable name="publisher" select="//*[local-name() = 'publisher']"/>
|
48
|
<xsl:variable name="descriptions" select="//*[local-name() = 'description']"/>
|
49
|
<xsl:variable name="dates" select="//*[local-name() = 'date']"/>
|
50
|
<xsl:variable name="dateaccepted" select="//oaf:dateAccepted"/>
|
51
|
<xsl:variable name="resourceType" select="//*[local-name() = 'resourceType']"/>
|
52
|
<xsl:variable name="formats" select="//*[local-name() = 'format']"/>
|
53
|
<xsl:variable name="sizes" select="//*[local-name() = 'size']"/>
|
54
|
<xsl:variable name="rights" select="//oaf:accessrights"/>
|
55
|
<xsl:variable name="license" select="//oaf:license"/>
|
56
|
<xsl:variable name="version" select="//*[local-name() = 'version']"/>
|
57
|
<xsl:variable name="language" select="//oaf:language"/>
|
58
|
<xsl:variable name="cobjcategory" select="//dr:CobjCategory"/>
|
59
|
<xsl:variable name="contributor" select="//*[local-name() = 'contributor']"/>
|
60
|
<xsl:variable name="distributionlocation" select="//*[local-name() = 'alternateIdentifier' and @alternateIdentifierType='DistributionLocation']"/>
|
61
|
<xsl:variable name="documentationUrl" select="//*[local-name() = 'relatedIdentifier' and @relatedIdentifierType='URL' and @relationType='IsDocumentedBy']"/>
|
62
|
<xsl:variable name="landingPage" select="//*[local-name() = 'alternateIdentifier' and @alternateIdentifierType='LandingPage']/text()"/>
|
63
|
|
64
|
<xsl:variable name="instanceURI">
|
65
|
<xsl:choose>
|
66
|
<xsl:when
|
67
|
test="string-length( //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='DOI']) > 0">
|
68
|
<xsl:value-of
|
69
|
select="concat('http://dx.doi.org','/', //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='DOI']/text())"/>
|
70
|
</xsl:when>
|
71
|
<xsl:when test="string-length( //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='URL']) > 0">
|
72
|
<xsl:value-of select="concat('', //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='URL'])"/>
|
73
|
</xsl:when>
|
74
|
<xsl:otherwise>
|
75
|
<xsl:value-of select="concat('', //*[local-name() = 'resource']//*[local-name()='alternateIdentifier' and ./@alternateIdentifierType='URL'])"/>
|
76
|
</xsl:otherwise>
|
77
|
</xsl:choose>
|
78
|
</xsl:variable>
|
79
|
|
80
|
<xsl:variable name="hostedby" select="//oaf:hostedBy"/>
|
81
|
<xsl:variable name="collectedfrom" select="//oaf:collectedFrom"/>
|
82
|
|
83
|
<xsl:variable name="pids"
|
84
|
select="//*[local-name() = 'resource']//*[local-name()='identifier'or local-name()='alternateIdentifier']"/>
|
85
|
|
86
|
<xsl:variable name="result"
|
87
|
select="dnet:odfResult($resultId, $invisible, $about, $metadata, $titles, $creators, $subjects, $publisher, $descriptions,
|
88
|
$dates, $dateaccepted, $resourceType, $formats, $sizes, $language, $cobjcategory, $contributor, $rights, $license,
|
89
|
$version, $pids, $provenance, $trust, $hostedby, $collectedfrom, $originalids, $instanceURI, $landingPage, $distributionlocation,
|
90
|
$documentationUrl, $dateOfCollection, $dateoftransformation)"/>
|
91
|
|
92
|
<ROWS>
|
93
|
<ROW key="{$resultId}" columnFamily="result">
|
94
|
<QUALIFIER name="body" type="base64">
|
95
|
<xsl:value-of select="$result"/>
|
96
|
</QUALIFIER>
|
97
|
</ROW>
|
98
|
|
99
|
<xsl:for-each select="//*[local-name()='projectid']">
|
100
|
|
101
|
<xsl:variable name="projectId"
|
102
|
select="dnet:oafSplitId('project', normalize-space(.))"/>
|
103
|
|
104
|
<xsl:variable name="resultproject"
|
105
|
select="dnet:rel($resultId, $projectId, 'resultProject', 'outcome', 'isProducedBy',
|
106
|
$collectedfrom, $provenance, $trust, $about)"/>
|
107
|
<xsl:variable name="projectresult"
|
108
|
select="dnet:rel($projectId, $resultId, 'resultProject', 'outcome', 'produces',
|
109
|
$collectedfrom, $provenance, $trust, $about)"/>
|
110
|
|
111
|
<xsl:if test="string-length($projectId) > 0">
|
112
|
<ROW key="{$resultId}" columnFamily="resultProject_outcome_isProducedBy">
|
113
|
<QUALIFIER name="{$projectId}" type="base64">
|
114
|
<xsl:value-of select="$resultproject"/>
|
115
|
</QUALIFIER>
|
116
|
</ROW>
|
117
|
<ROW key="{$projectId}" columnFamily="resultProject_outcome_produces">
|
118
|
<QUALIFIER name="{$resultId}" type="base64">
|
119
|
<xsl:value-of select="$projectresult"/>
|
120
|
</QUALIFIER>
|
121
|
</ROW>
|
122
|
</xsl:if>
|
123
|
</xsl:for-each>
|
124
|
|
125
|
<xsl:for-each
|
126
|
select="//*[local-name()='relatedIdentifier' and ./@relatedIdentifierType='OPENAIRE' and ./@relationType='IsSupplementTo']">
|
127
|
|
128
|
<!-- relatedDataset ids must be in the openaire format -->
|
129
|
<xsl:variable name="targetId" select="dnet:oafSimpleId('result', normalize-space(.))"/>
|
130
|
|
131
|
<xsl:if test="string-length($targetId) > 0">
|
132
|
|
133
|
<xsl:variable name="resultDataset"
|
134
|
select="dnet:rel($resultId, $targetId, 'resultResult', 'supplement', 'isSupplementTo',
|
135
|
$collectedfrom, $provenance, $trust, $about)"/>
|
136
|
<xsl:variable name="datasetResult"
|
137
|
select="dnet:rel($targetId, $resultId, 'resultResult', 'supplement', 'isSupplementedBy',
|
138
|
$collectedfrom, $provenance, $trust, $about)"/>
|
139
|
|
140
|
<ROW key="{$resultId}" columnFamily="resultResult_supplement_isSupplementTo">
|
141
|
<QUALIFIER name="{$targetId}" type="base64">
|
142
|
<xsl:value-of select="$resultDataset"/>
|
143
|
</QUALIFIER>
|
144
|
</ROW>
|
145
|
<ROW key="{$targetId}" columnFamily="resultResult_supplement_isSupplementedBy">
|
146
|
<QUALIFIER name="{$resultId}" type="base64">
|
147
|
<xsl:value-of select="$datasetResult"/>
|
148
|
</QUALIFIER>
|
149
|
</ROW>
|
150
|
</xsl:if>
|
151
|
</xsl:for-each>
|
152
|
|
153
|
<xsl:for-each
|
154
|
select="//*[local-name()='relatedIdentifier' and ./@relatedIdentifierType='OPENAIRE' and ./@relationType='IsPartOf']">
|
155
|
|
156
|
<!-- relatedDataset ids must be in the openaire format -->
|
157
|
<xsl:variable name="datasetId" select="dnet:oafSimpleId('result', normalize-space(.))"/>
|
158
|
|
159
|
<xsl:if test="string-length($datasetId) > 0">
|
160
|
|
161
|
<xsl:variable name="childParent"
|
162
|
select="dnet:rel($resultId, $datasetId, 'resultResult', 'part', 'isPartOf',
|
163
|
$collectedfrom, $provenance, $trust, $about)"/>
|
164
|
<xsl:variable name="parentChild"
|
165
|
select="dnet:rel($datasetId, $resultId, 'resultResult', 'part', 'hasPart',
|
166
|
$collectedfrom, $provenance, $trust, $about)"/>
|
167
|
|
168
|
<ROW key="{$resultId}" columnFamily="resultResult_part_isPartOf">
|
169
|
<QUALIFIER name="{$datasetId}" type="base64">
|
170
|
<xsl:value-of select="$childParent"/>
|
171
|
</QUALIFIER>
|
172
|
</ROW>
|
173
|
<ROW key="{$datasetId}" columnFamily="resultResult_part_hasPart">
|
174
|
<QUALIFIER name="{$resultId}" type="base64">
|
175
|
<xsl:value-of select="$parentChild"/>
|
176
|
</QUALIFIER>
|
177
|
</ROW>
|
178
|
</xsl:if>
|
179
|
</xsl:for-each>
|
180
|
|
181
|
</ROWS>
|
182
|
</xsl:if>
|
183
|
</xsl:otherwise>
|
184
|
</xsl:choose>
|
185
|
</xsl:template>
|
186
|
</xsl:stylesheet>
|