Project

General

Profile

1
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
                xmlns:datetime="http://exslt.org/dates-and-times"
3
                xmlns:exslt="http://exslt.org/common" xmlns:oai="http://www.openarchives.org/OAI/2.0/"
4
                xmlns:dri="http://www.driver-repository.eu/namespace/dri"
5
                xmlns:dc="http://purl.org/dc/elements/1.1/"
6
                xmlns:dnet="eu.dnetlib.dli.DLIUtils"
7
                xmlns:oaf="http://namespace.dnet.eu/oaf"
8
                version="2.0"
9
                exclude-result-prefixes="xsl datetime exslt dnet">
10
    <xsl:template match="/">
11
        <xsl:variable name="namespacePrefix" select="//dri:datasourceprefix"/>
12
        <xsl:variable name="pid">
13
            <xsl:value-of
14
                    select="dnet:fixPID(//*[local-name()='source']/*[local-name()='identifier']/*[local-name()='identifier'])"/>
15
        </xsl:variable>
16
        <xsl:variable name="pidType">
17
            <xsl:value-of
18
                    select="dnet:inferPidType(//*[local-name()='source']/*[local-name()='identifier']/*[local-name()='identifier'],//*[local-name()='source']/*[local-name()='identifier']/*[local-name()='schema'])"/>
19
        </xsl:variable>
20

    
21

    
22
        <xsl:variable name="relatedPid">
23
            <xsl:value-of
24
                    select="dnet:fixPID(//*[local-name()='target']/*[local-name()='identifier']/*[local-name()='identifier'])"/>
25
        </xsl:variable>
26
        <xsl:variable name="relatedPidType">
27
            <xsl:value-of
28
                    select="dnet:inferPidType(//*[local-name()='target']/*[local-name()='identifier']/*[local-name()='identifier'],//*[local-name()='target']/*[local-name()='identifier']/*[local-name()='schema'])"/>
29
        </xsl:variable>
30

    
31
        <xsl:variable name="relation">
32
            <xsl:value-of select="//*[local-name()='relationship']/*[local-name()='name']"/>
33
        </xsl:variable>
34
        <xsl:variable name="inverseRelation">
35
            <xsl:value-of select="//*[local-name()='relationship']/*[local-name()='inverseRelationship']"/>
36
        </xsl:variable>
37

    
38
        <xsl:variable name="targetType">
39
            <xsl:choose>
40
                <xsl:when
41
                        test="//*[local-name()='target']/*[local-name()='objectType']/*[local-name()='type'] ='dataset' or //*[local-name()='target']/*[local-name()='objectType']/*[local-name()='type']= 'collection'">
42
                    dataset
43
                </xsl:when>
44
                <xsl:when
45
                        test="//*[local-name()='target']/*[local-name()='objectType']/*[local-name()='type'] = 'literature' or //*[local-name()='target']/*[local-name()='objectType']/*[local-name()='type'] = 'publication'">
46
                    publication
47
                </xsl:when>
48
                <xsl:otherwise>unknown</xsl:otherwise>
49
            </xsl:choose>
50
        </xsl:variable>
51

    
52
        <xsl:variable name="sourceType">
53
            <xsl:choose>
54
                <xsl:when
55
                        test="//*[local-name()='source']/*[local-name()='objectType']/*[local-name()='type'] ='dataset' or //*[local-name()='source']/*[local-name()='objectType']/*[local-name()='type']= 'collection'">
56
                    dataset
57
                </xsl:when>
58
                <xsl:when test="//source/objectType/type = 'literature' or //source/objectType/type = 'publication'">
59
                    publication
60
                </xsl:when>
61
                <xsl:otherwise>unknown</xsl:otherwise>
62
            </xsl:choose>
63
        </xsl:variable>
64
        <xsl:variable name="dnetSourceId">
65
            <xsl:value-of
66
                    select="concat($namespacePrefix, '::', dnet:generateIdentifier(concat($pid, '::', $relatedPid), concat($pidType, '::', $relatedPidType)))"/>
67
        </xsl:variable>
68
        <xsl:variable name="dnetTargetId">
69
            <xsl:value-of
70
                    select="concat($namespacePrefix, '::', dnet:generateIdentifier(concat($relatedPid, '::', $pid), concat($relatedPidType, '::', $pidType)))"/>
71
        </xsl:variable>
72
        <pack>
73
            <xsl:choose>
74
                <xsl:when
75
                        test=".//*[local-name()='source']/*[local-name()='objectType']/*[local-name()='type'] = 'dataset' or .//*[local-name()='source']/*[local-name()='objectType']/*[local-name()='type'] = 'collection'">
76
                    <oai:record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77
                                xmlns="http://namespace.openaire.eu/">
