Project

General

Profile

1
<RESOURCE_PROFILE>
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER
4
				value="oaiAndsTransform_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
5
		<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
6
		<RESOURCE_KIND value="TransformationRuleDSResources"/>
7
		<RESOURCE_URI value=""/>
8
		<DATE_OF_CREATION value="2014-11-19T11:05:55+01:00"/>
9
	</HEADER>
10
	<BODY>
11
		<CONFIGURATION>
12
			<IMPORTED/>
13
			<SCRIPT>
14
                <TITLE>DLI: OAI_ANDS transform</TITLE>
15
                <CODE><![CDATA[<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
16
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17
                xmlns:datetime="http://exslt.org/dates-and-times" xmlns:exslt="http://exslt.org/common"
18
                xmlns:oai="http://www.openarchives.org/OAI/2.0/"
19
                xmlns:dnet="eu.dnetlib.dli.DLIUtils"
20
                xmlns:dc="http://purl.org/dc/elements/1.1/"
21
                xmlns:oaf="http://namespace.dnet.eu/oaf"
22
                xmlns:stringutils="org.apache.commons.lang3.StringUtils"
23
                exclude-result-prefixes="xsl datetime exslt dnet stringutils">
24
    <xsl:template match="/">
25
        <xsl:choose>
26
            <xsl:when test="not(//*[local-name()='relatedInfo'])">
27
                <record></record>
28
            </xsl:when>
29
            <xsl:when test="not(//*[local-name()='setSpec' and ./text()='class:collection'])">
30
                <record></record>
31
            </xsl:when>
32

    
33

    
34
            <xsl:otherwise>
35
                <xsl:variable name="pid">
36
                    <xsl:value-of
37
                            select="concat('https://researchdata.ands.org.au/registry/registry_object/view/',stringutils:substringAfter(//*[local-name()='header']/*[local-name()='recordIdentifier'],'::'))"/>
38
                </xsl:variable>
39

    
40
                <xsl:variable name="namespacePrefix">
41
                    <xsl:value-of select="//*[local-name()='header']/*[local-name()='datasourceprefix']"/>
42
                </xsl:variable>
43
                <xsl:variable name="datasourceID" select="dnet:getIdFromDataSourcePrefix($namespacePrefix)"/>
44
                <xsl:variable name="datasourceName" select="dnet:getNameFromDataSourcePrefix($namespacePrefix)"/>
45
                <pack>
46

    
47

    
48
                    <oai:record xmlns="http://namespace.openaire.eu/"
49
                                xmlns:dc="http://purl.org/dc/elements/1.1/"
50
                                xmlns:dr="http://www.driver-repository.eu/namespace/dr"
51
                                xmlns:prov="http://www.openarchives.org/OAI/2.0/provenance"
52
                                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
53
                        <xsl:copy-of select="//*[local-name()='header']"/>
54
                        <metadata>
55
                            <resource xmlns="http://datacite.org/schema/kernel-3"
56
                                      xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
57
                                <identifier identifierType="url">
58
                                    <xsl:value-of select="$pid"/>
59
                                </identifier>
60
                                <titles>
61
                                    <xsl:for-each
62
                                            select="//*[local-name()='name' and  ./@type='primary']/*[local-name()='namePart']">
63
                                        <title>
64
                                            <xsl:value-of select="."/>
65
                                        </title>
66
                                    </xsl:for-each>
67
                                </titles>
68
                                <dates>
69
                                    <xsl:for-each select="//*[local-name()='date' and ./@type='dateTo']">
70
                                        <date dateType="Collected">
71
                                            <xsl:value-of select="."/>
72
                                        </date>
73
                                    </xsl:for-each>
74
                                </dates>
75
                                <resourceType resourceTypeGeneral="Dataset">Dataset</resourceType>
76
                                <relatedIdentifiers>
77
                                    <xsl:for-each select="//*[local-name()='relatedInfo']">
78
                                        <xsl:if test="count(./*[local-name()='identifier']) &gt; 0">
79

    
80
                                            <xsl:variable name="relTypology">
81
                                                <xsl:choose>
82
                                                    <xsl:when test="./@type = 'publication'">publication</xsl:when>
83
                                                    <xsl:otherwise>unknown</xsl:otherwise>
84
                                                </xsl:choose>
85
                                            </xsl:variable>
86
                                            <xsl:variable name="relatedIdType">
87
                                                <xsl:choose>
88
                                                    <xsl:when test="./@type = 'publication'">dnet</xsl:when>
89
                                                    <xsl:otherwise>
90
                                                        <xsl:value-of select="./*[local-name()='identifier']/@type"/>
91
                                                    </xsl:otherwise>
92
                                                </xsl:choose>
93
                                            </xsl:variable>
94

    
95
                                            <xsl:variable name="relatedId">
96
                                                <xsl:choose>
97
                                                    <xsl:when test="./@type = 'publication'">
98
                                                        <xsl:choose>
99
                                                            <xsl:when
100
                                                                    test="./*[local-name()='identifier' and ./@type='doi']">
101
                                                                <xsl:value-of
102
                                                                        select="concat($namespacePrefix, '::', dnet:generateIdentifier(./*[local-name()='identifier' and ./@type='doi'],'doi'))"/>
103
                                                            </xsl:when>
104
                                                            <xsl:otherwise>
105
                                                                <xsl:value-of
106
                                                                        select="concat($namespacePrefix, '::', dnet:generateIdentifier(./*[local-name()='identifier'][1], ./*[local-name()='identifier'][1]/@type))"/>
107
                                                            </xsl:otherwise>
108
                                                        </xsl:choose>
109
                                                    </xsl:when>
110
                                                    <xsl:otherwise>
111
                                                        <xsl:value-of select="./*[local-name()='identifier']"/>
112
                                                    </xsl:otherwise>
113
                                                </xsl:choose>
114
                                            </xsl:variable>
115

    
116

    
117
                                            <xsl:for-each select=".//*[local-name()='identifier']">
118
                                                <relatedIdentifier xmlns:oaf="http://namespace.dnet.eu/oaf"
119
                                                                   inverseRelationType="unknown" relationType="unknown"
120
                                                                   entityType="{$relTypology}">
121
                                                    <xsl:attribute name="relatedIdentifierType">
122
                                                        <xsl:value-of select="$relatedIdType"/>
123
                                                    </xsl:attribute>
124
                                                    <xsl:value-of select="$relatedId"/>
125
                                                </relatedIdentifier>
126
                                            </xsl:for-each>
127
                                        </xsl:if>
128
                                    </xsl:for-each>
129
                                </relatedIdentifiers>
130
                            </resource>
131
                        </metadata>
132
                        <oaf:about>
133
                            <oaf:datainfo>
134
                                <oaf:collectedFrom completionStatus="complete">
135
                                    <xsl:attribute name="id">
136
                                        <xsl:value-of select="dnet:getIdFromDataSourcePrefix($namespacePrefix)"/>
137
                                    </xsl:attribute>
138
                                    <xsl:attribute name="name">
139
                                        <xsl:value-of select="dnet:getNameFromDataSourcePrefix($namespacePrefix)"/>
140
                                    </xsl:attribute>
141
                                </oaf:collectedFrom>
142
                                <oaf:completionStatus>complete</oaf:completionStatus>
143
                                <oaf:provisionMode>collected</oaf:provisionMode>
144
                            </oaf:datainfo>
145
                        </oaf:about>
146
                    </oai:record>
147

    
148

    
149

    
150

    
151

    
152

    
153

    
154
                    <xsl:for-each select="//*[local-name()='relatedInfo' and ./@type='publication']">
155

    
156
                        <xsl:if test="count(./*[local-name()='identifier']) &gt; 0">
157
                            <xsl:variable name="pidType">
158
                                <xsl:choose>
159
                                    <xsl:when test="count(./*[local-name()='identifier' and ./@type='doi'])">doi</xsl:when>
160
                                    <xsl:otherwise>
161
                                        <xsl:value-of select="./*[local-name()='identifier'][1]/@type"/>
162
                                    </xsl:otherwise>
163
                                </xsl:choose>
164
                            </xsl:variable>
165
                            <xsl:variable name="publicationIdentifier">
166
                                <xsl:choose>
167
                                    <xsl:when test="count(./*[local-name()='identifier' and ./@type='doi'])">
168
                                        <xsl:value-of select="./*[local-name()='identifier' and ./@type='doi']"/>
169
                                    </xsl:when>
170
                                    <xsl:otherwise>
171
                                        <xsl:value-of select="./*[local-name()='identifier'][1]"/>
172
                                    </xsl:otherwise>
173
                                </xsl:choose>
174
                            </xsl:variable>
175
                            <xsl:variable name="objIdentifier">
176
                                <xsl:value-of
177
                                        select="concat($namespacePrefix, '::', dnet:generateIdentifier($publicationIdentifier,$pidType))"/>
178
                            </xsl:variable>
179
                            <oai:record xmlns:oai="http://www.openarchives.org/OAI/2.0/"
180
                                        xmlns:dri="http://www.driver-repository.eu/namespace/dri"
181
                                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
182
                                <oai:header>
183
                                    <dri:objIdentifier>
184
                                        <xsl:value-of select="$objIdentifier"/>
185
                                    </dri:objIdentifier>
186
                                    <dri:recordIdentifier>
187
                                        <xsl:value-of select="$publicationIdentifier"/>
188
                                    </dri:recordIdentifier>
189
                                    <dri:dateOfCollection>
190
                                        <xsl:value-of select="//dri:dateOfCollection"/>
191
                                    </dri:dateOfCollection>
192
                                    <dri:repositoryId>
193
                                        <xsl:value-of select="//dri:repositoryId"/>
194
                                    </dri:repositoryId>
195
                                    <dri:datasourceprefix>
196
                                        <xsl:value-of select="$namespacePrefix"/>
197
                                    </dri:datasourceprefix>
198
                                    <oai:identifier>
199
                                        <xsl:value-of select="$publicationIdentifier"/>
200
                                    </oai:identifier>
201
                                </oai:header>
202
                                <metadata>
203
                                    <oaf:pid type="{$pidType}">
204
                                        <xsl:value-of select="$publicationIdentifier"/>
205
                                    </oaf:pid>
206
                                    <dc:identifier>
207
                                        <xsl:value-of select="$publicationIdentifier"/>
208
                                    </dc:identifier>
209
                                    <xsl:for-each select="./*[local-name()='title']">
210
                                        <dc:title>
211
                                            <xsl:value-of select="."/>
212
                                        </dc:title>
213
                                    </xsl:for-each>
214
                                    <xsl:for-each select=".//*[local-name()='note']">
215
                                        <dc:description>
216
                                            <xsl:value-of select="."/>
217
                                        </dc:description>
218
                                    </xsl:for-each>
219
                                    <dc:type>publication</dc:type>
220
                                </metadata>
221
                                <oaf:about>
222
                                    <oaf:datainfo>
223
                                        <oaf:collectedFrom completionStatus="complete">
224
                                            <xsl:attribute name="id">
225
                                                <xsl:value-of select="dnet:getIdFromDataSourcePrefix($namespacePrefix)"/>
226
                                            </xsl:attribute>
227
                                            <xsl:attribute name="name">
228
                                                <xsl:value-of select="dnet:getNameFromDataSourcePrefix($namespacePrefix)"/>
229
                                            </xsl:attribute>
230
                                        </oaf:collectedFrom>
231
                                        <oaf:completionStatus>complete</oaf:completionStatus>
232
                                        <oaf:provisionMode>collected</oaf:provisionMode>
233
                                    </oaf:datainfo>
234
                                </oaf:about>
235
                            </oai:record>
236
                        </xsl:if>
237
                    </xsl:for-each>
238
                </pack>
239
            </xsl:otherwise>
240
        </xsl:choose>
241
    </xsl:template>
242
</xsl:stylesheet>]]>
243
                </CODE>
244
			</SCRIPT>
245
		</CONFIGURATION>
246
		<STATUS/>
247
		<SECURITY_PARAMETERS/>
248
	</BODY>
249
</RESOURCE_PROFILE>
(7-7/16)