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="titles" select="//*[local-name() = 'title']"/>
44
					<xsl:variable name="subjects" select="//*[local-name() = 'subject']"/>
45
					<xsl:variable name="publisher" select="//*[local-name() = 'publisher']"/>
46
					<xsl:variable name="descriptions" select="//*[local-name() = 'description']"/>
47
					<xsl:variable name="dates" select="//*[local-name() = 'date']"/>
48
					<xsl:variable name="dateaccepted" select="//oaf:dateAccepted"/>
49
					<xsl:variable name="resourceType" select="//*[local-name() = 'resourceType']"/>
50
					<xsl:variable name="formats" select="//*[local-name() = 'format']"/>
51
					<xsl:variable name="sizes" select="//*[local-name() = 'size']"/>
52
					<xsl:variable name="rights" select="//oaf:accessrights"/>
53
					<xsl:variable name="version" select="//*[local-name() = 'version']"/>
54
					<xsl:variable name="language" select="//oaf:language"/>
55
					<xsl:variable name="cobjcategory" select="//dr:CobjCategory"/>
56
					<xsl:variable name="contributor" select="//*[local-name() = 'contributor']/*[local-name() = 'contributorName']"/>
57

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

    
74
					<xsl:variable name="hostedbyid"
75
					              select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
76
					<xsl:variable name="hostedbyname" select="concat('', //oaf:hostedBy/@name)"/>
77
					<xsl:variable name="collectedfromid"
78
					              select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
79
					<xsl:variable name="collectedfromname"
80
					              select="concat('', //oaf:collectedFrom/@name)"/>
81

    
82
					<xsl:variable name="pids"
83
					              select="//*[local-name() = 'resource']//*[local-name()='identifier'or local-name()='alternateIdentifier']"/>
84

    
85
					<xsl:variable name="result"
86
					              select="dnet:odfResult($resultId, $about, $metadata, $titles, $subjects, $publisher, $descriptions,
87
                        $dates, $dateaccepted, $resourceType, $formats, $sizes, $language, $cobjcategory, $contributor, $rights,
88
                        $version, $pids, $provenance, $trust, $hostedbyid, $hostedbyname, $collectedfromid,
89
                        $collectedfromname, $originalids, $instanceURI, $dateOfCollection, $dateoftransformation)"/>
90

    
91
					<ROWS>
92
						<ROW key="{$resultId}" columnFamily="result">
93
							<QUALIFIER name="body" type="base64">
94
								<xsl:value-of select="$result"/>
95
							</QUALIFIER>
96
						</ROW>
97
						<xsl:for-each select="//*[local-name() = 'creator']">
98

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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