78
                        <oai:header>
79
                            <dri:objIdentifier>
80
                                <xsl:value-of select="$dnetSourceId"/>
81
                            </dri:objIdentifier>
82
                            <dri:recordIdentifier>
83
                                <xsl:value-of select="concat($pid, '::', $pidType)"/>
84
                            </dri:recordIdentifier>
85
                            <dri:dateOfCollection>
86
                                <xsl:value-of select="//dri:dateOfCollection"/>
87
                            </dri:dateOfCollection>
88
                            <dri:repositoryId>
89
                                <xsl:value-of select="//dri:repositoryId"/>
90
                            </dri:repositoryId>
91
                            <dri:datasourceprefix>
92
                                <xsl:value-of select="$namespacePrefix"/>
93
                            </dri:datasourceprefix>
94
                        </oai:header>
95
                        <metadata>
96
                            <resource xmlns="http://datacite.org/schema/kernel-3"
97
                                      xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
98
                                <identifier identifierType="{$pidType}">
99
                                    <xsl:value-of select="$pid"/>
100
                                </identifier>
101
                                <titles>
102
                                    <xsl:for-each
103
                                            select="//*[local-name()='source']/*[local-name()='title']">
104
                                        <title>
105
                                            <xsl:value-of select="."/>
106
                                        </title>
107
                                    </xsl:for-each>
108
                                </titles>
109
                                <publisher>
110
                                    <xsl:value-of select="//*[local-name()='publisher']/*[local-name()='name']"/>
111
                                </publisher>
112
                                <dates>
113
                                    <xsl:for-each select="//*[local-name()='source']/*[local-name()='publicationDate']">
114
                                        <date dateType="Collected">
115
                                            <xsl:value-of select="."/>
116
                                        </date>
117
                                    </xsl:for-each>
118
                                </dates>
119
                                <creators>
120
                                    <xsl:for-each select="//*[local-name()='source']//*[local-name()='creatorName']">
121
                                        <creator>
122
                                            <creatorName>
123
                                                <xsl:value-of select="."/>
124
                                            </creatorName>
125
                                        </creator>
126
                                    </xsl:for-each>
127
                                </creators>
128
                                <resourceType resourceTypeGeneral="Dataset">Dataset</resourceType>
129
                                <relatedIdentifiers>
130
                                    <relatedIdentifier xmlns:oaf="http://namespace.dnet.eu/oaf"
131
                                                       inverseRelationType="{$inverseRelation}"
132
                                                       relationType="{$relation}"
133
                                                       entityType="{$targetType}" relatedIdentifierType="dnet">
134
                                        <xsl:value-of select="$dnetTargetId"/>
135
                                    </relatedIdentifier>
136
                                </relatedIdentifiers>
137
                            </resource>
138
                        </metadata>
139
                        <oaf:about>
140
                            <oaf:datainfo>
141
                                <oaf:collectedFrom completionStatus="complete">
142
                                    <xsl:attribute name="id">
143
                                        <xsl:value-of select="dnet:getIdFromDataSourcePrefix($namespacePrefix)"/>
144
                                    </xsl:attribute>
145
                                    <xsl:attribute name="name">
146
                                        <xsl:value-of select="dnet:getNameFromDataSourcePrefix($namespacePrefix)"/>
147
                                    </xsl:attribute>
148
                                </oaf:collectedFrom>
149
                                <oaf:completionStatus>complete</oaf:completionStatus>
150
                                <oaf:provisionMode>collected</oaf:provisionMode>
151
                            </oaf:datainfo>
152
                        </oaf:about>
153
                    </oai:record>
154
                </xsl:when>
155
                <xsl:when
156
                        test=".//*[local-name()='source']/*[local-name()='objectType']/*[local-name()='type'] = 'literature' or .//*[local-name()='source']/*[local-name()='objectType']/*[local-name()='type'] = 'publication'">
157
                    <oai:record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
158
                                xmlns="http://namespace.openaire.eu/">
159
                        <oai:header>
160
                            <dri:objIdentifier>
161
                                <xsl:value-of select="$dnetSourceId"/>
162
                            </dri:objIdentifier>
163
                            <dri:recordIdentifier>
164
                                <xsl:value-of select="concat($pid, '::', $pidType)"/>
165
                            </dri:recordIdentifier>
166
                            <dri:dateOfCollection>
167
                                <xsl:value-of select="//dri:dateOfCollection"/>
168
                            </dri:dateOfCollection>
169
                            <dri:repositoryId>
170
                                <xsl:value-of select="//dri:repositoryId"/>
171
                            </dri:repositoryId>
172
                            <dri:datasourceprefix>
