Project

General

Profile

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="trust" select="string('0.9')"/>
12
	<xsl:param name="provenance" select="string('sysimport:crosswalk:datasetarchive')"/>
13
	<xsl:template match="/*">
14
		<xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
15
		<xsl:variable name="dateOfCollection" select="concat('', //dri:dateOfCollection)"/>
16
		<xsl:variable name="dateoftransformation" select="concat('', //dr:dateOfTransformation)"/>
17
		<xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)"/>
18
		<xsl:variable name="namespaceprefix">
19
			<xsl:choose>
20
				<!-- TODO check namespaceprefix length is 12 -->
21
				<xsl:when test="string-length(//oaf:datasourceprefix) &gt; 0">
22
					<xsl:value-of select="//oaf:datasourceprefix"/>
23
				</xsl:when>
24
				<xsl:otherwise>
25
					<xsl:value-of select="unknown_____"/>
26
				</xsl:otherwise>
27
			</xsl:choose>
28
		</xsl:variable>
29

    
30
		<xsl:choose>
31
			<xsl:when
32
					test="count($metadata) = 0 or normalize-space(//oaf:skipRecord)= 'true'">
33
				<ROWS/>
34
			</xsl:when>
35
			<xsl:otherwise>
36

    
37
				<xsl:variable name="resultId"
38
				              select="dnet:oafSimpleId('result', //dri:objIdentifier)"/>
39

    
40
				<xsl:if test="string-length($resultId) &gt; 0">
41
					<xsl:variable name="originalids"
42
					              select="//*[local-name() = 'resource']/*[local-name()='identifier'] | //*[local-name() = 'resource']//*[local-name()='alternateIdentifier']"/>
43
					<xsl:variable name="creators" select="//*[local-name() = 'creator']"/>
44
					<xsl:variable name="titles" select="//*[local-name() = 'title']"/>
45
					<xsl:variable name="subjects" select="//*[local-name() = 'subject']"/>
46
					<xsl:variable name="publisher" select="//*[local-name() = 'publisher']"/>
47
					<xsl:variable name="descriptions" select="//*[local-name() = 'description']"/>
48
					<xsl:variable name="dates" select="//*[local-name() = 'date']"/>
49
					<xsl:variable name="dateaccepted" select="//oaf:dateAccepted"/>
50
					<xsl:variable name="resourceType" select="//*[local-name() = 'resourceType']"/>
51
					<xsl:variable name="formats" select="//*[local-name() = 'format']"/>
52
					<xsl:variable name="sizes" select="//*[local-name() = 'size']"/>
53
					<xsl:variable name="rights" select="//oaf:accessrights"/>
54
					<xsl:variable name="version" select="//*[local-name() = 'version']"/>
55
					<xsl:variable name="language" select="//oaf:language"/>
56
					<xsl:variable name="cobjcategory" select="//dr:CobjCategory"/>
57
					<xsl:variable name="contributor" select="//*[local-name() = 'contributor']/*[local-name() = 'contributorName']"/>
58

    
59
					<xsl:variable name="instanceURI">
60
						<xsl:choose>
61
							<xsl:when
62
									test="string-length( //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='DOI']) &gt; 0">
63
								<xsl:value-of
64
										select="concat('http://dx.doi.org','/', //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='DOI']/text())"/>
65
							</xsl:when>
66
							<xsl:when test="string-length( //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='URL']) &gt; 0">
67
								<xsl:value-of select="concat('', //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='URL'])"/>
68
							</xsl:when>
69
							<xsl:otherwise>
70
								<xsl:value-of select="concat('', //*[local-name() = 'resource']//*[local-name()='alternateIdentifier' and ./@alternateIdentifierType='URL'])"/>
71
							</xsl:otherwise>
72
						</xsl:choose>
73
					</xsl:variable>
74

    
75
					<xsl:variable name="hostedbyid"
76
					              select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
77
					<xsl:variable name="hostedbyname" select="concat('', //oaf:hostedBy/@name)"/>
78
					<xsl:variable name="collectedfromid"
79
					              select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
80
					<xsl:variable name="collectedfromname"
81
					              select="concat('', //oaf:collectedFrom/@name)"/>
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, $about, $metadata, $titles, $subjects, $publisher, $descriptions,
88
                        $dates, $dateaccepted, $resourceType, $formats, $sizes, $language, $cobjcategory, $contributor, $rights,
