Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
                xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dr="http://www.driver-repository.eu/namespace/dr"
4
                xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:oaa="http://namespace.openaire.eu/oaa"
5
                xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:dnet="eu.dnetlib.data.transform.xml.OafToHbaseXsltFunctions"
6
                xmlns:exslt="http://exslt.org/common"
7
                version="1.0"
8
                extension-element-prefixes="exslt"
9
                exclude-result-prefixes="xsl dc dr dri oaa oaf dnet exslt">
10

    
11
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
12

    
13
    <xsl:param name="trust" select="string('0.9')"/>
14
    <xsl:param name="provenance" select="string('UNKNOWN')"/>
15
    <xsl:param name="namespaceprefix" select="string('unknown_____')"/>
16

    
17
    <xsl:template match="/*">
18
        <xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
19
        <xsl:variable name="dateofcollection" select="//dr:dateOfCollection"/>
20
	    <xsl:variable name="dateoftransformation" select="//dr:dateOfTransformation"/>
21

    
22
        <xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)"/>
23
        <xsl:variable name="collectedDatasourceid">
24
            <xsl:choose>
25
                <xsl:when test="string-length(//oaf:collectedDatasourceid) &gt; 0">
26
                    <xsl:value-of select="//oaf:collectedDatasourceid"/>
27
                </xsl:when>
28
                <xsl:otherwise>
29
                    <xsl:value-of select="UNKNOWN"/>
30
                </xsl:otherwise>
31
            </xsl:choose>
32
        </xsl:variable>
33

    
34

    
35
        <xsl:choose>
36
            <xsl:when test="count($metadata) = 0">
37
                <ACTIONS/>
38
            </xsl:when>
39
            <xsl:otherwise>
40

    
41
                <xsl:variable name="objidentifier" select="/record/*[local-name() = 'header']/*[local-name() = 'objIdentifier']"/>
42

    
43
                <xsl:variable name="resultId" select="dnet:oafSimpleId('result', $objidentifier)"/>
44

    
45
                <xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
46
                <xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name"/>
47

    
48
                <xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
49
                <xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name"/>
50

    
51
	            <xsl:variable name="originalidTest" select="/record/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']"/>
52
	            <xsl:variable name="originalid">
53
		            <xsl:choose>
54
			            <xsl:when test="contains($originalidTest, '::')">
55
				            <xsl:value-of select="substring-after($originalidTest, '::')"/>
56
			            </xsl:when>
57
			            <xsl:otherwise>
58
				            <xsl:value-of select="$originalidTest"/>
59
			            </xsl:otherwise>
60
		            </xsl:choose>
61
	            </xsl:variable>
62

    
63
	            <xsl:variable name="result"
64
	                          select="dnet:oafResult($resultId, $provenance, $trust, $about, $hostedbyid, $hostedbyname,
65
	                          $collectedfromid, $collectedfromname, $originalid, $dateofcollection, $dateoftransformation, $metadata)"/>
66

    
67
	            <ACTIONS>
68
                    <ACTION targetKey="{$resultId}" targetColumnFamily="result" targetColumn="body">
69
                        <xsl:value-of select="$result"/>
70
                    </ACTION>
71

    
72
                    <!-- 					<xsl:variable name="instance" select="dnet:oafInstanceFromInfoPackage($resultId, $hostedbyid, $hostedbyname, $provenance, $trust, $metadata)" /> -->
73

    
74
                    <!-- 					<ACTION targetKey="{$resultId}" targetColumnFamily="instance" targetColumn="{$resultId}"> -->
75
                    <!-- 						<xsl:value-of select="$instance" /> -->
76
                    <!-- 					</ACTION> -->
77

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

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

    
82
	                    <xsl:if test="string-length($projectId) &gt; 0">
83

    
84
		                    <xsl:variable name="resultproject"
85
		                                  select="dnet:rel($resultId, $projectId, 'resultProject', 'outcome', 'isProducedBy', $provenance, $trust, $about)"/>
86
		                    <xsl:variable name="projectresult"
87
		                                  select="dnet:rel($projectId, $resultId, 'resultProject', 'outcome', 'produces', $provenance, $trust, $about)"/>
88

    
89
		                    <xsl:if test="string-length($projectId) &gt; 0">
90
			                    <ACTION targetKey="{$resultId}" targetColumnFamily="resultProject_outcome_isProducedBy" targetColumn="{$projectId}">
