Project

General

Profile

1
<xsl:stylesheet xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:dc="http://purl.org/dc/elements/1.1/"
2
                xmlns:oaa="http://namespace.openaire.eu/oaa" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common"
3
                xmlns:dnet="eu.dnetlib.data.transform.xml.DNetMdStoreToHbaseXsltFunctions" xmlns:oaf="http://namespace.openaire.eu/oaf"
4
                xmlns:dr="http://www.driver-repository.eu/namespace/dr" exclude-result-prefixes="xsl dc dr dri oaa oaf dnet exslt"
5
                extension-element-prefixes="exslt" version="1.0">
6
    <xsl:output indent="yes" omit-xml-declaration="yes"/>
7
    <xsl:param name="mergeIdForHomonyms" select="true()"/>
8
    <xsl:param name="writeCoAuthors" select="false()"/>
9
    <xsl:template match="/*">
10
        <xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
11
        <xsl:variable name="dateofcollection" select="//dr:dateOfCollection"/>
12
        <xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)"/>
13
        <xsl:variable name="namespaceprefix">
14
            <xsl:choose>
15

    
16
                <!-- TODO check namespaceprefix length is 12 -->
17
                <xsl:when test="string-length(//oaf:datasourceprefix) &gt; 0">
18
                    <xsl:value-of select="//oaf:datasourceprefix"/>
19
                </xsl:when>
20
                <xsl:otherwise>
21
                    <xsl:value-of select="unknown_"/>
22
                </xsl:otherwise>
23
            </xsl:choose>
24
        </xsl:variable>
25
        <xsl:choose>
26
            <!-- 			<xsl:when test="count($metadata) = 0 or string-length($namespaceprefix) = 0"> -->
27
            <xsl:when test="count($metadata) = 0">
28
                <ROWS/>
29
            </xsl:when>
30
            <xsl:otherwise>
31
                <xsl:variable name="objIdentifier" select="//dri:objIdentifier"/>
32
                <xsl:variable name="resultId" select="dnet:oafSimpleId('result', //dri:objIdentifier)"/>
33
                <xsl:if test="string-length($resultId) &gt; 0">
34
                    <xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
35
                    <xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name"/>
36
                    <xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
37
                    <xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name"/>
38
                    <xsl:variable name="originalidTest" select="/record/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']"/>
39
                    <xsl:variable name="originalid">
40
                        <xsl:choose>
41
                            <xsl:when test="contains($originalidTest, '::')">
42
                                <xsl:value-of select="substring-after($originalidTest, '::')"/>
43
                            </xsl:when>
44
                            <xsl:otherwise>
45
                                <xsl:value-of select="$originalidTest"/>
46
                            </xsl:otherwise>
47
                        </xsl:choose>
48
                    </xsl:variable>
49
                    <xsl:variable name="result"
50
                                  select="dnet:oafResultFromMDStore($resultId, $about, $hostedbyid, $hostedbyname, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, $metadata)"/>
51
                    <ROWS>
52
                        <ROW columnFamily="result" key="{$resultId}">
53
                            <QUALIFIER name="body" type="base64">
54
                                <xsl:value-of select="$result"/>
55
                            </QUALIFIER>
56
                        </ROW>
57
                        <xsl:for-each select="//*[local-name()='projectid']">
58
                            <xsl:variable name="projectId" select="dnet:oafSplitId('project', normalize-space(.))"/>
59
                            <xsl:if test="string-length($projectId) &gt; 0">
60
                                <xsl:variable name="resultproject"
61
                                              select="dnet:oafResultProject_Outcome_FromMDStore($resultId, $projectId, 'isProducedBy', $about)"/>
62
                                <xsl:variable name="projectresult"
63
                                              select="dnet:oafResultProject_Outcome_FromMDStore($projectId, $resultId, 'produces', $about)"/>
64
                                <ROW columnFamily="resultProject_outcome_isProducedBy" key="{$resultId}">
65
                                    <QUALIFIER name="{$projectId}" type="base64">
66
                                        <xsl:value-of select="$resultproject"/>
67
                                    </QUALIFIER>
68
                                </ROW>
69
                                <ROW columnFamily="resultProject_outcome_produces" key="{$projectId}">
70
                                    <QUALIFIER name="{$resultId}" type="base64">
71
                                        <xsl:value-of select="$projectresult"/>
72
                                    </QUALIFIER>
73
                                </ROW>
74
                            </xsl:if>
75
                        </xsl:for-each>
76
                        <xsl:for-each select="//*[local-name()='relatedDataset']">
77

    
78
                            <!-- relatedDataset ids must be in the openaire format  -->
79
                            <xsl:variable name="datasetId" select="dnet:oafSimpleId('result', normalize-space(./@id))"/>
80
                            <xsl:if test="string-length($datasetId) &gt; 0">
81
                                <xsl:variable name="resultDataset"
82
                                              select="dnet:oafResultResult_PublicationDataset_FromMDStore($resultId, $datasetId, 'isRelatedTo', $about)"/>
83
                                <xsl:variable name="datasetResult"
84
                                              select="dnet:oafResultResult_PublicationDataset_FromMDStore($datasetId, $resultId, 'isRelatedTo', $about)"/>