89
                        $version, $pids, $provenance, $trust, $hostedbyid, $hostedbyname, $collectedfromid,
90
                        $collectedfromname, $originalids, $instanceURI, $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
						<xsl:for-each select="//*[local-name() = 'creator']">
99

    
100
							<xsl:variable name="personIdTemp">
101
								<xsl:choose>
102
									<xsl:when test="string-length(./*[local-name() = 'nameIdentifier']) &gt; 0">
103
										<xsl:value-of
104
												select="translate(normalize-space(./*[local-name() = 'nameIdentifier']),' .,','___')"/>
105
									</xsl:when>
106
									<xsl:otherwise>
107
										<xsl:value-of select="translate(normalize-space(./*[local-name() = 'creatorName']),' .,','___')"/>
108
									</xsl:otherwise>
109
								</xsl:choose>
110
							</xsl:variable>
111

    
112
							<xsl:variable name="personId" select="dnet:oafId('person', $namespaceprefix, normalize-space($personIdTemp))"/>
113

    
114
							<xsl:variable name="originalPersonId">
115
								<xsl:choose>
116
									<xsl:when test="./*[local-name() = 'nameIdentifier']">
117
										<xsl:value-of select="./*[local-name() = 'nameIdentifier'][0]"/>
118
									</xsl:when>
119
									<xsl:otherwise>
120
										<xsl:value-of select="''"/>
121
									</xsl:otherwise>
122
								</xsl:choose>
123
							</xsl:variable>
124

    
125
							<xsl:variable name="nameIdentifier">
126
								<xsl:choose>
127
									<xsl:when test="./*[local-name() = 'nameIdentifier']">
128
										<xsl:value-of select="./*[local-name() = 'nameIdentifier'][0]"/>
129
									</xsl:when>
130
									<xsl:otherwise>
131
										<xsl:value-of select="''"/>
132
									</xsl:otherwise>
133
								</xsl:choose>
134
							</xsl:variable>
135
							<xsl:variable name="nameIdentifierScheme">
136
								<xsl:choose>
137
									<xsl:when test="./*[local-name() = 'nameIdentifier']">
138
										<xsl:value-of select="./*[local-name() = 'nameIdentifier'][0]/@nameIdentifierScheme"/>
139
									</xsl:when>
140
									<xsl:otherwise>
141
										<xsl:value-of select="''"/>
142
									</xsl:otherwise>
143
								</xsl:choose>
144
							</xsl:variable>
145

    
146
							<xsl:if test="string-length($personId) &gt; 0">
147
								<xsl:variable name="position" select="position()"/>
148
								<xsl:variable name="person"
149
								              select="dnet:person($personId, $about, $provenance, $trust, $collectedfromid, $collectedfromname,
