Project

General

Profile

1
<RESOURCE_PROFILE>
2
    <HEADER>
3
        <RESOURCE_IDENTIFIER
4
                value="102207dc-aaf5-41b7-a7c7-4fbc6bcb60b9_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
5
        <RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
6
        <RESOURCE_KIND value="TransformationRuleDSResources"/>
7
        <RESOURCE_URI value=""/>
8
        <DATE_OF_CREATION value="2015-02-27T17:15:30+00:00"/>
9
    </HEADER>
10
    <BODY>
11
        <CONFIGURATION>
12
            <SOURCE_METADATA_FORMAT name="dmf" layout="store" interpretation="cleaned"/>
13
            <SINK_METADATA_FORMAT name="dngf_hbase"/>
14
            <IMPORTED/>
15
            <SCRIPT>
16
                <TITLE>DLI2HBASE:dataset mapping to hbase</TITLE>
17
                <CODE>
18
                    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
19
                                    xmlns:dnet="eu.dnetlib.data.transform.xml.DmfToHbaseXsltFunctions"
20
                                    xmlns:dliut="eu.dnetlib.dli.DLIUtils"
21
                                    xmlns:exslt="http://exslt.org/common"
22
                                    xmlns:oaf="http://namespace.dnet.eu/oaf"
23
                                    xmlns:dc="http://purl.org/dc/elements/1.1/"
24
                                    xmlns:dri="http://www.driver-repository.eu/namespace/dri"
25
                                    xmlns:dr="http://www.driver-repository.eu/namespace/dr"
26
                                    version="1.0" extension-element-prefixes="exslt"
27
                                    exclude-result-prefixes="xsl oaf dr dri dnet exslt dliut">
28

    
29
                        <xsl:output omit-xml-declaration="yes" indent="yes"/>
30
                        <xsl:template match="/*">
31
                            <xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
32
                            <xsl:variable name="dateOfCollection" select="concat('', //dri:dateOfCollection)"/>
33
                            <xsl:variable name="dateoftransformation" select="concat('', //dr:dateOfTransformation)"/>
34

    
35
                            <xsl:variable name="trust" select="string('0.9')"/>
36
                            <xsl:variable name="provenance" select="string('sysimport:crosswalk:datasetarchive')"/>
37

    
38
                            <xsl:variable name="metadata"
39
                                          select="exslt:node-set(//*[local-name()='metadata']/*)"/>
40
                            <xsl:variable name="namespaceprefix">
41
                                <xsl:choose>
42
                                    <!-- TODO check namespaceprefix length is 12 -->
43
                                    <xsl:when test="string-length(//dri:datasourceprefix) &gt; 0">
44
                                        <xsl:choose>
45
                                            <xsl:when test="count(//dri:datasourceprefix) &gt; 1">
46
                                                <xsl:value-of select="//dri:datasourceprefix[1]"/>
47
                                            </xsl:when>
48
                                            <xsl:otherwise>
49
                                                <xsl:value-of select="//dri:datasourceprefix"/>
50
                                            </xsl:otherwise>
51

    
52
                                        </xsl:choose>
53
                                    </xsl:when>
54
                                    <xsl:otherwise>
55
                                        <xsl:value-of select="unknown_____"/>
56
                                    </xsl:otherwise>
57
                                </xsl:choose>
58
                            </xsl:variable>
59

    
60
                            <xsl:choose>
61
                                <xsl:when test="count($metadata) = 0 or normalize-space(//oaf:skipRecord)= 'true'">
62
                                    <ROWS/>
63
                                </xsl:when>
64
                                <xsl:otherwise>
65

    
66
                                    <xsl:variable name="datasetId"
67
                                                  select="dnet:oafSimpleId('dataset', //dri:objIdentifier)"/>
68

    
69
                                    <xsl:if test="string-length($datasetId) &gt; 0">
70
                                        <xsl:variable name="originalids"
71
                                                      select="//*[local-name() = 'resource']/*[local-name()='identifier'] | //*[local-name() = 'resource']//*[local-name()='alternateIdentifier']"/>
72
                                        <xsl:variable name="creators" select="//*[local-name() = 'creator']"/>
73
                                        <xsl:variable name="titles" select="//*[local-name() = 'title']"/>
74
                                        <xsl:variable name="subjects" select="//*[local-name() = 'subject']"/>
75
                                        <xsl:variable name="publisher" select="//*[local-name() = 'publisher']"/>
76
                                        <xsl:variable name="descriptions" select="//*[local-name() = 'description']"/>
