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() = 'creators']/*[local-name() = 'creator']"/>
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']"/>
60
                    <xsl:variable name="distributionlocation"
61
                                  select="//*[local-name() = 'alternateIdentifier' and @alternateIdentifierType='DistributionLocation']"/>
62
                    <xsl:variable name="documentationUrl"
63
                                  select="//*[local-name() = 'relatedIdentifier' and @relatedIdentifierType='URL' and @relationType='IsDocumentedBy']"/>
64
                    <xsl:variable name="landingPage"
65
                                  select="//*[local-name() = 'alternateIdentifier' and @alternateIdentifierType='LandingPage']/text()"/>
66

    
67
                    <xsl:variable name="instanceURI">
68
                        <xsl:choose>
69
                            <xsl:when
70
                                    test="string-length( //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='DOI']) &gt; 0">
71
                                <xsl:value-of
72
                                        select="concat('http://dx.doi.org','/', //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='DOI']/text())"/>
73
                            </xsl:when>
74
                            <xsl:when
75
                                    test="string-length( //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='URL']) &gt; 0">
76
                                <xsl:value-of
77
                                        select="concat('', //*[local-name() = 'resource']/*[local-name()='identifier' and ./@identifierType='URL'])"/>
78
                            </xsl:when>
79
                            <xsl:otherwise>
80
                                <xsl:value-of
81
                                        select="concat('', //*[local-name() = 'resource']//*[local-name()='alternateIdentifier' and ./@alternateIdentifierType='URL'])"/>
82
                            </xsl:otherwise>
83
                        </xsl:choose>
84
                    </xsl:variable>
85

    
86
                    <xsl:variable name="hostedby" select="//oaf:hostedBy"/>
87
                    <xsl:variable name="collectedfrom" select="//oaf:collectedFrom"/>
88

    
89
                    <xsl:variable name="pids"
90
                                  select="//*[local-name() = 'resource']//*[local-name()='identifier'or local-name()='alternateIdentifier']"/>
91

    
92
                    <xsl:variable name="result"
93
                                  select="dnet:odfResult($resultId, $invisible, $about, $metadata, $titles, $creators, $subjects, $publisher, $descriptions,
94
		                        $dates, $dateaccepted, $resourceType, $formats, $sizes, $language, $cobjcategory, $contributor, $rights, $license,
95
		                        $version, $pids, $provenance, $trust, $hostedby, $collectedfrom, $originalids, $instanceURI, $landingPage, $distributionlocation,
96
		                        $documentationUrl, $dateOfCollection, $dateoftransformation)"/>
97

    
98
                    <ROWS>
99
                        <ROW key="{$resultId}" columnFamily="result">
100
                            <QUALIFIER name="body" type="base64">
101
                                <xsl:value-of select="$result"/>
102
                            </QUALIFIER>
103
                        </ROW>
104

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

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

    
110
                            <xsl:variable name="resultproject"
111
                                          select="dnet:rel($resultId, $projectId, 'resultProject', 'outcome', 'isProducedBy',
112
		                              $collectedfrom, $provenance, $trust, $about)"/>
113
                            <xsl:variable name="projectresult"
114
                                          select="dnet:rel($projectId, $resultId, 'resultProject', 'outcome', 'produces',
115
		                              $collectedfrom, $provenance, $trust, $about)"/>
116

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

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

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

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

    
139
                                <xsl:variable name="resultDataset"
140
                                              select="dnet:rel($resultId, $targetId, 'resultResult', 'supplement', 'isSupplementTo',
141
			                              $collectedfrom, $provenance, $trust, $about)"/>
142
                                <xsl:variable name="datasetResult"
143
                                              select="dnet:rel($targetId, $resultId, 'resultResult', 'supplement', 'isSupplementedBy',
144
			                              $collectedfrom, $provenance, $trust, $about)"/>
145

    
146
                                <ROW key="{$resultId}" columnFamily="resultResult_supplement_isSupplementTo">
147
                                    <QUALIFIER name="{$targetId}" type="base64">
148
                                        <xsl:value-of select="$resultDataset"/>
149
                                    </QUALIFIER>
150
                                </ROW>
151
                                <ROW key="{$targetId}" columnFamily="resultResult_supplement_isSupplementedBy">
152
                                    <QUALIFIER name="{$resultId}" type="base64">
153
                                        <xsl:value-of select="$datasetResult"/>
154
                                    </QUALIFIER>
155
                                </ROW>
156
                            </xsl:if>
157
                        </xsl:for-each>
158

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

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

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

    
167
                                <xsl:variable name="childParent"
168
                                              select="dnet:rel($resultId, $datasetId, 'resultResult', 'part', 'isPartOf',
169
			                              $collectedfrom, $provenance, $trust, $about)"/>
170
                                <xsl:variable name="parentChild"
171
                                              select="dnet:rel($datasetId, $resultId, 'resultResult', 'part', 'hasPart',
172
			                              $collectedfrom, $provenance, $trust, $about)"/>
173

    
174
                                <ROW key="{$resultId}" columnFamily="resultResult_part_isPartOf">
175
                                    <QUALIFIER name="{$datasetId}" type="base64">
176
                                        <xsl:value-of select="$childParent"/>
177
                                    </QUALIFIER>
178
                                </ROW>
179
                                <ROW key="{$datasetId}" columnFamily="resultResult_part_hasPart">
180
                                    <QUALIFIER name="{$resultId}" type="base64">
181
                                        <xsl:value-of select="$parentChild"/>
182
                                    </QUALIFIER>
183
                                </ROW>
184
                            </xsl:if>
185
                        </xsl:for-each>
186

    
187
                    </ROWS>
188
                </xsl:if>
189
            </xsl:otherwise>
190
        </xsl:choose>
191
    </xsl:template>
192
</xsl:stylesheet>
(1-1/4)