150
			                              $originalPersonId, $dateOfCollection, $dateoftransformation, normalize-space(./*[local-name() = 'creatorName']),
151
			                              $nameIdentifier, $nameIdentifierScheme)"/>
152
								<xsl:variable name="personresult"
153
								              select="dnet:personResult_Authorship($personId, $resultId, $position, 'isAuthorOf',
154
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
155
								<xsl:variable name="resultperson"
156
								              select="dnet:personResult_Authorship($resultId, $personId, $position, 'hasAuthor',
157
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
158

    
159
								<ROW key="{$personId}" columnFamily="person">
160
									<QUALIFIER name="body" type="base64">
161
										<xsl:value-of select="$person"/>
162
									</QUALIFIER>
163
								</ROW>
164
								<ROW key="{$personId}" columnFamily="personResult_authorship_isAuthorOf">
165
									<QUALIFIER name="{$resultId}" type="base64">
166
										<xsl:value-of select="$personresult"/>
167
									</QUALIFIER>
168
								</ROW>
169
								<ROW key="{$resultId}" columnFamily="personResult_authorship_hasAuthor">
170
									<QUALIFIER name="{$personId}" type="base64">
171
										<xsl:value-of select="$resultperson"/>
172
									</QUALIFIER>
173
								</ROW>
174
							</xsl:if>
175
						</xsl:for-each>
176

    
177
						<xsl:for-each select="//*[local-name()='projectid']">
178

    
179
							<xsl:variable name="projectId"
180
							              select="dnet:oafSplitId('project', normalize-space(.))"/>
181

    
182
							<xsl:variable name="resultproject"
183
							              select="dnet:rel($resultId, $projectId, 'resultProject', 'outcome', 'isProducedBy',
184
		                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
185
							<xsl:variable name="projectresult"
186
							              select="dnet:rel($projectId, $resultId, 'resultProject', 'outcome', 'produces',
187
		                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
188

    
189
							<xsl:if test="string-length($projectId) &gt; 0">
190
								<ROW key="{$resultId}" columnFamily="resultProject_outcome_isProducedBy">
191
									<QUALIFIER name="{$projectId}" type="base64">
192
										<xsl:value-of select="$resultproject"/>
193
									</QUALIFIER>
194
								</ROW>
195
								<ROW key="{$projectId}" columnFamily="resultProject_outcome_produces">
196
									<QUALIFIER name="{$resultId}" type="base64">
197
										<xsl:value-of select="$projectresult"/>
198
									</QUALIFIER>
199
								</ROW>
200
							</xsl:if>
201
						</xsl:for-each>
202

    
203
						<xsl:for-each
204
								select="//*[local-name()='relatedIdentifier' and ./@relatedIdentifierType='OPENAIRE' and ./@relationType='IsSupplementTo']">
205

    
206
							<!-- relatedDataset ids must be in the openaire format  -->
207
							<xsl:variable name="targetId" select="dnet:oafSimpleId('result', normalize-space(.))"/>
208

    
209
							<xsl:if test="string-length($targetId) &gt; 0">
210

    
211
								<xsl:variable name="resultDataset"
212
								              select="dnet:rel($resultId, $targetId, 'resultResult', 'supplement', 'isSupplementTo',
213
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
214
								<xsl:variable name="datasetResult"
215
								              select="dnet:rel($targetId, $resultId, 'resultResult', 'supplement', 'isSupplementedBy',
216
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
217

    
218
								<ROW key="{$resultId}" columnFamily="resultResult_supplement_isSupplementTo">
219
									<QUALIFIER name="{$targetId}" type="base64">
220
										<xsl:value-of select="$resultDataset"/>
221
									</QUALIFIER>
222
								</ROW>
223
								<ROW key="{$targetId}" columnFamily="resultResult_supplement_isSupplementedBy">
224
									<QUALIFIER name="{$resultId}" type="base64">
225
										<xsl:value-of select="$datasetResult"/>
226
									</QUALIFIER>
227
								</ROW>
228
							</xsl:if>
229
						</xsl:for-each>
230

    
231
						<xsl:for-each
232
								select="//*[local-name()='relatedIdentifier' and ./@relatedIdentifierType='OPENAIRE' and ./@relationType='IsPartOf']">
233

    
234
							<!-- relatedDataset ids must be in the openaire format  -->
235
							<xsl:variable name="datasetId" select="dnet:oafSimpleId('result', normalize-space(.))"/>
236

    
237
							<xsl:if test="string-length($datasetId) &gt; 0">
238

    
239
								<xsl:variable name="childParent"
240
								              select="dnet:rel($resultId, $datasetId, 'resultResult', 'part', 'isPartOf',
241
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
242
								<xsl:variable name="parentChild"
243
								              select="dnet:rel($datasetId, $resultId, 'resultResult', 'part', 'hasPart',
244
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
245

    
246
								<ROW key="{$resultId}" columnFamily="resultResult_part_isPartOf">
247
									<QUALIFIER name="{$datasetId}" type="base64">
248
										<xsl:value-of select="$childParent"/>
249
									</QUALIFIER>
250
								</ROW>
251
								<ROW key="{$datasetId}" columnFamily="resultResult_part_hasPart">
252
									<QUALIFIER name="{$resultId}" type="base64">
253
										<xsl:value-of select="$parentChild"/>
254
									</QUALIFIER>
255
								</ROW>
256
							</xsl:if>
257
						</xsl:for-each>
258

    
259
					</ROWS>
260
				</xsl:if>
261
			</xsl:otherwise>
262
		</xsl:choose>
263
	</xsl:template>
264
</xsl:stylesheet>
(1-1/4)