Project

General

Profile

« Previous | Next » 

Revision 59687

Fixed xslt for OpenDOAR. Using xslt2.0 caused some xpaths to not work anymore and need the embedding in CDATA element

View differences:

modules/dnet-openaireplus-profiles/trunk/src/main/resources/eu/dnetlib/test/profiles/TransformationRuleDSResources/TransformationRuleDSResourceType/datasources/opendoar2dbrest.xml
13 13
            <SCRIPT>
14 14
                <TITLE>OPENDOAR 2 DB REST</TITLE>
15 15
                <CODE>
16
                    <![CDATA[
16 17

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

  
20 21
                        <xsl:param name="varDataSourceId"/>
21 22
                        <xsl:variable name="namespacePrefix" select="string('opendoar____')"/>
......
23 24
                        <xsl:template match="/">
24 25
                            <record>
25 26

  
26
                                <xsl:copy-of select=".//*[local-name()='header']"/>
27
                                <xsl:copy-of select=".//*[local-name() = 'header']"/>
27 28
                                <metadata>
28 29
                                    <xsl:variable name="rid" select="normalize-space(//items/system_metadata/id)"/>
29 30
                                    <xsl:variable name="datasourceId" select="concat($namespacePrefix, '::', $rid)"/>
30 31
                                    <xsl:variable name="apiId" select="concat('api_________::', $datasourceId, '::0')"/>
31
                                    <xsl:variable name="oUrl" select="normalize-space(//organisation/url)"/>
32
                                    <xsl:variable name="oName" select="normalize-space(//organisation/name/name)"/>
33
                                    <xsl:variable name="organizationId"
34
                                                  select="translate(concat($namespacePrefix, '::', $oName), ' ', '_')"/>
35 32
                                    <xsl:variable name="repositoryType">
36 33
                                        <xsl:choose>
37 34
                                            <xsl:when
......
50 47
                                                    test="lower-case(normalize-space(//repository_metadata/type)) = 'aggregating'">
51 48
                                                <xsl:choose>
52 49
                                                    <xsl:when
53
                                                            test="lower-case(normalize-space(//repository_metadata/content_types)) = 'journal_articles'">
50
                                                            test="//repository_metadata/content_types = 'journal_articles'">
54 51
                                                        <xsl:value-of
55 52
                                                                select="string('aggregator::pubsrepository::journals')"/>
56 53
                                                    </xsl:when>
......
68 65

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

  
82 79
                                    <xsl:variable name="subjects">
83 80
                                        <xsl:for-each select=".//content_subjects/label">
84
                                            <xsl:if test="position() &amp;gt; 1">@@</xsl:if>
81
                                            <xsl:if test="position() > 1">@@</xsl:if>
85 82
                                            <xsl:value-of select="."/>
86 83
                                        </xsl:for-each>
87 84
                                    </xsl:variable>
......
98 95
                                                <xsl:choose>
99 96
                                                    <xsl:when test="//repository_metadata/name/name">
100 97
                                                        <xsl:value-of
101
                                                                select="normalize-space(//repository_metadata/name/name)"/>
98
                                                                select="normalize-space(//repository_metadata/name[1]/name[1])"/>
102 99
                                                    </xsl:when>
103 100
                                                    <xsl:otherwise>
104 101
                                                        <xsl:value-of
105
                                                                select="normalize-space(//repository_metadata/name/acronym)"/>
102
                                                                select="normalize-space(//repository_metadata/name[1]/acronym)"
103
                                                        />
106 104
                                                    </xsl:otherwise>
107 105
                                                </xsl:choose>
108 106
                                            </FIELD>
......
110 108
                                                <xsl:choose>
111 109
                                                    <xsl:when test="//repository_metadata/name/acronym">
112 110
                                                        <xsl:value-of
113
                                                                select="normalize-space(//repository_metadata/name/acronym)"/>
111
                                                                select="normalize-space(//repository_metadata/name[1]/acronym)"
112
                                                        />
114 113
                                                    </xsl:when>
115 114
                                                    <xsl:otherwise>
116 115
                                                        <xsl:value-of
117
                                                                select="normalize-space(//repository_metadata/name/name)"/>
116
                                                                select="normalize-space(//repository_metadata/name[1]/name[1])"/>
118 117
                                                    </xsl:otherwise>
119 118
                                                </xsl:choose>
120 119
                                            </FIELD>
......
124 123
                                            <FIELD name="contactemail">
125 124
                                                <xsl:value-of select="normalize-space(//pEmail)"/>
126 125
                                            </FIELD>
127
                                            <xsl:if test="not(normalize-space(//organisation/location/latitude) = 'null')">
126
                                            <xsl:if
127
                                                    test="not(normalize-space(//organisation/location/latitude) = 'null')">
128 128
                                                <FIELD name="latitude" type="float">
129 129
                                                    <xsl:value-of
130 130
                                                            select="normalize-space(//organisation/location/latitude)"/>
......
133 133
                                            <xsl:if test="normalize-space(//organisation/location/latitude) = 'null'">
134 134
                                                <FIELD name="latitude" type="float"/>
135 135
                                            </xsl:if>
136
                                            <xsl:if test="not(normalize-space(//organisation/location/longitude) = 'null')">
136
                                            <xsl:if
137
                                                    test="not(normalize-space(//organisation/location/longitude) = 'null')">
137 138
                                                <FIELD name="longitude" type="float">
138 139
                                                    <xsl:value-of
139 140
                                                            select="normalize-space(//organisation/location/longitude)"/>
......
170 171
                                            <FIELD name="subjects">
171 172
                                                <xsl:value-of select="normalize-space($subjects)"/>
172 173
                                            </FIELD>
173
                                            <xsl:if test="//policies/preservation_policy/version_control/policy[./text() = 'updated_versions_allowed']">
174
                                            <xsl:if
175
                                                    test="//policies/preservation_policy/version_control/policy[./text() = 'updated_versions_allowed']">
174 176
                                                <FIELD name="versioning" type="boolean">true</FIELD>
175 177
                                            </xsl:if>
176 178
                                        </ROW>
......
193 195
                                            <FIELD name="baseurl">
194 196
                                                <xsl:value-of select="normalize-space(//repository_metadata/oai_url)"/>
195 197
                                            </FIELD>
196
                                            <FIELD name="metadata_identifier_path">
197
                                                //*[local-name()='header']/*[local-name()='identifier']
198
                                            </FIELD>
198
                                            <FIELD name="metadata_identifier_path">//*[local-name()='header']/*[local-name()='identifier']</FIELD>
199 199
                                        </ROW>
200 200

  
201 201
                                        <ROW table="dsm_apiparams">
......
209 209
                                            <FIELD name="value">oai_dc</FIELD>
210 210
                                        </ROW>
211 211

  
212
                                        <ROW table="dsm_organizations">
213
                                            <FIELD name="_dnet_resource_identifier_">
214
                                                <xsl:value-of select="$organizationId"/>
215
                                            </FIELD>
216
                                            <FIELD name="id">
217
                                                <xsl:value-of select="$organizationId"/>
218
                                            </FIELD>
219
                                            <FIELD name="legalname">
220
                                                <xsl:value-of select="$oName"/>
221
                                            </FIELD>
222
                                            <FIELD name="legalshortname">
223
                                                <xsl:value-of select="normalize-space(//organisation/name/acronym)"/>
224
                                            </FIELD>
225
                                            <FIELD name="websiteurl">
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">
226 217
                                                <xsl:choose>
227
                                                    <xsl:when test="starts-with(normalize-space($oUrl), 'http')">
228
                                                        <xsl:value-of select="normalize-space($oUrl)"/>
229
                                                    </xsl:when>
230
                                                    <xsl:when test="string-length(normalize-space($oUrl)) &amp;gt; 0">
218
                                                    <xsl:when
219
                                                            test="string-length($preferredNameLanguage[1]/text()) > 0 and ./name[./language = $preferredNameLanguage]/name">
231 220
                                                        <xsl:value-of
232
                                                                select="concat('http://', normalize-space($oUrl))"/>
221
                                                                select="./name[./language = $preferredNameLanguage]/name/text()"
222
                                                        />
233 223
                                                    </xsl:when>
224
                                                    <xsl:otherwise>
225
                                                        <xsl:value-of select="./name[1]/name/text()"/>
226
                                                    </xsl:otherwise>
234 227
                                                </xsl:choose>
235
                                            </FIELD>
236

  
237
                                            <FIELD name="country">
228
                                            </xsl:variable>
229
                                            <xsl:variable name="oAcronym">
238 230
                                                <xsl:choose>
239
                                                    <xsl:when test="normalize-space(//organisation/country) = 'UK'">GB
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
                                                        />
240 236
                                                    </xsl:when>
241 237
                                                    <xsl:otherwise>
242
                                                        <xsl:value-of select="normalize-space(//organisation/country)"/>
238
                                                        <xsl:value-of select="./name[1]/acronym"/>
243 239
                                                    </xsl:otherwise>
244 240
                                                </xsl:choose>
245
                                            </FIELD>
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>
246 271

  
247
                                            <FIELD name="collectedfrom">
248
                                                <xsl:value-of select="$varDataSourceId"/>
249
                                            </FIELD>
250
                                            <FIELD name="provenanceaction">sysimport:crosswalk:entityregistry</FIELD>
251
                                        </ROW>
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>
252 280

  
253
                                        <ROW table="dsm_datasource_organization">
254
                                            <FIELD name="_dnet_resource_identifier_">
255
                                                <xsl:value-of select="concat($datasourceId, '@@', $organizationId)"/>
256
                                            </FIELD>
257
                                            <FIELD name="datasource">
258
                                                <xsl:value-of select="$datasourceId"/>
259
                                            </FIELD>
260
                                            <FIELD name="organization">
261
                                                <xsl:value-of select="$organizationId"/>
262
                                            </FIELD>
263
                                        </ROW>
281
                                                    <FIELD name="collectedfrom">
282
                                                        <xsl:value-of select="$varDataSourceId"/>
283
                                                    </FIELD>
284
                                                    <FIELD name="provenanceaction"
285
                                                    >sysimport:crosswalk:entityregistry</FIELD>
286
                                                </ROW>
264 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

  
265 303
                                    </ROWS>
266 304
                                </metadata>
267 305
                            </record>
268 306
                        </xsl:template>
269 307

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

  
272 311

  
312

  
273 313
                </CODE>
274 314
            </SCRIPT>
275 315
        </CONFIGURATION>

Also available in: Unified diff