Project

General

Profile

1
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
                xmlns:dnet="eu.dnetlib.dli.DLIUtils"
3
                xmlns:oai="http://www.openarchives.org/OAI/2.0/"
4
                xmlns:oaf="http://namespace.openaire.eu/oaf" version="2.0" exclude-result-prefixes="xsl dnet">
5
    <xsl:template match="/">
6
        <xsl:param name="check">
7
            <xsl:value-of select="count(//*[local-name()='relatedIdentifier' and normalize-space()])"/>
8
        </xsl:param>
9
        <xsl:choose>
10
            <xsl:when test="$check=0">
11
                <junk/>
12
            </xsl:when>
13
            <xsl:otherwise>
14
                <xsl:choose>
15
                    <xsl:when test="//*[local-name() = 'resourceType']/@bibtex = 'article'">
16
                        <xsl:call-template name="transformPublication"/>
17
                    </xsl:when>
18
                    <xsl:otherwise>
19
                        <xsl:call-template name="transformDataset"/>
20
                    </xsl:otherwise>
21
                </xsl:choose>
22
            </xsl:otherwise>
23
        </xsl:choose>
24
    </xsl:template>
25

    
26
    <xsl:template name="transformPublication">
27
        <oai:record xmlns:dri="http://www.driver-repository.eu/namespace/dri"
28
                    xmlns:oaf="http://namespace.openaire.eu/oaf"
29
                    xmlns:dc="http://purl.org/dc/elements/1.1/"
30
        >
31
            <oai:header>
32
                <dri:repositoryId>
33
                    <xsl:value-of select="//dri:repositoryId"/>
34
                </dri:repositoryId>
35
                <dri:recordIdentifier>
36
                    <xsl:value-of select="//dri:recordIdentifier"/>
37
                </dri:recordIdentifier>
38
                <dri:datasourceprefix>
39
                    <xsl:value-of select="//dri:datasourceprefix"/>
40
                </dri:datasourceprefix>
41
                <dri:objIdentifier>
42
                    <xsl:value-of select="//dri:objIdentifier"/>
43
                </dri:objIdentifier>
44
                <dri:dateOfCollection>
45
                    <xsl:value-of select="//dri:dateOfCollection"/>
46
                </dri:dateOfCollection>
47
                <oaf:datasourceprefix>
48
                    <xsl:value-of select="//oaf:datasourceprefix"/>
49
                </oaf:datasourceprefix>
50
                <identifier>
51
                    <xsl:value-of select="//oai:identifier"/>
52
                </identifier>
53
                <setSpec>
54
                    <xsl:value-of select="//oai:setSpec"/>
55
                </setSpec>
56
            </oai:header>
57
            <oai:metadata>
58
                <oaf:pid type="doi">
59
                    <xsl:value-of select="//*[local-name()='resource']/*[local-name()='identifier']"/>
60
                </oaf:pid>
61
                <dc:identifier>
62
                    <xsl:value-of select="//*[local-name()='resource']/*[local-name()='identifier']"/>
63
                </dc:identifier>
64
                <xsl:for-each select="//*[local-name()='title']">
65
                    <dc:title>
66
                        <xsl:value-of select="."/>
67
                    </dc:title>
68
                </xsl:for-each>
69

    
70
                <xsl:for-each select="//*[local-name()='creatorName']">
71
                    <dc:creator>
72
                        <xsl:value-of select="."/>
73
                    </dc:creator>
74
                </xsl:for-each>
75

    
76
                <xsl:for-each select="//*[local-name()='description']">
77
                    <dc:description>
78
                        <xsl:value-of select="."/>
79
                    </dc:description>
80
                </xsl:for-each>
81
                <dc:type>publication</dc:type>
82
                <xsl:for-each select="//*[local-name()='date']">
83
                    <dc:date>
84
                        <xsl:value-of select="."/>
85
                    </dc:date>
86
                </xsl:for-each>
87

    
88
                <xsl:for-each select="//*[local-name()='subject']">