77
                                        <xsl:variable name="dates" select="//*[local-name() = 'date']"/>
78
                                        <xsl:variable name="dateaccepted" select="//oaf:dateAccepted"/>
79
                                        <xsl:variable name="resourceType"
80
                                                      select="//*[local-name() = 'resourceType']/@resourceTypeGeneral"/>
81
                                        <xsl:variable name="formats" select="//*[local-name() = 'format']"/>
82
                                        <xsl:variable name="sizes" select="//*[local-name() = 'size']"/>
83
                                        <xsl:variable name="rights" select="//oaf:accessrights"/>
84
                                        <xsl:variable name="version" select="//*[local-name() = 'version']"/>
85
                                        <xsl:variable name="language" select="//oaf:language"/>
86
                                        <xsl:variable name="cobjcategory" select="//dr:CobjCategory"/>
87
                                        <xsl:variable name="contributor"
88
                                                      select="//*[local-name() = 'creator']/*[local-name() = 'creatorName']"/>
89
                                        <xsl:variable name="pid"
90
                                                      select="//*[local-name()='resource']/*[local-name()='identifier']/text()"/>
91
                                        <xsl:variable name="pidType"
92
                                                      select="//*[local-name()='resource']/*[local-name()='identifier']/@identifierType"/>
93
                                        <xsl:variable name="aboutNode" select="//oaf:about"/>
94
                                        <xsl:variable name="pids"
95
                                                      select="//*[local-name() = 'resource']//*[local-name()='identifier'or local-name()='alternateIdentifier']"/>
96

    
97
                                        <ROWS>
98
                                            <ROW>
99
                                                <xsl:attribute name="value">
100
                                                    <xsl:value-of select="dnet:dliDataset($datasetId, $about, $titles, $subjects, $publisher, $descriptions,
101
                                    $dates, $dateaccepted, $resourceType, $formats, $sizes, $language, $cobjcategory, $contributor, $rights,
102
                                    $pids, $provenance, $aboutNode, $originalids, $dateOfCollection, $dateoftransformation, $trust)"/>
103
                                                </xsl:attribute>
104
                                            </ROW>
105

    
106
                                            <!--PUBLICATION RELATIONS-->
107
                                            <xsl:for-each
108
                                                    select="//*[normalize-space(local-name())='relatedIdentifier' and normalize-space(./@entityType)='publication']">
109

    
110
                                                <xsl:variable name="relationSemantic" select="./@relationType"/>
111
                                                <xsl:variable name="inverseRelationSemantic"
112
                                                              select="./@inverseRelationType"/>
113

    
114
                                                <!-- relatedDataset ids must be in the openaire format  -->
115
                                                <xsl:variable name="publicationId">
116
                                                    <xsl:choose>
117
                                                        <xsl:when test="./@relatedIdentifierType = 'dnet'">
118
                                                            <xsl:value-of select="concat('50|' , . )"/>
119
                                                        </xsl:when>
120
                                                        <xsl:otherwise>
121
                                                            <xsl:value-of
122
                                                                    select="dnet:oafSimpleId('publication', normalize-space(.))"/>
123
                                                        </xsl:otherwise>
124
                                                    </xsl:choose>
125
                                                </xsl:variable>
126
                                                <xsl:if test="string-length($datasetId) &gt; 0">
127
                                                    <ROW>
128
                                                        <xsl:attribute name="value">
129
                                                            <xsl:value-of
130
                                                                    select="dnet:createRel($publicationId, $datasetId, $inverseRelationSemantic, 'publication_dataset', $provenance, $trust,  $about)"/>
131
                                                        </xsl:attribute>
132
                                                    </ROW>
133
                                                    <ROW>
134
                                                        <xsl:attribute name="value">
135
                                                            <xsl:value-of
136
                                                                    select="dnet:createRel($datasetId, $publicationId, $relationSemantic, 'publication_dataset', $provenance, $trust, $about)"/>
137
                                                        </xsl:attribute>
138
                                                    </ROW>
139
                                                    <ROW>
140
                                                        <xsl:attribute name="value">
141
                                                            <xsl:value-of
142
                                                                    select="dnet:createSimpleEntity(./@relatedIdentifierType, normalize-space(.), $namespaceprefix, $about, 'publication', 'incomplete')"/>
143
                                                        </xsl:attribute>
144
                                                    </ROW>
145
                                                </xsl:if>
146
                                            </xsl:for-each>
147

    
148
                                            <!--DATASET RELATIONS-->
149
                                            <xsl:for-each
