Project

General

Profile

1
<RESOURCE_PROFILE>
2
    <HEADER>
3
        <RESOURCE_IDENTIFIER
4
                value="a2611b61-3748-4917-9397-3426b5174d8d_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
5
        <RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
6
        <RESOURCE_KIND value="TransformationRuleDSResources"/>
7
        <RESOURCE_URI value=""/>
8
        <DATE_OF_CREATION value="2019-11-11T10:35:54+00:00"/>
9
    </HEADER>
10
    <BODY>
11
        <CONFIGURATION>
12
            <IMPORTED/>
13
            <SCRIPT>
14
                <TITLE>OPENDOAR 2 DB REST</TITLE>
15
                <CODE>
16
                    <![CDATA[
17

    
18
                    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
19
                                    xmlns:dnet="eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions" version="2.0">
20

    
21
                        <xsl:param name="varDataSourceId"/>
22
                        <xsl:variable name="namespacePrefix" select="string('opendoar____')"/>
23

    
24
                        <xsl:template match="/">
25
                            <record>
26

    
27
                                <xsl:copy-of select=".//*[local-name() = 'header']"/>
28
                                <metadata>
29
                                    <xsl:variable name="rid" select="normalize-space(//items/system_metadata/id)"/>
30
                                    <xsl:variable name="datasourceId" select="concat($namespacePrefix, '::', $rid)"/>
31
                                    <xsl:variable name="apiId" select="concat('api_________::', $datasourceId, '::0')"/>
32
                                    <xsl:variable name="repositoryType">
33
                                        <xsl:choose>
34
                                            <xsl:when
35
                                                    test="lower-case(normalize-space(//repository_metadata/type)) = 'institutional'">
36
                                                <xsl:value-of select="string('pubsrepository::institutional')"/>
37
                                            </xsl:when>
38
                                            <xsl:when
39
                                                    test="lower-case(normalize-space(//repository_metadata/type)) = 'governmental'">
40
                                                <xsl:value-of select="string('pubsrepository::institutional')"/>
41
                                            </xsl:when>
42
                                            <xsl:when
43
                                                    test="lower-case(normalize-space(//repository_metadata/type)) = 'disciplinary'">
44
                                                <xsl:value-of select="string('pubsrepository::thematic')"/>
45
                                            </xsl:when>
46
                                            <xsl:when
47
                                                    test="lower-case(normalize-space(//repository_metadata/type)) = 'aggregating'">
48
                                                <xsl:choose>
49
                                                    <xsl:when
50
                                                            test="//repository_metadata/content_types = 'journal_articles'">
51
                                                        <xsl:value-of
52
                                                                select="string('aggregator::pubsrepository::journals')"/>
53
                                                    </xsl:when>
54
                                                    <xsl:otherwise>
55
                                                        <xsl:value-of
56
                                                                select="string('aggregator::pubsrepository::unknown')"/>
57
                                                    </xsl:otherwise>
58
                                                </xsl:choose>
59
                                            </xsl:when>
60
                                            <xsl:otherwise>
61
                                                <xsl:value-of select="string('pubsrepository::unknown')"/>
62
                                            </xsl:otherwise>
63
                                        </xsl:choose>
64
                                    </xsl:variable>
65

    
66
                                    <xsl:variable name="contenttypes">
67
                                        <xsl:for-each select=".//content_types">
68
                                            <xsl:if test="position() > 1">-</xsl:if>
69
                                            <xsl:value-of select="."/>
70
                                        </xsl:for-each>
71
                                    </xsl:variable>
72
                                    <xsl:variable name="languages">
73
                                        <xsl:for-each select=".//content_languages">
74
                                            <xsl:if test="position() > 1">,</xsl:if>
75
                                            <xsl:value-of select="."/>
76
                                        </xsl:for-each>
77
                                    </xsl:variable>
78

    
79
                                    <xsl:variable name="subjects">
80
                                        <xsl:for-each select=".//content_subjects/label">
81
                                            <xsl:if test="position() > 1">@@</xsl:if>
82
                                            <xsl:value-of select="."/>
83
                                        </xsl:for-each>
84
                                    </xsl:variable>
85

    
86
                                    <ROWS>
87
                                        <ROW table="dsm_datasources">
88
                                            <FIELD name="_dnet_resource_identifier_">
89
                                                <xsl:value-of select="$datasourceId"/>
90
                                            </FIELD>
91
                                            <FIELD name="id">
92
                                                <xsl:value-of select="$datasourceId"/>
93
                                            </FIELD>
94
                                            <FIELD name="officialname">
95
                                                <xsl:choose>
96
                                                    <xsl:when test="//repository_metadata/name/name">
97
                                                        <xsl:value-of
98
                                                                select="normalize-space(//repository_metadata/name[1]/name[1])"/>
99
                                                    </xsl:when>
100
                                                    <xsl:otherwise>
101
                                                        <xsl:value-of
102
                                                                select="normalize-space(//repository_metadata/name[1]/acronym)"
103
                                                        />
104
                                                    </xsl:otherwise>
105
                                                </xsl:choose>
106
                                            </FIELD>
107
                                            <FIELD name="englishname">
108
                                                <xsl:choose>
109
                                                    <xsl:when test="//repository_metadata/name/acronym">
110
                                                        <xsl:value-of
111
                                                                select="normalize-space(//repository_metadata/name[1]/acronym)"
112
                                                        />
113
                                                    </xsl:when>
114
                                                    <xsl:otherwise>
115
                                                        <xsl:value-of
116
                                                                select="normalize-space(//repository_metadata/name[1]/name[1])"/>
117
                                                    </xsl:otherwise>
118
                                                </xsl:choose>
119
                                            </FIELD>
120
                                            <FIELD name="websiteurl">
121
                                                <xsl:value-of select="normalize-space(//repository_metadata/url)"/>
122
                                            </FIELD>
123
                                            <FIELD name="contactemail">
124
                                                <xsl:value-of select="normalize-space(//pEmail)"/>
125
                                            </FIELD>
126
                                            <xsl:if
127
                                                    test="not(normalize-space(//organisation/location/latitude) = 'null')">
128
                                                <FIELD name="latitude" type="float">
129
                                                    <xsl:value-of
130
                                                            select="normalize-space(//organisation/location/latitude)"/>
131
                                                </FIELD>
132
                                            </xsl:if>
133
                                            <xsl:if test="normalize-space(//organisation/location/latitude) = 'null'">
134
                                                <FIELD name="latitude" type="float"/>
135
                                            </xsl:if>
136
                                            <xsl:if
137
                                                    test="not(normalize-space(//organisation/location/longitude) = 'null')">
138
                                                <FIELD name="longitude" type="float">
139
                                                    <xsl:value-of
140
                                                            select="normalize-space(//organisation/location/longitude)"/>
141
                                                </FIELD>
142
                                            </xsl:if>
143
                                            <xsl:if test="normalize-space(//organisation/location/longitude) = 'null'">
144
                                                <FIELD name="longitude" type="float"/>
145
                                            </xsl:if>
146
                                            <FIELD name="namespaceprefix">
147
                                                <xsl:value-of select="dnet:generateNsPrefix('od', $rid)"/>
148
                                            </FIELD>
149
                                            <FIELD name="languages">
150
                                                <xsl:value-of select="normalize-space($languages)"/>
151
                                            </FIELD>
152
                                            <FIELD name="od_contenttypes">
153
                                                <xsl:value-of select="normalize-space($contenttypes)"/>
154
                                            </FIELD>
155
                                            <FIELD name="collectedfrom">
156
                                                <xsl:value-of select="$varDataSourceId"/>
157
                                            </FIELD>
158
                                            <FIELD name="typology">
159
                                                <xsl:value-of select="$repositoryType"/>
160
                                            </FIELD>
161
                                            <FIELD name="provenanceaction">sysimport:crosswalk:entityregistry</FIELD>
162
                                            <FIELD name="platform">
163
                                                <xsl:value-of
164
                                                        select="normalize-space(//repository_metadata/software/name)"/>
165
                                            </FIELD>
166
                                            <FIELD name="description">
167
                                                <xsl:value-of
168
                                                        select="normalize-space(//repository_metadata/description)"/>
169
                                            </FIELD>
170

    
171
                                            <FIELD name="subjects">
172
                                                <xsl:value-of select="normalize-space($subjects)"/>
173
                                            </FIELD>
174
                                            <xsl:if
175
                                                    test="//policies/preservation_policy/version_control/policy[./text() = 'updated_versions_allowed']">
176
                                                <FIELD name="versioning" type="boolean">true</FIELD>
177
                                            </xsl:if>
178
                                        </ROW>
179

    
180
                                        <ROW table="dsm_api">
181
                                            <FIELD name="_dnet_resource_identifier_">
182
                                                <xsl:value-of select="$apiId"/>
183
                                            </FIELD>
184
                                            <FIELD name="id">
185
                                                <xsl:value-of select="$apiId"/>
186
                                            </FIELD>
187
                                            <FIELD name="protocol">oai</FIELD>
188
                                            <FIELD name="datasource">
189
                                                <xsl:value-of select="$datasourceId"/>
190
                                            </FIELD>
191
                                            <FIELD name="contentdescription">metadata</FIELD>
192
                                            <FIELD name="typology">
193
                                                <xsl:value-of select="$repositoryType"/>
194
                                            </FIELD>
195
                                            <FIELD name="baseurl">
196
                                                <xsl:value-of select="normalize-space(//repository_metadata/oai_url)"/>
197
                                            </FIELD>
198
                                            <FIELD name="metadata_identifier_path">//*[local-name()='header']/*[local-name()='identifier']</FIELD>
199
                                        </ROW>
200

    
201
                                        <ROW table="dsm_apiparams">
202
                                            <FIELD name="_dnet_resource_identifier_">
203
                                                <xsl:value-of select="concat($apiId, '@@format')"/>
204
                                            </FIELD>
205
                                            <FIELD name="api">
206
                                                <xsl:value-of select="$apiId"/>
207
                                            </FIELD>
208
                                            <FIELD name="param">format</FIELD>
209
                                            <FIELD name="value">oai_dc</FIELD>
210
                                        </ROW>
211

    
212
                                        <xsl:for-each select="//organisation">
213
                                            <xsl:variable name="oUrl" select="normalize-space(./url)"/>
214
                                            <xsl:variable name="preferredNameLanguage"
215
                                                          select="./name/preferred_phrases[./value = 'name'][1]/language[1]"/>
216
                                            <xsl:variable name="oName">
217
                                                <xsl:choose>
218
                                                    <xsl:when
219
                                                            test="string-length($preferredNameLanguage[1]/text()) > 0 and ./name[./language = $preferredNameLanguage]/name">
220
                                                        <xsl:value-of
221
                                                                select="./name[./language = $preferredNameLanguage]/name/text()"
222
                                                        />
223
                                                    </xsl:when>
224
                                                    <xsl:otherwise>
225
                                                        <xsl:value-of select="./name[1]/name/text()"/>
226
                                                    </xsl:otherwise>
227
                                                </xsl:choose>
228
                                            </xsl:variable>
229
                                            <xsl:variable name="oAcronym">
230
                                                <xsl:choose>
231
                                                    <xsl:when
232
                                                            test="string-length($preferredNameLanguage[1]/text()) > 0 and ./name[./language = $preferredNameLanguage]/acronym">
233
                                                        <xsl:value-of
234
                                                                select="./name[./language = $preferredNameLanguage]/acronym"
235
                                                        />
236
                                                    </xsl:when>
237
                                                    <xsl:otherwise>
238
                                                        <xsl:value-of select="./name[1]/acronym"/>
239
                                                    </xsl:otherwise>
240
                                                </xsl:choose>
241
                                            </xsl:variable>
242
                                            <xsl:variable name="oCountry"
243
                                                          select="upper-case(normalize-space(./country))"/>
244
                                            <xsl:variable name="organizationId"
245
                                                          select="translate(translate(concat($namespacePrefix, '::', $oName, '_', $oCountry), ' ', '_'), '&quot;', '')"/>
246
                                            <xsl:if test="string-length($oName) > 0">
247
                                                <ROW table="dsm_organizations">
248
                                                    <FIELD name="_dnet_resource_identifier_">
249
                                                        <xsl:value-of select="$organizationId"/>
250
                                                    </FIELD>
251
                                                    <FIELD name="id">
252
                                                        <xsl:value-of select="$organizationId"/>
253
                                                    </FIELD>
254
                                                    <FIELD name="legalname">
255
                                                        <xsl:value-of select="$oName"/>
256
                                                    </FIELD>
257
                                                    <FIELD name="legalshortname">
258
                                                        <xsl:value-of select="normalize-space($oAcronym)"/>
259
                                                    </FIELD>
260
                                                    <FIELD name="websiteurl">
261
                                                        <xsl:choose>
262
                                                            <xsl:when test="starts-with(normalize-space($oUrl), 'http')">
263
                                                                <xsl:value-of select="normalize-space($oUrl)"/>
264
                                                            </xsl:when>
265
                                                            <xsl:when test="string-length(normalize-space($oUrl)) > 0">
266
                                                                <xsl:value-of
267
                                                                        select="concat('http://', normalize-space($oUrl))"/>
268
                                                            </xsl:when>
269
                                                        </xsl:choose>
270
                                                    </FIELD>
271

    
272
                                                    <FIELD name="country">
273
                                                        <xsl:choose>
274
                                                            <xsl:when test="$oCountry = 'UK'">GB</xsl:when>
275
                                                            <xsl:otherwise>
276
                                                                <xsl:value-of select="$oCountry"/>
277
                                                            </xsl:otherwise>
278
                                                        </xsl:choose>
279
                                                    </FIELD>
280

    
281
                                                    <FIELD name="collectedfrom">
282
                                                        <xsl:value-of select="$varDataSourceId"/>
283
                                                    </FIELD>
284
                                                    <FIELD name="provenanceaction"
285
                                                    >sysimport:crosswalk:entityregistry</FIELD>
286
                                                </ROW>
287

    
288
                                                <ROW table="dsm_datasource_organization">
289
                                                    <FIELD name="_dnet_resource_identifier_">
290
                                                        <xsl:value-of
291
                                                                select="concat($datasourceId, '@@', $organizationId)"/>
292
                                                    </FIELD>
293
                                                    <FIELD name="datasource">
294
                                                        <xsl:value-of select="$datasourceId"/>
295
                                                    </FIELD>
296
                                                    <FIELD name="organization">
297
                                                        <xsl:value-of select="$organizationId"/>
298
                                                    </FIELD>
299
                                                </ROW>
300
                                            </xsl:if>
301
                                        </xsl:for-each>
302

    
303
                                    </ROWS>
304
                                </metadata>
305
                            </record>
306
                        </xsl:template>
307

    
308
                    </xsl:stylesheet>
309
]]>
310

    
311

    
312

    
313
                </CODE>
314
            </SCRIPT>
315
        </CONFIGURATION>
316
        <STATUS/>
317
        <SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
318
    </BODY>
319
</RESOURCE_PROFILE>
(5-5/8)