1
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
2
|
xmlns:dnet="eu.dnetlib.data.transform.xml.PmfToHbaseXsltFunctions"
|
3
|
xmlns:exslt="http://exslt.org/common"
|
4
|
xmlns:oaf="http://namespace.dnet.eu/oaf"
|
5
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
xmlns:dri="http://www.driver-repository.eu/namespace/dri"
|
7
|
xmlns:dr="http://www.driver-repository.eu/namespace/dr"
|
8
|
version="1.0" extension-element-prefixes="exslt"
|
9
|
exclude-result-prefixes="xsl oaf dr dri dnet exslt">
|
10
|
|
11
|
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
12
|
|
13
|
<xsl:param name="writeCoAuthors" select="false()"/>
|
14
|
|
15
|
<xsl:template match="/*">
|
16
|
<xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
|
17
|
<xsl:variable name="dateofcollection" select="//dr:dateOfCollection"/>
|
18
|
<xsl:variable name="dateoftransformation" select="//dr:dateOfTransformation"/>
|
19
|
|
20
|
<xsl:variable name="trust" select="string('0.9')"/>
|
21
|
<xsl:variable name="provenance" select="string('sysimport:crosswalk:repository')"/>
|
22
|
|
23
|
<xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)"/>
|
24
|
<xsl:variable name="namespaceprefix">
|
25
|
<xsl:choose>
|
26
|
|
27
|
<!-- TODO check namespaceprefix length is 12 -->
|
28
|
<xsl:when test="string-length(//oaf:datasourceprefix) > 0">
|
29
|
<xsl:value-of select="//oaf:datasourceprefix"/>
|
30
|
</xsl:when>
|
31
|
<xsl:when test="string-length(//dri:datasourceprefix) > 0">
|
32
|
<xsl:value-of select="//dri:datasourceprefix"/>
|
33
|
</xsl:when>
|
34
|
<xsl:otherwise>
|
35
|
<xsl:value-of select="unknown_"/>
|
36
|
</xsl:otherwise>
|
37
|
</xsl:choose>
|
38
|
</xsl:variable>
|
39
|
|
40
|
<xsl:choose>
|
41
|
<!-- <xsl:when test="count($metadata) = 0 or string-length($namespaceprefix) = 0"> -->
|
42
|
<xsl:when test="count($metadata) = 0">
|
43
|
<ROWS/>
|
44
|
</xsl:when>
|
45
|
<xsl:otherwise>
|
46
|
|
47
|
<xsl:variable name="objIdentifier" select="//dri:objIdentifier"/>
|
48
|
<xsl:variable name="publicationId"
|
49
|
select="dnet:oafSimpleId('publication', //dri:objIdentifier)"/>
|
50
|
|
51
|
<xsl:if test="string-length($publicationId) > 0">
|
52
|
<xsl:variable name="originalidTest"
|
53
|
select="/record/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']"/>
|
54
|
<xsl:variable name="originalid">
|
55
|
<xsl:choose>
|
56
|
<xsl:when test="contains($originalidTest, '::')">
|
57
|
<xsl:value-of select="substring-after($originalidTest, '::')"/>
|
58
|
</xsl:when>
|
59
|
<xsl:otherwise>
|
60
|
<xsl:value-of select="$originalidTest"/>
|
61
|
</xsl:otherwise>
|
62
|
</xsl:choose>
|
63
|
</xsl:variable>
|
64
|
|
65
|
<ROWS>
|
66
|
<ROM>
|
67
|
<xsl:attribute name="value">
|
68
|
<xsl:value-of
|
69
|
select="dnet:pmfPublication($publicationId, $provenance, $trust, $about, $originalid, $dateofcollection, $dateoftransformation, $metadata)"/>
|
70
|
</xsl:attribute>
|
71
|
</ROM>
|
72
|
|
73
|
|
74
|
<xsl:for-each
|
75
|
select="//*[local-name()='relatedIdentifier' and ./@entityType='dataset']">
|
76
|
|
77
|
<xsl:variable name="relationSemantic" select="./@relationType"/>
|
78
|
<xsl:variable name="inverseSemantic" select="./@inverseRelationType"/>
|
79
|
|
80
|
<!-- relatedDataset ids must be in the openaire format -->
|
81
|
<xsl:variable name="datasetId"
|
82
|
select="dnet:oafSimpleId('dataset', normalize-space(.))"/>
|
83
|
|
84
|
<xsl:if test="string-length($datasetId) > 0">
|
85
|
<ROW>
|
86
|
<xsl:attribute name="value">
|
87
|
<xsl:value-of
|
88
|
select="dnet:rel($publicationId, $datasetId, $relationSemantic, 'publication_dataset', $provenance, $trust, $about)"/>
|
89
|
</xsl:attribute>
|
90
|
</ROW>
|
91
|
<ROW>
|
92
|
<xsl:attribute name="value">
|
93
|
<xsl:value-of
|
94
|
select="dnet:rel($datasetId, $publicationId, $inverseSemantic, 'publication_dataset', $provenance, $trust, $about)"/>
|
95
|
</xsl:attribute>
|
96
|
</ROW>
|
97
|
</xsl:if>
|
98
|
</xsl:for-each>
|
99
|
|
100
|
<xsl:for-each
|
101
|
select="//*[local-name()='relatedIdentifier' and ./@entityType='publication']">
|
102
|
|
103
|
<xsl:variable name="relationSemantic" select="./@relationType"/>
|
104
|
<xsl:variable name="inverseSemantic" select="./@inverseRelationType"/>
|
105
|
|
106
|
<!-- relatedPublication ids must be in the openaire format -->
|
107
|
<xsl:variable name="targetPublication"
|
108
|
select="dnet:oafSimpleId('publication', normalize-space(.))"/>
|
109
|
|
110
|
<xsl:if test="string-length($targetPublication) > 0">
|
111
|
<ROW>
|
112
|
<xsl:attribute name="value">
|
113
|
<xsl:value-of
|
114
|
select="dnet:rel($publicationId, $targetPublication, $relationSemantic, 'publication_publication', $provenance, $trust, $about)"/>
|
115
|
</xsl:attribute>
|
116
|
</ROW>
|
117
|
<ROW key="{$targetPublication}" columnFamily="rel">
|
118
|
<xsl:attribute name="value">
|
119
|
<xsl:value-of
|
120
|
select="dnet:rel($targetPublication, $publicationId, $inverseSemantic, 'publication_publication', $provenance, $trust, $about)"/>
|
121
|
</xsl:attribute>
|
122
|
</ROW>
|
123
|
</xsl:if>
|
124
|
</xsl:for-each>
|
125
|
|
126
|
|
127
|
<!--UNKOWN RELATIONS-->
|
128
|
|
129
|
<xsl:for-each
|
130
|
select="//*[local-name()='relatedIdentifier' and ./@entityType='unknown']">
|
131
|
|
132
|
<xsl:variable name="entityId">
|
133
|
<xsl:value-of
|
134
|
select="dnet:createEntityId(./@relatedIdentifierType, ., $namespaceprefix)"/>
|
135
|
</xsl:variable>
|
136
|
|
137
|
<ROW>
|
138
|
<xsl:attribute name="value">
|
139
|
<xsl:value-of
|
140
|
select="dnet:createEntity(./@relatedIdentifierType, ., $namespaceprefix, $about)"/>
|
141
|
</xsl:attribute>
|
142
|
</ROW>
|
143
|
|
144
|
<xsl:variable name="relationSemantic" select="./@relationType"/>
|
145
|
<xsl:variable name="inverseSemantic" select="./@inverseRelationType"/>
|
146
|
|
147
|
<ROW>
|
148
|
<xsl:attribute name="value">
|
149
|
<xsl:value-of
|
150
|
select="dnet:rel($publicationId, $entityId, $relationSemantic, 'publication_unknown', $provenance, $trust, $about)"/>
|
151
|
</xsl:attribute>
|
152
|
</ROW>
|
153
|
<ROW>
|
154
|
<xsl:attribute name="value">
|
155
|
<xsl:value-of
|
156
|
select="dnet:rel($entityId, $publicationId, $inverseSemantic, 'publication_unknown', $provenance, $trust, $about)"/>
|
157
|
</xsl:attribute>
|
158
|
</ROW>
|
159
|
</xsl:for-each>
|
160
|
</ROWS>
|
161
|
</xsl:if>
|
162
|
</xsl:otherwise>
|
163
|
</xsl:choose>
|
164
|
</xsl:template>
|
165
|
</xsl:stylesheet>
|