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