1
|
<RESOURCE_PROFILE>
|
2
|
<HEADER>
|
3
|
<RESOURCE_IDENTIFIER value="a9649911-1697-47df-922a-23ac4c1e593a_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
|
4
|
<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
|
5
|
<RESOURCE_KIND value="TransformationRuleDSResources"/>
|
6
|
<RESOURCE_URI value=""/>
|
7
|
<DATE_OF_CREATION value="2014-07-17T10:41:08+02:00"/>
|
8
|
</HEADER>
|
9
|
<BODY>
|
10
|
<CONFIGURATION>
|
11
|
<IMPORTED/>
|
12
|
<SCRIPT>
|
13
|
<TITLE>xslt_cleaning_pangaea_datacite</TITLE>
|
14
|
<CODE><![CDATA[
|
15
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"
|
16
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
17
|
xmlns:oaf="http://namespace.openaire.eu/oaf"
|
18
|
xmlns:dr="http://www.driver-repository.eu/namespace/dr"
|
19
|
xmlns:TransformationFunction="eu.dnetlib.data.collective.transformation.core.xsl.ext.TransformationFunctionProxy"
|
20
|
extension-element-prefixes="TransformationFunction"
|
21
|
exclude-result-prefixes="TransformationFunction">
|
22
|
<xsl:param name="varOfficialName"/>
|
23
|
<xsl:param name="varDsType"/>
|
24
|
<xsl:param name="varDataSourceId"/>
|
25
|
<xsl:param name="varCorda" select="'corda_______::'"/>
|
26
|
<xsl:param name="varCordaH2020" select="'corda__h2020::'"/>
|
27
|
<xsl:param name="index" select="0"/>
|
28
|
<xsl:param name="transDate" select="current-dateTime()"/>
|
29
|
<xsl:variable name="tf" select="TransformationFunction:getInstance()"/>
|
30
|
<xsl:template match="/">
|
31
|
<xsl:variable name="datasourcePrefix" select="normalize-space(//oaf:datasourceprefix)"/>
|
32
|
<xsl:call-template name="validRecord"/>
|
33
|
</xsl:template>
|
34
|
<xsl:template name="validRecord">
|
35
|
<record>
|
36
|
<xsl:apply-templates select="//*[local-name() = 'header']"/>
|
37
|
<metadata>
|
38
|
<xsl:copy-of select="//*[local-name() = 'metadata']/*[local-name() = 'resource']"/>
|
39
|
<xsl:copy-of
|
40
|
select="//*[local-name() = 'metadata']/*[local-name() = 'relatedPublication']"
|
41
|
copy-namespaces="no"/>
|
42
|
<xsl:copy-of
|
43
|
select="//*[local-name() = 'metadata']/*[local-name() = 'relatedDataSet']"
|
44
|
copy-namespaces="no"/>
|
45
|
<xsl:if test="//*[local-name() = 'date']/@dateType = 'Available'">
|
46
|
<xsl:variable name="varEmbargoEndDate"
|
47
|
select="TransformationFunction:convertString($tf, normalize-space(//*[local-name() = 'date'][@dateType = 'Available']), 'DateISO8601')"/>
|
48
|
<xsl:choose>
|
49
|
<xsl:when test="string-length($varEmbargoEndDate) > 0">
|
50
|
<oaf:embargoenddate>
|
51
|
<xsl:value-of select="$varEmbargoEndDate"/>
|
52
|
</oaf:embargoenddate>
|
53
|
</xsl:when>
|
54
|
<xsl:otherwise>
|
55
|
<oaf:skip>
|
56
|
<xsl:value-of
|
57
|
select="TransformationFunction:skipRecord($tf, $index)"/>
|
58
|
</oaf:skip>
|
59
|
</xsl:otherwise>
|
60
|
</xsl:choose>
|
61
|
</xsl:if>
|
62
|
<dr:CobjCategory>
|
63
|
<xsl:value-of
|
64
|
select="TransformationFunction:convertString($tf, //*[local-name() = 'resourceType']/@resourceTypeGeneral, 'TextTypologies')"
|
65
|
/>
|
66
|
</dr:CobjCategory>
|
67
|
<oaf:dateAccepted>
|
68
|
<xsl:value-of
|
69
|
select="TransformationFunction:convertString($tf, normalize-space(//*[local-name() = 'publicationYear']), 'DateISO8601')"
|
70
|
/>
|
71
|
</oaf:dateAccepted>
|
72
|
<xsl:choose>
|
73
|
<xsl:when
|
74
|
test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
|
75
|
<oaf:accessrights>
|
76
|
<xsl:value-of
|
77
|
select="TransformationFunction:convertString($tf, //*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'AccessRights')"
|
78
|
/>
|
79
|
</oaf:accessrights>
|
80
|
</xsl:when>
|
81
|
<xsl:when
|
82
|
test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
|
83
|
<oaf:accessrights>
|
84
|
<xsl:value-of
|
85
|
select="TransformationFunction:convertString($tf, //*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'AccessRights')"
|
86
|
/>
|
87
|
</oaf:accessrights>
|
88
|
</xsl:when>
|
89
|
<xsl:otherwise>
|
90
|
<xsl:choose>
|
91
|
<xsl:when
|
92
|
test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'http://creativecommons.org')]">
|
93
|
<oaf:accessrights>
|
94
|
<xsl:text>OPEN</xsl:text>
|
95
|
</oaf:accessrights>
|
96
|
</xsl:when>
|
97
|
<xsl:otherwise>
|
98
|
<oaf:accessrights>
|
99
|
<xsl:text>CLOSED</xsl:text>
|
100
|
</oaf:accessrights>
|
101
|
</xsl:otherwise>
|
102
|
</xsl:choose>
|
103
|
</xsl:otherwise>
|
104
|
</xsl:choose>
|
105
|
<oaf:language>
|
106
|
<xsl:value-of
|
107
|
select="TransformationFunction:convert($tf, //*[local-name() = 'language'], 'Languages')"
|
108
|
/>
|
109
|
</oaf:language>
|
110
|
<!--
|
111
|
<xsl:if test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics/embargoedAccess')]">
|
112
|
<oaf:embargoenddate>
|
113
|
<xsl:value-of select="//*[local-name()='date']/@dateType='Available'"/>
|
114
|
</oaf:embargoenddate>
|
115
|
</xsl:if>
|
116
|
-->
|
117
|
<!-- I am not sure the following foreach works and it is useful...nameIdentifie seems not to be an XML element in pangaea format -->
|
118
|
<xsl:for-each select="//*[local-name() = 'nameIdentifier']">
|
119
|
|
120
|
<xsl:if test="string-length(substring-after(normalize-space(.), 'info:eu-repo/grantAgreement/EC/FP7/')) = 6">
|
121
|
<oaf:projectid>
|
122
|
<xsl:value-of
|
123
|
select="TransformationFunction:regExpr($tf, normalize-space(.), $varCorda, 's/^(.*info:eu-repo\/grantAgreement\/EC\/FP7\/)//gm')"
|
124
|
/>
|
125
|
</oaf:projectid>
|
126
|
</xsl:if>
|
127
|
<xsl:if test="starts-with(normalize-space(.), 'tar')">
|
128
|
<oaf:projectid>
|
129
|
<xsl:value-of select="normalize-space(.)"/>
|
130
|
</oaf:projectid>
|
131
|
</xsl:if>
|
132
|
</xsl:for-each>
|
133
|
|
134
|
<xsl:for-each select="//*[local-name() = 'projectid']">
|
135
|
<xsl:choose>
|
136
|
<xsl:when test="string-length(substring-after(normalize-space(.), 'info:eu-repo/grantAgreement/EC/FP7/')) > 0">
|
137
|
<oaf:projectid>
|
138
|
<xsl:value-of
|
139
|
select="TransformationFunction:regExpr($tf, normalize-space(.), $varCorda, 's/^(.*info:eu-repo\/grantAgreement\/EC\/FP7\/)//gm')" />
|
140
|
</oaf:projectid>
|
141
|
</xsl:when>
|
142
|
<xsl:when test="string-length(substring-after(normalize-space(.), 'info:eu-repo/grantAgreement/EC/H2020/')) > 0">
|
143
|
<oaf:projectid>
|
144
|
<xsl:value-of
|
145
|
select="TransformationFunction:regExpr($tf, normalize-space(.), $varCordaH2020, 's/^(.*info:eu-repo\/grantAgreement\/EC\/H2020\/)//gm')" />
|
146
|
</oaf:projectid>
|
147
|
</xsl:when>
|
148
|
<xsl:otherwise>
|
149
|
<oaf:projectid><xsl:value-of select="normalize-space(.)"/></oaf:projectid>
|
150
|
</xsl:otherwise>
|
151
|
</xsl:choose>
|
152
|
</xsl:for-each>
|
153
|
|
154
|
|
155
|
<oaf:hostedBy>
|
156
|
<xsl:attribute name="name">
|
157
|
<xsl:value-of select="$varOfficialName"/>
|
158
|
</xsl:attribute>
|
159
|
<xsl:attribute name="id">
|
160
|
<xsl:value-of select="$varDataSourceId"/>
|
161
|
</xsl:attribute>
|
162
|
</oaf:hostedBy>
|
163
|
<oaf:collectedFrom>
|
164
|
<xsl:attribute name="name">
|
165
|
<xsl:value-of select="$varOfficialName"/>
|
166
|
</xsl:attribute>
|
167
|
<xsl:attribute name="id">
|
168
|
<xsl:value-of select="$varDataSourceId"/>
|
169
|
</xsl:attribute>
|
170
|
</oaf:collectedFrom>
|
171
|
</metadata>
|
172
|
<xsl:copy-of select="//*[local-name() = 'about']"/>
|
173
|
</record>
|
174
|
</xsl:template>
|
175
|
<!--
|
176
|
<xsl:template match="//*[local-name()='language']">
|
177
|
<oaf:language>
|
178
|
<xsl:value-of select="TransformationFunction:convert($tf, //*[local-name()='language'], 'Languages')" />
|
179
|
</oaf:language>
|
180
|
</xsl:template>
|
181
|
-->
|
182
|
<xsl:template match="node() | @*">
|
183
|
<xsl:copy>
|
184
|
<xsl:apply-templates select="node() | @*"/>
|
185
|
</xsl:copy>
|
186
|
</xsl:template>
|
187
|
<xsl:template match="//*[local-name() = 'header']">
|
188
|
<xsl:copy>
|
189
|
<xsl:apply-templates select="node() | @*"/>
|
190
|
<xsl:element name="dr:dateOfTransformation">
|
191
|
<xsl:value-of select="$transDate"/>
|
192
|
</xsl:element>
|
193
|
</xsl:copy>
|
194
|
</xsl:template>
|
195
|
</xsl:stylesheet>
|
196
|
]]></CODE>
|
197
|
</SCRIPT>
|
198
|
</CONFIGURATION>
|
199
|
<STATUS/>
|
200
|
<SECURITY_PARAMETERS/>
|
201
|
</BODY>
|
202
|
</RESOURCE_PROFILE>
|