150
                                                    select="//*[normalize-space(local-name())='relatedIdentifier' and normalize-space(./@entityType)='dataset']">
151
                                                <xsl:variable name="relationSemantic" select="./@relationType"/>
152
                                                <xsl:variable name="inverseRelationSemantic"
153
                                                              select="./@inverseRelationType"/>
154

    
155
                                                <!-- relatedDataset ids must be in the openaire format  -->
156
                                                <xsl:variable name="relDatasetId">
157
                                                    <xsl:choose>
158
                                                        <xsl:when test="./@relatedIdentifierType = 'dnet'">
159
                                                            <xsl:value-of select="concat('60|' , . )"/>
160
                                                        </xsl:when>
161
                                                        <xsl:otherwise>
162
                                                            <xsl:value-of
163
                                                                    select="dnet:oafSimpleId('dataset', normalize-space(.))"/>
164
                                                        </xsl:otherwise>
165
                                                    </xsl:choose>
166
                                                </xsl:variable>
167

    
168

    
169
                                                <xsl:if test="string-length($datasetId) &gt; 0">
170
                                                    <ROW>
171
                                                        <xsl:attribute name="value">
172
                                                            <xsl:value-of
173
                                                                    select="dnet:createRel($relDatasetId, $datasetId, $inverseRelationSemantic, 'dataset_dataset', $provenance, $trust,  $about)"/>
174
                                                        </xsl:attribute>
175
                                                    </ROW>
176
                                                    <ROW>
177
                                                        <xsl:attribute name="value">
178
                                                            <xsl:value-of
179
                                                                    select="dnet:createRel($datasetId, $relDatasetId, $relationSemantic, 'dataset_dataset', $provenance, $trust, $about)"/>
180
                                                        </xsl:attribute>
181
                                                    </ROW>
182
                                                    <ROW>
183
                                                        <xsl:attribute name="value">
184
                                                            <xsl:value-of
185
                                                                    select="dnet:createSimpleEntity(./@relatedIdentifierType, normalize-space(.), $namespaceprefix, $about, 'dataset', 'incomplete')"/>
186
                                                        </xsl:attribute>
187
                                                    </ROW>
188
                                                </xsl:if>
189
                                            </xsl:for-each>
190

    
191
                                            <!--UNKOWN RELATIONS-->
192
                                            <xsl:for-each
193
                                                    select="//*[normalize-space(local-name())='relatedIdentifier' and (normalize-space(./@entityType)='unknown' or not(./@entityType))]">
194

    
195
                                                <xsl:variable name="relationSemantic" select="./@relationType"/>
196
                                                <xsl:variable name="inverseRelationSemantic"
197
                                                              select="./@inverseRelationType"/>
198
                                                <xsl:variable name="enityId"
199
                                                              select="dnet:createDNetEntityIdentifier(./@relatedIdentifierType, ., $namespaceprefix, 'unknown')"/>
200

    
201
                                                <xsl:if test="string-length(dliut:fixPID(normalize-space(.))) &gt; 0 ">
202
                                                    <ROW>
203
                                                        <xsl:attribute name="value">
204
                                                            <xsl:value-of
205
                                                                    select="dnet:createEntity(./@relatedIdentifierType, ., $namespaceprefix, $about, 'incomplete')"/>
206
                                                        </xsl:attribute>
207
                                                    </ROW>
208
                                                    <ROW>
209
                                                        <xsl:attribute name="value">
210
                                                            <xsl:value-of
211
                                                                    select="dnet:createRel($datasetId, $enityId, $relationSemantic, 'dataset_unknown', $provenance, $trust, $about)"/>
212
                                                        </xsl:attribute>
213
                                                    </ROW>
214
                                                    <ROW>
215
                                                        <xsl:attribute name="value">
216
                                                            <xsl:value-of
217
                                                                    select="dnet:createRel($enityId, $datasetId, $inverseRelationSemantic, 'dataset_unknown', $provenance, $trust, $about)"/>
218
                                                        </xsl:attribute>
219
                                                    </ROW>
220
                                                </xsl:if>
221
                                            </xsl:for-each>
222
                                        </ROWS>
223
                                    </xsl:if>
224
                                </xsl:otherwise>
225
                            </xsl:choose>
226
                        </xsl:template>
227
                    </xsl:stylesheet>
228
                </CODE>
229
            </SCRIPT>
230
        </CONFIGURATION>
231
        <STATUS/>
232
        <SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
233
    </BODY>
234
</RESOURCE_PROFILE>
(1-1/3)