173
                                <xsl:value-of select="$namespacePrefix"/>
174
                            </dri:datasourceprefix>
175
                        </oai:header>
176
                        <metadata>
177
                            <oaf:pid type="{$pidType}">
178
                                <xsl:value-of select="$pid"/>
179
                            </oaf:pid>
180
                            <dc:identifier>
181
                                <xsl:value-of select="$pid"/>
182
                            </dc:identifier>
183
                            <dc:title>
184
                                <xsl:value-of select="//*[local-name()='source']/*[local-name()='title']"/>
185
                            </dc:title>
186
                            <xsl:for-each select="//*[local-name()='source']//*[local-name()='creatorName']">
187
                                <dc:creator>
188
                                    <xsl:value-of select="."/>
189
                                </dc:creator>
190
                            </xsl:for-each>
191
                            <dc:type>publication</dc:type>
192
                            <!--<oaf:relatedIdentifier inverseRelationType="{$inverseRelation}" relationType="{$relation}"-->
193
                            <!--entityType="{$targetType}" relatedIdentifierType="dnet">-->
194
                            <!--<xsl:value-of select="$dnetTargetId"/>-->
195
                            <!--</oaf:relatedIdentifier>-->
196
                        </metadata>
197
                        <oaf:about>
198
                            <oaf:datainfo>
199
                                <oaf:collectedFrom completionStatus="complete">
200
                                    <xsl:attribute name="id">
201
                                        <xsl:value-of select="dnet:getIdFromDataSourcePrefix($namespacePrefix)"/>
202
                                    </xsl:attribute>
203
                                    <xsl:attribute name="name">
204
                                        <xsl:value-of select="dnet:getNameFromDataSourcePrefix($namespacePrefix)"/>
205
                                    </xsl:attribute>
206
                                </oaf:collectedFrom>
207
                                <oaf:completionStatus>complete</oaf:completionStatus>
208
                                <oaf:provisionMode>collected</oaf:provisionMode>
209
                            </oaf:datainfo>
210
                        </oaf:about>
211
                    </oai:record>
212
                </xsl:when>
213
            </xsl:choose>
214
            <xsl:choose>
215
                <xsl:when
216
                        test="//*[local-name()='target']/*[local-name()='objectType']/*[local-name()='type'] = 'literature' or //*[local-name()='target']/*[local-name()='objectType']/*[local-name()='type'] = 'publication'">
217
                    <oai:record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
218
                                xmlns="http://namespace.openaire.eu/">
219
                        <oai:header>
220
                            <dri:objIdentifier>
221
                                <xsl:value-of select="$dnetTargetId"/>
222
                            </dri:objIdentifier>
223
                            <dri:recordIdentifier>
224
                                <xsl:value-of select="concat($relatedPid, '::', $relatedPidType)"/>
225
                            </dri:recordIdentifier>
226
                            <dri:dateOfCollection>
227
                                <xsl:value-of select="//dri:dateOfCollection"/>
228
                            </dri:dateOfCollection>
229
                            <dri:repositoryId>
230
                                <xsl:value-of select="//dri:repositoryId"/>
231
                            </dri:repositoryId>
232
                            <dri:datasourceprefix>
233
                                <xsl:value-of select="$namespacePrefix"/>
234
                            </dri:datasourceprefix>
235
                        </oai:header>
236
                        <metadata>
237
                            <oaf:pid type="{$relatedPidType}">
238
                                <xsl:value-of select="$relatedPid"/>
239
                            </oaf:pid>
240
                            <dc:identifier>
241
                                <xsl:value-of select="$relatedPid"/>
242
                            </dc:identifier>
243
                            <dc:title>
244
                                <xsl:value-of select="//*[local-name()='target']/*[local-name()='title']"/>
245
                            </dc:title>
246
                            <xsl:for-each select="//*[local-name()='target']//*[local-name()='creatorName']">
247
                                <dc:creator>
248
                                    <xsl:value-of select="."/>
249
                                </dc:creator>
250
                            </xsl:for-each>
251
                            <dc:type>publication</dc:type>
252
                            <!--<oaf:relatedIdentifier inverseRelationType="{$relation}" relationType="{$inverseRelation}"-->
253
                            <!--entityType="{$sourceType}" relatedIdentifierType="dnet">-->
254
                            <!--<xsl:value-of select="$dnetSourceId"/>-->
255
                            <!--</oaf:relatedIdentifier>-->
256
                        </metadata>
257
                        <oaf:about>
258
                            <oaf:datainfo>
259
                                <oaf:collectedFrom completionStatus="complete">
260
                                    <xsl:attribute name="id">
261
                                        <xsl:value-of select="dnet:getIdFromDataSourcePrefix($namespacePrefix)"/>