91
				                    <xsl:value-of select="$resultproject"/>
92
			                    </ACTION>
93
			                    <ACTION targetKey="{$projectId}" targetColumnFamily="resultProject_outcome_produces" targetColumn="{$resultId}">
94
				                    <xsl:value-of select="$projectresult"/>
95
			                    </ACTION>
96
		                    </xsl:if>
97

    
98
	                    </xsl:if>
99
                    </xsl:for-each>
100

    
101
                    <xsl:for-each select="//dc:creator">
102

    
103
                        <xsl:variable name="personId" select="dnet:oafId('person', $namespaceprefix, concat($objidentifier, '::', .))"/>
104

    
105
	                    <xsl:if test="string-length($personId) &gt; 0">
106

    
107
		                    <xsl:variable name="position" select="position()"/>
108
		                    <xsl:variable name="originalPersonId">
109
			                    <xsl:choose>
110
				                    <xsl:when test="string-length(@nameIdentifier) &gt; 0">
111
					                    <xsl:value-of select="normalize-space(@nameIdentifier)"/>
112
				                    </xsl:when>
113
				                    <xsl:otherwise>
114
					                    <xsl:value-of select="concat($originalid, '::', normalize-space(.))"/>
115
				                    </xsl:otherwise>
116
			                    </xsl:choose>
117
		                    </xsl:variable>
118

    
119
		                    <xsl:variable name="person"
120
		                                  select="dnet:person($personId, $about, $provenance, $trust, $collectedfromid, $collectedfromname,
121
								              $originalPersonId, $dateofcollection, $dateoftransformation, normalize-space(.), @nameIdentifier, @nameIdentifierScheme)"/>
122
		                    <xsl:variable name="personresult"
123
		                                  select="dnet:personResult_Authorship($personId, $resultId, $position, 'isAuthorOf', $provenance, $trust, $about)"/>
124
		                    <xsl:variable name="resultperson"
125
		                                  select="dnet:personResult_Authorship($resultId, $personId, $position, 'hasAuthor', $provenance, $trust, $about)"/>
126

    
127
		                    <ACTION targetKey="{$personId}" targetColumnFamily="person" targetColumn="body">
128
                                <xsl:value-of select="$person"/>
129
                            </ACTION>
130
                            <ACTION targetKey="{$personId}" targetColumnFamily="personResult_authorship_isAuthorOf" targetColumn="{$resultId}">
131
                                <xsl:value-of select="$personresult"/>
132
                            </ACTION>
133
                            <ACTION targetKey="{$resultId}" targetColumnFamily="personResult_authorship_hasAuthor" targetColumn="{$personId}">
134
                                <xsl:value-of select="$resultperson"/>
135
                            </ACTION>
136
                        </xsl:if>
137
                    </xsl:for-each>
138

    
139
                    <xsl:for-each select="//*[local-name()='relatedPublication']">
140

    
141
                        <!-- relatedDataset ids must be in the openaire format  -->
142
                        <xsl:variable name="publicationId" select="dnet:oafSimpleId('result', normalize-space(./@id))"/>
143

    
144
                        <xsl:if test="string-length($publicationId) &gt; 0">
145

    
146
	                        <xsl:variable name="resultDataset"
147
	                                      select="dnet:rel($resultId, $publicationId, 'resultResult', 'publicationDataset', 'isRelatedTo', $provenance, $trust, $about)"/>
148
	                        <xsl:variable name="datasetResult"
149
	                                      select="dnet:rel($publicationId, $resultId, 'resultResult', 'publicationDataset', 'isRelatedTo', $provenance, $trust, $about)"/>
150

    
151
	                        <ACTION targetKey="{$resultId}" targetColumnFamily="resultResult_publicationDataset_isRelatedTo" targetColumn="{$publicationId}">
152
                                <xsl:value-of select="$resultDataset"/>
153
                            </ACTION>
154
	                        <ACTION targetKey="{$publicationId}" targetColumnFamily="resultResult_publicationDataset_isRelatedTo" targetColumn="{$resultId}">
155
                                <xsl:value-of select="$datasetResult"/>
156
                            </ACTION>
157
                        </xsl:if>
158
                    </xsl:for-each>
159

    
160
                </ACTIONS>
161
            </xsl:otherwise>
162
        </xsl:choose>
163
    </xsl:template>
164

    
165
</xsl:stylesheet>
(3-3/5)