89
                    <dc:subject><xsl:value-of select="." /> </dc:subject>
90
                </xsl:for-each>
91

    
92
                <xsl:for-each select="//*[local-name()='publisher']" >
93
                    <dc:publisher><xsl:value-of select="." /> </dc:publisher>
94

    
95
                </xsl:for-each>
96

    
97
                <xsl:for-each select="//*[local-name()='hostedBy']">
98
                    <oaf:hostedBy>
99
                        <xsl:attribute name="id" select="./@id"/>
100
                        <xsl:attribute name="name" select="./@name"/>
101
                    </oaf:hostedBy>
102
                </xsl:for-each>
103

    
104

    
105

    
106
                <xsl:for-each select="//*[local-name()='relatedIdentifier']">
107
                    <xsl:choose>
108
                        <xsl:when
109
                                test="string-length(normalize-space(./@relatedIdentifierType)) &gt; 0 and string-length(normalize-space(./@relationType)) &gt; 0 and string-length(normalize-space(.)) &gt; 0">
110
                            <oaf:relatedIdentifier>
111
                                <xsl:attribute name="relatedIdentifierType">
112
                                    <xsl:value-of select="dnet:geussPidType(./@relatedIdentifierType, .)"/>
113
                                </xsl:attribute>
114
                                <xsl:attribute name="relationType">
115
                                    <xsl:value-of select="dnet:normalizeRelation(./@relationType)"/>
116
                                </xsl:attribute>
117
                                <xsl:attribute name="inverseRelationType">
118
                                    <xsl:value-of select="dnet:getInverse(./@relationType)"/>
119
                                </xsl:attribute>
120
                                <xsl:value-of select="dnet:geussPidValue(.)"/>
121
                            </oaf:relatedIdentifier>
122
                        </xsl:when>
123
                    </xsl:choose>
124
                </xsl:for-each>
125
            </oai:metadata>
126
            <oaf:about>
127
                <oaf:datainfo>
128
                    <xsl:variable name="datasourcePrefix">
129
                        <xsl:value-of select="//dri:datasourceprefix/text()"/>
130
                    </xsl:variable>
131
                    <oaf:collectedFrom completionStatus="complete">
132
                        <xsl:attribute name="id">
133
                            <xsl:value-of select="dnet:getIdFromDataSourcePrefix($datasourcePrefix)"/>
134
                        </xsl:attribute>
135
                        <xsl:attribute name="name">
136
                            <xsl:value-of select="dnet:getNameFromDataSourcePrefix($datasourcePrefix)"/>
137
                        </xsl:attribute>
138
                    </oaf:collectedFrom>
139
                    <oaf:completionStatus>complete</oaf:completionStatus>
140
                    <oaf:provisionMode>collected</oaf:provisionMode>
141
                </oaf:datainfo>
142
            </oaf:about>
143
        </oai:record>
144
    </xsl:template>
145

    
146

    
147
    <xsl:template name="transformDataset">
148
        <oai:record xmlns:dri="http://www.driver-repository.eu/namespace/dri"
149
                    xmlns:oaf="http://namespace.openaire.eu/oaf"
150
                    xmlns:dc="http://purl.org/dc/elements/1.1/">
151
            <oai:header>
152
                <dri:repositoryId>
153
                    <xsl:value-of select="//dri:repositoryId"/>
154
                </dri:repositoryId>
155
                <dri:recordIdentifier>
156
                    <xsl:value-of select="//dri:recordIdentifier"/>
157
                </dri:recordIdentifier>
158
                <dri:datasourceprefix>
159
                    <xsl:value-of select="//dri:datasourceprefix"/>
160
                </dri:datasourceprefix>
161
                <dri:objIdentifier>
162
                    <xsl:value-of select="//dri:objIdentifier"/>
163
                </dri:objIdentifier>
164
                <dri:dateOfCollection>
165
                    <xsl:value-of select="//dri:dateOfCollection"/>
166
                </dri:dateOfCollection>
167
                <oaf:datasourceprefix>
