1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
3
|
xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:dc="http://purl.org/dc/elements/1.1/"
|
4
|
xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:dr="http://www.driver-repository.eu/namespace/dr"
|
5
|
xmlns:dnet="eu.dnetlib.data.transform.xml.OafToHbaseXsltFunctions"
|
6
|
xmlns:exslt="http://exslt.org/common"
|
7
|
version="1.0" extension-element-prefixes="exslt"
|
8
|
exclude-result-prefixes="xsl oaf dr dri dnet exslt">
|
9
|
|
10
|
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
11
|
|
12
|
<xsl:param name="writeCoAuthors" select="false()"/>
|
13
|
|
14
|
<xsl:param name="trust" select="string('0.9')"/>
|
15
|
<xsl:param name="provenance" select="string('sysimport:crosswalk:repository')"/>
|
16
|
|
17
|
<xsl:template match="/*">
|
18
|
<xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
|
19
|
<xsl:variable name="dateofcollection" select="/*[local-name() = 'record']/*[local-name() = 'header']/*[local-name()='dateOfCollection' and text()][1]"/>
|
20
|
<xsl:variable name="dateoftransformation" select="/*[local-name() = 'record']/*[local-name() = 'header']/*[local-name()='dateOfTransformation' and text()][1]"/>
|
21
|
<xsl:variable name="metadata" select="exslt:node-set(/*[local-name() = 'record']/*[local-name()='metadata']/*)"/>
|
22
|
<xsl:variable name="namespaceprefix">
|
23
|
<xsl:choose>
|
24
|
|
25
|
<!-- TODO check namespaceprefix length is 12 -->
|
26
|
<xsl:when test="string-length(//oaf:datasourceprefix) > 0">
|
27
|
<xsl:value-of select="//oaf:datasourceprefix"/>
|
28
|
</xsl:when>
|
29
|
<xsl:otherwise>
|
30
|
<xsl:value-of select="unknown_"/>
|
31
|
</xsl:otherwise>
|
32
|
</xsl:choose>
|
33
|
</xsl:variable>
|
34
|
|
35
|
<xsl:choose>
|
36
|
<!-- <xsl:when test="count($metadata) = 0 or string-length($namespaceprefix) = 0"> -->
|
37
|
<xsl:when test="count($metadata) = 0">
|
38
|
<ROWS/>
|
39
|
</xsl:when>
|
40
|
<xsl:otherwise>
|
41
|
|
42
|
<xsl:variable name="objIdentifier" select="//dri:objIdentifier"/>
|
43
|
<xsl:variable name="resultId" select="dnet:oafSimpleId('result', //dri:objIdentifier)"/>
|
44
|
|
45
|
<xsl:if test="string-length($resultId) > 0">
|
46
|
|
47
|
<xsl:variable name="cobjcategory" select="//dr:CobjCategory"/>
|
48
|
<xsl:choose>
|
49
|
<!-- check if we need to exclude datasets from an OAF MDStore-->
|
50
|
<xsl:when test="$cobjcategory = '0021'">
|
51
|
<ROWS/>
|
52
|
</xsl:when>
|
53
|
<xsl:otherwise>
|
54
|
<xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
|
55
|
<xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name"/>
|
56
|
|
57
|
<xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
|
58
|
<xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name"/>
|
59
|
|
60
|
<xsl:variable name="originalidTest" select="/*[local-name()='record']/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']"/>
|
61
|
<xsl:variable name="originalid">
|
62
|
<xsl:choose>
|
63
|
<xsl:when test="contains($originalidTest, '::')">
|
64
|
<xsl:value-of select="substring-after($originalidTest, '::')"/>
|
65
|
</xsl:when>
|
66
|
<xsl:otherwise>
|
67
|
<xsl:value-of select="$originalidTest"/>
|
68
|
</xsl:otherwise>
|
69
|
</xsl:choose>
|
70
|
</xsl:variable>
|
71
|
|
72
|
<xsl:variable name="result"
|
73
|
select="dnet:oafResult($resultId, $provenance, $trust, $about, $hostedbyid, $hostedbyname, $collectedfromid,
|
74
|
$collectedfromname, $originalid, $dateofcollection, $dateoftransformation, $metadata)"/>
|
75
|
|
76
|
<ROWS>
|
77
|
<ROW key="{$resultId}" columnFamily="result">
|
78
|
<QUALIFIER name="body" type="base64">
|
79
|
<xsl:value-of select="$result"/>
|
80
|
</QUALIFIER>
|
81
|
</ROW>
|
82
|
|
83
|
<xsl:for-each select="//*[local-name()='projectid']">
|
84
|
|
85
|
<xsl:variable name="projectId" select="dnet:oafSplitId('project', normalize-space(.))"/>
|
86
|
|
87
|
<xsl:if test="string-length($projectId) > 0">
|
88
|
|
89
|
<xsl:variable name="resultproject"
|
90
|
select="dnet:rel($resultId, $projectId, 'resultProject', 'outcome', 'isProducedBy',
|
91
|
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
|
92
|
<xsl:variable name="projectresult"
|
93
|
select="dnet:rel($projectId, $resultId, 'resultProject', 'outcome', 'produces',
|
94
|
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
|
95
|
|
96
|
<ROW key="{$resultId}" columnFamily="resultProject_outcome_isProducedBy">
|
97
|
<QUALIFIER name="{$projectId}" type="base64">
|
98
|
<xsl:value-of select="$resultproject"/>
|
99
|
</QUALIFIER>
|
100
|
</ROW>
|
101
|
<ROW key="{$projectId}" columnFamily="resultProject_outcome_produces">
|
102
|
<QUALIFIER name="{$resultId}" type="base64">
|
103
|
<xsl:value-of select="$projectresult"/>
|
104
|
</QUALIFIER>
|
105
|
</ROW>
|
106
|
</xsl:if>
|
107
|
</xsl:for-each>
|
108
|
|
109
|
<xsl:for-each select="//*[local-name()='relatedDataset']">
|
110
|
|
111
|
<!-- relatedDataset ids must be in the openaire format -->
|
112
|
<xsl:variable name="datasetId" select="dnet:oafSimpleId('result', normalize-space(./@id))"/>
|
113
|
|
114
|
<xsl:if test="string-length($datasetId) > 0">
|
115
|
|
116
|
<xsl:variable name="resultDataset"
|
117
|
select="dnet:rel($resultId, $datasetId, 'resultResult', 'publicationDataset', 'isRelatedTo',
|
118
|
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
|
119
|
<xsl:variable name="datasetResult"
|
120
|
select="dnet:rel($datasetId, $resultId, 'resultResult', 'publicationDataset', 'isRelatedTo',
|
121
|
$collectedfromid, $collectedfromname, $provenance, $trust, $about)"/>
|
122
|
|
123
|
<ROW key="{$resultId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
|
124
|
<QUALIFIER name="{$datasetId}" type="base64">
|
125
|
<xsl:value-of select="$resultDataset"/>
|
126
|
</QUALIFIER>
|
127
|
</ROW>
|
128
|
<ROW key="{$datasetId}" columnFamily="resultResult_publicationDataset_isRelatedTo">
|
129
|
<QUALIFIER name="{$resultId}" type="base64">
|
130
|
<xsl:value-of select="$datasetResult"/>
|
131
|
</QUALIFIER>
|
132
|
</ROW>
|
133
|
</xsl:if>
|
134
|
</xsl:for-each>
|
135
|
</ROWS>
|
136
|
</xsl:otherwise>
|
137
|
</xsl:choose>
|
138
|
</xsl:if>
|
139
|
</xsl:otherwise>
|
140
|
</xsl:choose>
|
141
|
</xsl:template>
|
142
|
</xsl:stylesheet>
|