85
                                <ROW columnFamily="resultResult_publicationDataset_isRelatedTo" key="{$resultId}">
86
                                    <QUALIFIER name="{$datasetId}" type="base64">
87
                                        <xsl:value-of select="$resultDataset"/>
88
                                    </QUALIFIER>
89
                                </ROW>
90
                                <ROW columnFamily="resultResult_publicationDataset_isRelatedTo" key="{$datasetId}">
91
                                    <QUALIFIER name="{$resultId}" type="base64">
92
                                        <xsl:value-of select="$datasetResult"/>
93
                                    </QUALIFIER>
94
                                </ROW>
95
                            </xsl:if>
96
                        </xsl:for-each>
97
                        <xsl:for-each select="//*[local-name()='creator']">
98
                            <xsl:if test="string-length(normalize-space(.)) &gt; 0">
99
                                <xsl:variable name="personIdPart">
100
                                    <xsl:call-template name="personIdTmpl">
101
                                        <xsl:with-param name="objIdentifier" select="$objIdentifier"/>
102
                                    </xsl:call-template>
103
                                </xsl:variable>
104
                                <xsl:variable name="position" select="position()"/>
105
                                <xsl:variable name="personId" select="dnet:oafId('person', $namespaceprefix, normalize-space($personIdPart))"/>
106
                                <xsl:variable name="person"
107
                                              select="dnet:oafPersonFromMDStore($personId, $about, $collectedfromid, $collectedfromname, $originalid, $dateofcollection, .)"/>
108
                                <xsl:variable name="personresult"
109
                                              select="dnet:oafPersonResult_Authorship_FromMDStore($personId, $resultId, $position, 'isAuthorOf', $about)"/>
110
                                <xsl:variable name="resultperson"
111
                                              select="dnet:oafPersonResult_Authorship_FromMDStore($resultId, $personId, $position, 'hasAuthor', $about)"/>
112
                                <xsl:if test="string-length($personId) &gt; 0">
113
                                    <ROW columnFamily="person" key="{$personId}">
114
                                        <QUALIFIER name="body" type="base64">
115
                                            <xsl:value-of select="$person"/>
116
                                        </QUALIFIER>
117
                                    </ROW>
118
                                    <ROW columnFamily="personResult_authorship_isAuthorOf" key="{$personId}">
119
                                        <QUALIFIER name="{$resultId}" type="base64">
120
                                            <xsl:value-of select="$personresult"/>
121
                                        </QUALIFIER>
122
                                    </ROW>
123
                                    <ROW columnFamily="personResult_authorship_hasAuthor" key="{$resultId}">
124
                                        <QUALIFIER name="{$personId}" type="base64">
125
                                            <xsl:value-of select="$resultperson"/>
126
                                        </QUALIFIER>
127
                                    </ROW>
128
                                    <ROW columnFamily="result" key="{$personId}">
129
                                        <QUALIFIER name="{$resultId}" type="base64">
130
                                            <xsl:value-of select="$result"/>
131
                                        </QUALIFIER>
132
                                    </ROW>
133
                                </xsl:if>
134

    
135
                                <!-- COAUTHORS -->
136
                                <xsl:if test="$writeCoAuthors = true()">
137
                                    <xsl:for-each select="../dc:creator">
138
                                        <xsl:if test="$position != position()">
139
                                            <xsl:variable name="coauthorIdPart">
140
                                                <xsl:call-template name="personIdTmpl">
141
                                                    <xsl:with-param name="objIdentifier" select="$objIdentifier"/>
142
                                                </xsl:call-template>
143
                                            </xsl:variable>
144
                                            <xsl:variable name="coauthorId" select="dnet:oafId('person', $namespaceprefix, normalize-space($coauthorIdPart))"/>
145
                                            <xsl:variable name="personperson"
146
                                                          select="dnet:oafPersonPerson_CoAuthorship_FromDMF($personId, $coauthorId, 'isCoAuthorOf', $about)"/>
147
                                            <ROW columnFamily="personPerson_coAuthorship_isCoAuthorOf" key="{$personId}">
148
                                                <QUALIFIER name="{$coauthorId}" type="base64">
149
                                                    <xsl:value-of select="$personperson"/>
150
                                                </QUALIFIER>
151
                                            </ROW>
152
                                        </xsl:if>
153
                                    </xsl:for-each>
154
                                </xsl:if>
155
                                <!-- / COAUTHORS -->
156
                            </xsl:if>
157
                        </xsl:for-each>
158
                    </ROWS>
159
                </xsl:if>
160
            </xsl:otherwise>
161
        </xsl:choose>
162
    </xsl:template>
163
    <xsl:template name="personIdTmpl">
164
        <xsl:param name="objIdentifier"/>
165
        <xsl:choose>
166
            <xsl:when test="$mergeIdForHomonyms = false()">
167
                <xsl:value-of select="concat($objIdentifier, '::', normalize-space(.))"/>
168
            </xsl:when>
169
            <xsl:otherwise>
170
                <xsl:value-of select="normalize-space(.)"/>
171
            </xsl:otherwise>
172
        </xsl:choose>
173
    </xsl:template>
174
</xsl:stylesheet>
(1-1/32)