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="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) &gt; 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) &gt; 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() = 'creator']/*[local-name() = 'creatorName']"/>
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']/*[local-name() = 'contributorName']"/>
60

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

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

    
85
					<xsl:variable name="pids"
86
					              select="//*[local-name() = 'resource']//*[local-name()='identifier'or local-name()='alternateIdentifier']"/>
87

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

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

    
102
							<xsl:variable name="projectId"
103
							              select="dnet:oafSplitId('project', normalize-space(.))"/>
104

    
105
							<xsl:variable name="resultproject"
106
							              select="dnet:rel($resultId, $projectId, 'resultProject', 'outcome', 'isProducedBy',
107
		                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
108
							<xsl:variable name="projectresult"
109
							              select="dnet:rel($projectId, $resultId, 'resultProject', 'outcome', 'produces',
110
		                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
111

    
112
							<xsl:if test="string-length($projectId) &gt; 0">
113
								<ROW key="{$resultId}" columnFamily="resultProject_outcome_isProducedBy">
114
									<QUALIFIER name="{$projectId}" type="base64">
115
										<xsl:value-of select="$resultproject"/>
116
									</QUALIFIER>
117
								</ROW>
118
								<ROW key="{$projectId}" columnFamily="resultProject_outcome_produces">
119
									<QUALIFIER name="{$resultId}" type="base64">
120
										<xsl:value-of select="$projectresult"/>
121
									</QUALIFIER>
122
								</ROW>
123
							</xsl:if>
124
						</xsl:for-each>
125

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

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

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

    
134
								<xsl:variable name="resultDataset"
135
								              select="dnet:rel($resultId, $targetId, 'resultResult', 'supplement', 'isSupplementTo',
136
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
137
								<xsl:variable name="datasetResult"
138
								              select="dnet:rel($targetId, $resultId, 'resultResult', 'supplement', 'isSupplementedBy',
139
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
140

    
141
								<ROW key="{$resultId}" columnFamily="resultResult_supplement_isSupplementTo">
142
									<QUALIFIER name="{$targetId}" type="base64">
143
										<xsl:value-of select="$resultDataset"/>
144
									</QUALIFIER>
145
								</ROW>
146
								<ROW key="{$targetId}" columnFamily="resultResult_supplement_isSupplementedBy">
147
									<QUALIFIER name="{$resultId}" type="base64">
148
										<xsl:value-of select="$datasetResult"/>
149
									</QUALIFIER>
150
								</ROW>
151
							</xsl:if>
152
						</xsl:for-each>
153

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

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

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

    
162
								<xsl:variable name="childParent"
163
								              select="dnet:rel($resultId, $datasetId, 'resultResult', 'part', 'isPartOf',
164
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
165
								<xsl:variable name="parentChild"
166
								              select="dnet:rel($datasetId, $resultId, 'resultResult', 'part', 'hasPart',
167
			                              $collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
168

    
169
								<ROW key="{$resultId}" columnFamily="resultResult_part_isPartOf">
170
									<QUALIFIER name="{$datasetId}" type="base64">
171
										<xsl:value-of select="$childParent"/>
172
									</QUALIFIER>
173
								</ROW>
174
								<ROW key="{$datasetId}" columnFamily="resultResult_part_hasPart">
175
									<QUALIFIER name="{$resultId}" type="base64">
176
										<xsl:value-of select="$parentChild"/>
177
									</QUALIFIER>
178
								</ROW>
179
							</xsl:if>
180
						</xsl:for-each>
181

    
182
					</ROWS>
183
				</xsl:if>
184
			</xsl:otherwise>
185
		</xsl:choose>
186
	</xsl:template>
187
</xsl:stylesheet>
(1-1/4)