1
|
<RESOURCE_PROFILE>
|
2
|
<HEADER>
|
3
|
<RESOURCE_IDENTIFIER value="c460e550-01dc-414d-9eb3-7f5c02e2ab03_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU=" />
|
4
|
<RESOURCE_TYPE value="TransformationRuleDSResourceType" />
|
5
|
<RESOURCE_KIND value="TransformationRuleDSResources" />
|
6
|
<RESOURCE_URI value="" />
|
7
|
<DATE_OF_CREATION value="2015-02-27T17:15:30+00:00"/>
|
8
|
</HEADER>
|
9
|
<BODY>
|
10
|
<CONFIGURATION>
|
11
|
<SOURCE_METADATA_FORMAT name="oaf" layout="store" interpretation="cleaned" />
|
12
|
<SINK_METADATA_FORMAT name="oaf_hbase" />
|
13
|
<IMPORTED/>
|
14
|
<SCRIPT>
|
15
|
<TITLE>xslt_mapping_oaf2hbase_unpack_authors</TITLE>
|
16
|
<CODE>
|
17
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
18
|
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dr="http://www.driver-repository.eu/namespace/dr"
|
19
|
xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:oaa="http://namespace.openaire.eu/oaa"
|
20
|
xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:dnet="eu.dnetlib.data.transform.xml.DNetMdStoreToHbaseXsltFunctions"
|
21
|
xmlns:exslt="http://exslt.org/common"
|
22
|
version="1.0" extension-element-prefixes="exslt"
|
23
|
exclude-result-prefixes="xsl dc dr dri oaa oaf dnet exslt">
|
24
|
|
25
|
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
26
|
|
27
|
<xsl:param name="mergeIdForHomonyms" select="false()"/>
|
28
|
<xsl:param name="mergeIdForHomonymsMap"/>
|
29
|
|
30
|
<xsl:param name="writeCoAuthors" select="false()"/>
|
31
|
|
32
|
<xsl:template match="/*">
|
33
|
<xsl:variable name="dataInfo" select="/*[local-name() = 'record']/*[local-name() = 'about']/*[local-name() = 'datainfo']"/>
|
34
|
<xsl:variable name="dateofcollection" select="//dr:dateOfCollection"/>
|
35
|
|
36
|
<xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)"/>
|
37
|
<xsl:variable name="namespaceprefix">
|
38
|
<xsl:choose>
|
39
|
|
40
|
<!-- TODO check namespaceprefix length is 12 -->
|
41
|
<xsl:when test="string-length(//oaf:datasourceprefix) > 0">
|
42
|
<xsl:value-of select="//oaf:datasourceprefix"/>
|
43
|
</xsl:when>
|
44
|
<xsl:otherwise>
|
45
|
<xsl:value-of select="unknown_"/>
|
46
|
</xsl:otherwise>
|
47
|
</xsl:choose>
|
48
|
</xsl:variable>
|
49
|
|
50
|
<xsl:choose>
|
51
|
<!-- <xsl:when test="count($metadata) = 0 or string-length($namespaceprefix) = 0"> -->
|
52
|
<xsl:when test="count($metadata) = 0">
|
53
|
<ROWS/>
|
54
|
</xsl:when>
|
55
|
<xsl:otherwise>
|
56
|
|
57
|
<xsl:variable name="objIdentifier" select="//dri:objIdentifier"/>
|
58
|
<xsl:variable name="resultId" select="dnet:oafSimpleId('result', //dri:objIdentifier)"/>
|
59
|
|
60
|
<xsl:if test="string-length($resultId) > 0">
|
61
|
|
62
|
<xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
|
63
|
<xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name"/>
|
64
|
|
65
|
<xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
|
66
|
<xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name"/>
|
67
|
|
68
|
<xsl:variable name="originalidTest" select="/record/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']"/>
|
69
|
<xsl:variable name="originalid">
|
70
|
<xsl:choose>
|
71
|
<xsl:when test="contains($originalidTest, '::')">
|
72
|
<xsl:value-of select="substring-after($originalidTest, '::')"/>
|
73
|
</xsl:when>
|
74
|
<xsl:otherwise>
|
75
|
<xsl:value-of select="$originalidTest"/>
|
76
|
</xsl:otherwise>
|
77
|
</xsl:choose>
|
78
|
</xsl:variable>
|
79
|
|
80
|
<xsl:variable name="result"
|
81
|
select="dnet:oafResultFromMDStore($resultId, $dataInfo, $hostedbyid, $hostedbyname, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, $metadata)"/>
|
82
|
|
83
|
<ROWS>
|
84
|
<ROW key="{$resultId}" columnFamily="result">
|
85
|
<QUALIFIER name="body" type="base64">
|
86
|
<xsl:value-of select="$result"/>
|
87
|
</QUALIFIER>
|
88
|
</ROW>
|
89
|
|
90
|
<xsl:for-each select="//*[local-name()='projectid']">
|
91
|
|
92
|
<xsl:variable name="projectId" select="dnet:oafSplitId('project', normalize-space(.))"/>
|
93
|
|
94
|
<xsl:if test="string-length($projectId) > 0">
|
95
|
|
96
|
<xsl:variable name="resultproject"
|
97
|
select="dnet:oafResultProject_Outcome_FromMDStore($resultId, $projectId, 'isProducedBy', $dataInfo)"/>
|
98
|
<xsl:variable name="projectresult"
|
99
|
select="dnet:oafResultProject_Outcome_FromMDStore($projectId, $resultId, 'produces', $dataInfo)"/>
|
100
|
|
101
|
<ROW key="{$resultId}" columnFamily="resultProject_outcome_isProducedBy">
|
102
|
<QUALIFIER name="{$projectId}" type="base64">
|
103
|
<xsl:value-of select="$resultproject"/>
|
104
|
</QUALIFIER>
|
105
|
</ROW>
|
106
|
<ROW key="{$projectId}" columnFamily="resultProject_outcome_produces">
|
107
|
<QUALIFIER name="{$resultId}" type="base64">
|
108
|
<xsl:value-of select="$projectresult"/>
|
109
|
</QUALIFIER>
|
110
|
</ROW>
|
111
|
</xsl:if>
|
112
|
</xsl:for-each>
|
113
|
|
114
|
<xsl:for-each select="//*[local-name()='relatedDataset']">
|
115
|
|
116
|
<!-- relatedDataset ids must be in the openaire format -->
|
117
|
<xsl:variable name="datasetId" select="dnet:oafSimpleId('result', normalize-space(./@id))"/>
|
118
|
|
119
|
<xsl:if test="string-length($datasetId) > 0">
|
120
|
|
121
|
<xsl:variable name="resultDataset"
|
122
|
select="dnet:oafResultResult_PublicationDataset_FromMDStore($resultId, $datasetId, 'isRelatedTo', $dataInfo)"/>
|
123
|
<xsl:variable name="datasetResult"
|
124
|
select="dnet:oafResultResult_PublicationDataset_FromMDStore($datasetId, $resultId, 'isRelatedTo', $dataInfo)"/>
|
125
|
|
126
|
<ROW key="{$resultId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
|
127
|
<QUALIFIER name="{$datasetId}" type="base64">
|
128
|
<xsl:value-of select="$resultDataset"/>
|
129
|
</QUALIFIER>
|
130
|
</ROW>
|
131
|
<ROW key="{$datasetId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
|
132
|
<QUALIFIER name="{$resultId}" type="base64">
|
133
|
<xsl:value-of select="$datasetResult"/>
|
134
|
</QUALIFIER>
|
135
|
</ROW>
|
136
|
</xsl:if>
|
137
|
</xsl:for-each>
|
138
|
|
139
|
<xsl:for-each select="//*[local-name()='creator']">
|
140
|
|
141
|
<xsl:if test="string-length(normalize-space(.)) > 0">
|
142
|
|
143
|
<xsl:variable name="personIdPart">
|
144
|
<xsl:call-template name="personIdTmpl">
|
145
|
<xsl:with-param name="objIdentifier" select="$objIdentifier"/>
|
146
|
<xsl:with-param name="namespaceprefix" select="$namespaceprefix"/>
|
147
|
<xsl:with-param name="mergeIdForHomonymsMap" select="$mergeIdForHomonymsMap"/>
|
148
|
</xsl:call-template>
|
149
|
</xsl:variable>
|
150
|
<xsl:variable name="position" select="position()"/>
|
151
|
|
152
|
<xsl:variable name="personId"
|
153
|
select="dnet:oafId('person', $namespaceprefix, normalize-space($personIdPart))"/>
|
154
|
<xsl:variable name="person"
|
155
|
select="dnet:oafPersonFromMDStore($personId, $dataInfo, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, .)"/>
|
156
|
<xsl:variable name="personresult"
|
157
|
select="dnet:oafPersonResult_Authorship_FromMDStore($personId, $resultId, $position, 'isAuthorOf', $dataInfo)"/>
|
158
|
<xsl:variable name="resultperson"
|
159
|
select="dnet:oafPersonResult_Authorship_FromMDStore($resultId, $personId, $position, 'hasAuthor', $dataInfo)"/>
|
160
|
|
161
|
<xsl:if test="string-length($personId) > 0">
|
162
|
<ROW key="{$personId}" columnFamily="person">
|
163
|
<QUALIFIER name="body" type="base64">
|
164
|
<xsl:value-of select="$person"/>
|
165
|
</QUALIFIER>
|
166
|
</ROW>
|
167
|
<ROW key="{$personId}" columnFamily="personResult_authorship_isAuthorOf">
|
168
|
<QUALIFIER name="{$resultId}" type="base64">
|
169
|
<xsl:value-of select="$personresult"/>
|
170
|
</QUALIFIER>
|
171
|
</ROW>
|
172
|
<ROW key="{$resultId}" columnFamily="personResult_authorship_hasAuthor">
|
173
|
<QUALIFIER name="{$personId}" type="base64">
|
174
|
<xsl:value-of select="$resultperson"/>
|
175
|
</QUALIFIER>
|
176
|
</ROW>
|
177
|
<ROW key="{$personId}" columnFamily="result">
|
178
|
<QUALIFIER name="{$resultId}" type="base64">
|
179
|
<xsl:value-of select="$result"/>
|
180
|
</QUALIFIER>
|
181
|
</ROW>
|
182
|
</xsl:if>
|
183
|
|
184
|
<!-- COAUTHORS -->
|
185
|
<xsl:if test="$writeCoAuthors = true()">
|
186
|
<xsl:for-each select="../dc:creator">
|
187
|
<xsl:if test="$position != position()">
|
188
|
<xsl:variable name="coauthorIdPart">
|
189
|
<xsl:call-template name="personIdTmpl">
|
190
|
<xsl:with-param name="objIdentifier" select="$objIdentifier"/>
|
191
|
</xsl:call-template>
|
192
|
</xsl:variable>
|
193
|
<xsl:variable name="coauthorId"
|
194
|
select="dnet:oafId('person', $namespaceprefix, normalize-space($coauthorIdPart))"/>
|
195
|
<xsl:variable name="personperson"
|
196
|
select="dnet:oafPersonPerson_CoAuthorship_FromDMF($personId, $coauthorId, 'isCoAuthorOf', $dataInfo)"/>
|
197
|
<ROW key="{$personId}" columnFamily="personPerson_coAuthorship_isCoAuthorOf">
|
198
|
<QUALIFIER name="{$coauthorId}" type="base64">
|
199
|
<xsl:value-of select="$personperson"/>
|
200
|
</QUALIFIER>
|
201
|
</ROW>
|
202
|
</xsl:if>
|
203
|
</xsl:for-each>
|
204
|
</xsl:if>
|
205
|
<!-- / COAUTHORS -->
|
206
|
</xsl:if>
|
207
|
</xsl:for-each>
|
208
|
</ROWS>
|
209
|
</xsl:if>
|
210
|
</xsl:otherwise>
|
211
|
</xsl:choose>
|
212
|
</xsl:template>
|
213
|
|
214
|
<xsl:template name="personIdTmpl">
|
215
|
|
216
|
<xsl:param name="objIdentifier"/>
|
217
|
<xsl:param name="namespaceprefix"/>
|
218
|
<xsl:param name="mergeIdForHomonymsMap"/>
|
219
|
<xsl:variable name="mergeIdForHomonyms" select="dnet:lookupValue($mergeIdForHomonymsMap, $namespaceprefix)"/>
|
220
|
<xsl:choose>
|
221
|
<xsl:when test="$mergeIdForHomonyms = false()">
|
222
|
<xsl:value-of select="concat($objIdentifier, '::', normalize-space(.))"/>
|
223
|
</xsl:when>
|
224
|
<xsl:otherwise>
|
225
|
<xsl:value-of select="normalize-space(.)"/>
|
226
|
</xsl:otherwise>
|
227
|
</xsl:choose>
|
228
|
</xsl:template>
|
229
|
|
230
|
</xsl:stylesheet>
|
231
|
</CODE>
|
232
|
</SCRIPT>
|
233
|
</CONFIGURATION>
|
234
|
<STATUS />
|
235
|
<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
|
236
|
</BODY>
|
237
|
</RESOURCE_PROFILE>
|