168
                    <xsl:value-of select="//oaf:datasourceprefix"/>
169
                </oaf:datasourceprefix>
170
                <identifier>
171
                    <xsl:value-of select="//oai:identifier"/>
172
                </identifier>
173
                <setSpec>
174
                    <xsl:value-of select="//oai:setSpec"/>
175
                </setSpec>
176
            </oai:header>
177
            <oai:metadata>
178
                <resource xmlns="http://datacite.org/schema/kernel-3">
179
                    <identifier>
180
                        <xsl:attribute name="identifierType">
181
                            <xsl:value-of
182
                                    select="lower-case(//*[local-name()='resource']/*[local-name()='identifier'][0]/@identifierType)"/>
183
                        </xsl:attribute>
184
                        <xsl:value-of select="lower-case(//*[local-name()='resource']/*[local-name()='identifier'][0])"/>
185
                    </identifier>
186
                    <xsl:copy-of select="//*[local-name()='titles']"/>
187
                    <xsl:copy-of select="//*[local-name()='publisher']"/>
188
                    <xsl:copy-of select="//*[local-name()='publicationYear']"/>
189
                    <xsl:copy-of select="//*[local-name()='dates']"/>
190
                    <xsl:copy-of select="//*[local-name()='creators']"/>
191
                    <xsl:copy-of select="//*[local-name()='subjects']"/>
192
                    <xsl:copy-of select="//*[local-name()='descriptions']"/>
193

    
194

    
195
                    <xsl:copy-of select="//*[local-name()='hostedBy']"/>
196
                    <resourceType resourceTypeGeneral="Dataset"/>
197

    
198
                    <relatedIdentifiers>
199
                        <xsl:for-each select="//*[local-name()='relatedIdentifier']">
200
                            <xsl:choose>
201
                                <xsl:when
202
                                        test="string-length(normalize-space(./@relatedIdentifierType)) &gt; 0 and string-length(normalize-space(./@relationType)) &gt; 0 and string-length(normalize-space(.)) &gt; 0">
203
                                    <relatedIdentifier>
204
                                        <xsl:attribute name="relatedIdentifierType">
205
                                            <xsl:value-of select="dnet:geussPidType(./@relatedIdentifierType, .)"/>
206
                                        </xsl:attribute>
207
                                        <xsl:attribute name="relationType">
208
                                            <xsl:value-of select="dnet:normalizeRelation(./@relationType)"/>
209
                                        </xsl:attribute>
210
                                        <xsl:attribute name="inverseRelationType">
211
                                            <xsl:value-of select="dnet:getInverse(./@relationType)"/>
212
                                        </xsl:attribute>
213
                                        <xsl:value-of select="dnet:geussPidValue(.)"/>
214
                                    </relatedIdentifier>
215
                                </xsl:when>
216
                            </xsl:choose>
217
                        </xsl:for-each>
218
                    </relatedIdentifiers>
219
                </resource>
220
            </oai:metadata>
221
            <oaf:about>
222
                <oaf:datainfo>
223
                    <xsl:variable name="datasourcePrefix">
224
                        <xsl:value-of select="//dri:datasourceprefix/text()"/>
225
                    </xsl:variable>
226
                    <oaf:collectedFrom completionStatus="complete">
227
                        <xsl:attribute name="id">
228
                            <xsl:value-of select="dnet:getIdFromDataSourcePrefix($datasourcePrefix)"/>
229
                        </xsl:attribute>
230
                        <xsl:attribute name="name">
231
                            <xsl:value-of select="dnet:getNameFromDataSourcePrefix($datasourcePrefix)"/>
232
                        </xsl:attribute>
233
                    </oaf:collectedFrom>
234
                    <oaf:completionStatus>complete</oaf:completionStatus>
235
                    <oaf:provisionMode>collected</oaf:provisionMode>
236
                </oaf:datainfo>
237
            </oaf:about>
238
        </oai:record>
239
    </xsl:template>
240

    
241

    
242
</xsl:stylesheet>
(13-13/15)