262
                                    </xsl:attribute>
263
                                    <xsl:attribute name="name">
264
                                        <xsl:value-of select="dnet:getNameFromDataSourcePrefix($namespacePrefix)"/>
265
                                    </xsl:attribute>
266
                                </oaf:collectedFrom>
267
                                <oaf:completionStatus>complete</oaf:completionStatus>
268
                                <oaf:provisionMode>collected</oaf:provisionMode>
269
                            </oaf:datainfo>
270
                        </oaf:about>
271
                    </oai:record>
272
                </xsl:when>
273
                <xsl:when
274
                        test=".//*[local-name()='target']/*[local-name()='objectType']/*[local-name()='type'] = 'dataset' or .//*[local-name()='target']/*[local-name()='objectType']/*[local-name()='type'] = 'collection'">
275
                    <oai:record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
276
                                xmlns="http://namespace.openaire.eu/">
277
                        <oai:header>
278
                            <dri:objIdentifier>
279
                                <xsl:value-of select="$dnetTargetId"/>
280
                            </dri:objIdentifier>
281
                            <dri:recordIdentifier>
282
                                <xsl:value-of select="concat($relatedPid, '::', $relatedPidType)"/>
283
                            </dri:recordIdentifier>
284
                            <dri:dateOfCollection>
285
                                <xsl:value-of select="//dri:dateOfCollection"/>
286
                            </dri:dateOfCollection>
287
                            <dri:repositoryId>
288
                                <xsl:value-of select="//dri:repositoryId"/>
289
                            </dri:repositoryId>
290
                            <dri:datasourceprefix>
291
                                <xsl:value-of select="$namespacePrefix"/>
292
                            </dri:datasourceprefix>
293
                        </oai:header>
294
                        <metadata>
295
                            <resource xmlns="http://datacite.org/schema/kernel-3"
296
                                      xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
297
                                <identifier identifierType="{$relatedPidType}">
298
                                    <xsl:value-of select="$relatedPid"/>
299
                                </identifier>
300
                                <titles>
301
                                    <xsl:for-each
302
                                            select="//*[local-name()='target']/*[local-name()='title']">
303
                                        <title>
304
                                            <xsl:value-of select="."/>
305
                                        </title>
306
                                    </xsl:for-each>
307
                                </titles>
308
                                <publisher>
309
                                    <xsl:value-of select="//*[local-name()='publisher']/*[local-name()='name']"/>
310
                                </publisher>
311
                                <dates>
312
                                    <xsl:for-each select="//*[local-name()='target']/*[local-name()='publicationDate']">
313
                                        <date dateType="Collected">
314
                                            <xsl:value-of select="."/>
315
                                        </date>
316
                                    </xsl:for-each>
317
                                </dates>
318
                                <creators>
319
                                    <xsl:for-each select="//*[local-name()='target']//*[local-name()='creatorName']">
320
                                        <creator>
321
                                            <creatorName>
322
                                                <xsl:value-of select="."/>
323
                                            </creatorName>
324
                                        </creator>
325
                                    </xsl:for-each>
326
                                </creators>
327
                                <resourceType resourceTypeGeneral="Dataset">Dataset</resourceType>
328
                                <relatedIdentifiers>
329
                                    <relatedIdentifier xmlns:oaf="http://namespace.dnet.eu/oaf"
330
                                                       inverseRelationType="{$relation}"
331
                                                       relationType="{$inverseRelation}"
332
                                                       entityType="{$sourceType}" relatedIdentifierType="dnet">
333
                                        <xsl:value-of select="$dnetSourceId"/>
334
                                    </relatedIdentifier>
335
                                </relatedIdentifiers>
336
                            </resource>
337
                        </metadata>
338
                        <oaf:about>
339
                            <oaf:datainfo>
340
                                <oaf:collectedFrom completionStatus="complete">
341
                                    <xsl:attribute name="id">
342
                                        <xsl:value-of select="dnet:getIdFromDataSourcePrefix($namespacePrefix)"/>
343
                                    </xsl:attribute>
344
                                    <xsl:attribute name="name">
345
                                        <xsl:value-of select="dnet:getNameFromDataSourcePrefix($namespacePrefix)"/>
346
                                    </xsl:attribute>
347
                                </oaf:collectedFrom>
348
                                <oaf:completionStatus>complete</oaf:completionStatus>
349
                                <oaf:provisionMode>collected</oaf:provisionMode>
350
                            </oaf:datainfo>
351
                        </oaf:about>
352
                    </oai:record>
353
                </xsl:when>
354
            </xsl:choose>
355
        </pack>
356
    </xsl:template>
357
</xsl:stylesheet>
(2-2/10)