Project

General

Profile

1
<RESOURCE_PROFILE>
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER value="ee5c6497-b984-411d-9890-69bed2ae38c5_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
4
		<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
5
		<RESOURCE_KIND value="TransformationRuleDSResources"/>
6
		<RESOURCE_URI value=""/>
7
		<DATE_OF_CREATION value="2020-09-19T18:24:53+00:00"/>
8
	</HEADER>
9
	<BODY>
10
		<CONFIGURATION>
11
			<IMPORTED/>
12
			<SCRIPT>
13
				<TITLE>xslt_cleaning_datarepo_datacite_NAKALA</TITLE>
14
				<CODE>
15
					<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oaf="http://namespace.openaire.eu/oaf"
16
									xmlns:oai="http://www.openarchives.org/OAI/2.0/"
17
									xmlns:TransformationFunction="eu.dnetlib.data.collective.transformation.core.xsl.ext.TransformationFunctionProxy"
18
									xmlns:dr="http://www.driver-repository.eu/namespace/dr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19
									exclude-result-prefixes="TransformationFunction" extension-element-prefixes="TransformationFunction" version="1.1">
20
						<xsl:param name="varOfficialName"/>
21
						<xsl:param name="varDsType"/>
22
						<xsl:param name="varDataSourceId"/>
23
						<xsl:param name="index" select="0"/>
24
						<xsl:param name="transDate" select="current-dateTime()"/>
25
						<xsl:variable name="tf" select="TransformationFunction:getInstance()"/>
26
						<xsl:template match="/">
27
							<xsl:variable name="datasourcePrefix" select="normalize-space(//oaf:datasourceprefix)"/>
28
							<xsl:call-template name="validRecord"/>
29
						</xsl:template>
30
						<xsl:template name="terminate">
31
							<xsl:message terminate="yes">
32
								record is not compliant, transformation is interrupted.
33
							</xsl:message>
34
						</xsl:template>
35
						<xsl:template name="validRecord">
36
							<record>
37
								<xsl:apply-templates select="//*[local-name() = 'header']"/>
38
								<metadata>
39
									<xsl:apply-templates select="//*[local-name() = 'metadata']//*[local-name() = 'resource']"/><!-- for CoCoON many deleted records appeared among the transformed records -->
40
									<xsl:if test="//oai:header/@status='deleted'">
41
										<xsl:call-template name="terminate"/>
42
									</xsl:if>
43
									<xsl:for-each select="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='Handle'][not(. = '123456789')]">
44
										<oaf:identifier>
45
											<xsl:attribute name="identifierType">
46
												<xsl:value-of select="'handle'"/>
47
											</xsl:attribute>
48
											<xsl:if test="contains(., '://hdl.handle.net/')">
49
												<xsl:value-of select="substring-after(., '://hdl.handle.net/')"/>
50
											</xsl:if>
51
											<xsl:if test="not(contains(., '://hdl.handle.net/'))">
52
												<xsl:value-of select="."/>
53
											</xsl:if>
54
										</oaf:identifier>
55
									</xsl:for-each>
56
									<xsl:for-each select="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='DOI']">
57
										<oaf:identifier>
58
											<xsl:attribute name="identifierType">
59
												<xsl:value-of select="'doi'"/>
60
											</xsl:attribute>
61
											<xsl:if test="contains(., '://dx.doi.org/')">
62
												<xsl:value-of select="substring-after(., '://dx.doi.org/')"/>
63
											</xsl:if>
64
											<xsl:if test="not(contains(., '://dx.doi.org/'))">
65
												<xsl:value-of select="."/>
66
											</xsl:if>
67
										</oaf:identifier>
68
									</xsl:for-each>
69
									<!-- This is the only difference with the generic datacite repo rule: since all datasets from Nakala are Images -->
70
									<xsl:if
71
											test="lower-case(//*[local-name()='resourceType']/@*[local-name()='resourceTypeGeneral']) = 'image'">
72
										<oaf:concept>
73
											<xsl:attribute name="id">
74
												<xsl:value-of select="'dariah'"/>
75
											</xsl:attribute>
76
										</oaf:concept>
77
									</xsl:if>
78
									<xsl:if test="//*[local-name()='date']/@dateType='Available' and //*[local-name()='datasourceprefix']!='r33ffb097cef'">
79
										<xsl:variable name="varEmbargoEndDate" select="TransformationFunction:convertString($tf, normalize-space(//*[local-name()='date'][@dateType='Available']), 'DateISO8601')"/>
80
										<xsl:choose>
81
											<xsl:when test="string-length($varEmbargoEndDate) &gt; 0">
82
												<oaf:embargoenddate>
83
													<xsl:value-of select="$varEmbargoEndDate"/>
84
												</oaf:embargoenddate>
85
											</xsl:when>
86
											<xsl:otherwise>
87
												<xsl:call-template name="terminate"/>
88
											</xsl:otherwise>
89
										</xsl:choose>
90
									</xsl:if>
91
									<xsl:variable name="varTypLst" select="distinct-values((//*[local-name()='resourceType']/(., @resourceTypeGeneral)))"/>
92
									<xsl:variable name="varCobjCatLst" select="distinct-values((for $i in $varTypLst      return TransformationFunction:convertString($tf, normalize-space($i), 'TextTypologies')))"/>
93
									<xsl:variable name="varCobjSupLst" select="for $i in $varCobjCatLst      return concat($i, '###', TransformationFunction:convertString($tf, normalize-space($i), 'SuperTypes'))"/>
94
									<dr:CobjCategory>
95
										<xsl:choose>
96
											<xsl:when test="count($varCobjSupLst[not(substring-after(., '###') = 'other') and not(substring-before(., '###') = ('0038', '0039', '0040'))]) &gt; 0">
97
												<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-after(., '###') = 'other') and not(substring-before(., '###') = ('0038', '0039', '0040'))][1]"/>
98
												<xsl:attribute name="type" select="substring-after($varCobjSup, '###')"/>
99
												<xsl:value-of select="substring-before($varCobjSup, '###')"/>
100
											</xsl:when>
101
											<xsl:when test="count($varCobjSupLst[not(substring-after(., '###') = 'other')]) &gt; 0">
102
												<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-after(., '###') = 'other')][1]"/>
103
												<xsl:attribute name="type" select="substring-after($varCobjSup, '###')"/>
104
												<xsl:value-of select="substring-before($varCobjSup, '###')"/>
105
											</xsl:when>
106
											<xsl:when test="count($varCobjSupLst[not(substring-before(., '###') = ('0020', '0000'))]) &gt; 0">
107
												<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-before(., '###') = ('0020', '0000'))][1]"/>
108
												<xsl:attribute name="type" select="substring-after($varCobjSup, '###')"/>
109
												<xsl:value-of select="substring-before($varCobjSup, '###')"/>
110
											</xsl:when>
111
											<xsl:when test="count($varCobjSupLst[not(substring-before(., '###') = ('0000'))]) &gt; 0">
112
												<xsl:variable name="varCobjSup" select="$varCobjSupLst[not(substring-before(., '###') = ('0000'))][1]"/>
113
												<xsl:attribute name="type" select="substring-after($varCobjSup, '###')"/>
114
												<xsl:value-of select="substring-before($varCobjSup, '###')"/>
115
											</xsl:when>
116
											<xsl:otherwise>
117
												<xsl:attribute name="type" select="'other'"/>
118
												<xsl:value-of select="'0000'"/>
119
											</xsl:otherwise>
120
										</xsl:choose>
121
									</dr:CobjCategory><!-- review status --><!-- no review hints found in resource type declarations, no version declarations found -->
122
									<xsl:variable name="varRefereedConvt" select="for $i in (      //*[local-name()='resourceType']/(., @resourceTypeGeneral), //oai:setSpec, //*[local-name()='description'])      return TransformationFunction:convertString($tf, normalize-space($i), 'ReviewLevels')"/>
123
									<xsl:variable name="varRefereedIdntf" select="(      //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '(^|.*[\.\-_\\/\s\(\)%\d#:])pre[\.\-_\\/\s\(\)%\d#:]?prints?([\.\-_\\/\s\(\)%\d#:].*)?$')]/'0002',      //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '(^|.*[\.\-_\\/\s\(\)%\d#:])refereed([\.\-_\\/\s\(\)%\d#:].*)?$')]/'0001',      //*[local-name()=('identifier', 'alternateIdentifier')][count(//*[local-name()=('metadata', 'resource')]//*[local-name()=('identifier', 'alternateIdentifier')]) = 1][matches(lower-case(.), '.*-peer-reviewed-(fulltext-)?article-.*')]/'0001')"/>
124
									<xsl:variable name="varRefereedVersn" select="(//*[local-name()='version'][matches(lower-case(.), '.*peer[\s\-\.\\_/:%]?reviewed.*')]/'0001',      //*[local-name()='version'][matches(normalize-space(lower-case(.)), '^(v|vs|version|rel|release)?[\s\.\-_]*0$')]/'0002',      //*[local-name()='version'][matches(lower-case(.), '(^|[\s\-\.\\_/:%].*)(beta|draft|trial|test)([\s\-\.\\_/:%].*|$)')]/'0002',      //*[local-name()='version'][matches(lower-case(.), '.*submi(tted|ssion|ttal).*')]/'0002') "/>
125
									<xsl:variable name="varRefereedOther" select="(//*[local-name()='publisher'][matches(lower-case(.), '.*[\s\-\.\\_/:%]pre[\s\-\.\\_/:%]?prints?([\s\-\.\\_/:%].*|$)')]/'0002',      //*[local-name()='description'][matches(lower-case(.), '^peer[\s\-\.\\_/:%]?reviewed$')]/'0001',      //*[local-name()='description'][matches(lower-case(.), '^pre[\s\-\.\\_/:%]?prints?$')]/'0002') "/>
126
									<xsl:variable name="varRefereedReltn" select="//*[local-name() = 'relatedIdentifier'][./@relationType/lower-case(.)='isreviewedby']/'0001'"/>
127
									<xsl:variable name="varRefereedDesct" select="(//*[local-name() = 'description']      [matches(lower-case(.), '.*(this\s*book|this\s*volume|it)\s*constitutes\s*the\s*(thoroughly\s*)?refereed') or      matches(lower-case(.), '.*peer[\.\-_/\s\(\)]?review\s*under\s*responsibility\s*of.*') or      matches(lower-case(.), '(this|a)\s*(article|preprint)\s*(has\s*been\s*)?(peer[\-\s]*)?reviewed\s*and\s*recommended\s*by\s*peer[\-\s]*community')]/'0001')"/>
128
									<xsl:variable name="varRefereed" select="($varRefereedConvt, $varRefereedIdntf, $varRefereedReltn, $varRefereedVersn, $varRefereedOther, $varRefereedReltn, $varRefereedDesct)"/>
129
									<xsl:choose>
130
										<xsl:when test="count($varRefereed[. = '0001']) &gt; 0">
131
											<oaf:refereed>
132
												<xsl:value-of select="'0001'"/>
133
											</oaf:refereed>
134
										</xsl:when>
135
										<xsl:when test="count($varRefereed[. = '0002']) &gt; 0">
136
											<oaf:refereed>
137
												<xsl:value-of select="'0002'"/>
138
											</oaf:refereed>
139
										</xsl:when>
140
									</xsl:choose>
141
									<oaf:dateAccepted>
142
										<xsl:value-of select="TransformationFunction:convertString($tf, normalize-space(//*[local-name()='publicationYear']), 'DateISO8601')"/>
143
									</oaf:dateAccepted>
144
									<xsl:choose>
145
										<xsl:when test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
146
											<oaf:accessrights>
147
												<xsl:value-of select="TransformationFunction:convertString($tf, //*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'AccessRights')"/>
148
											</oaf:accessrights>
149
										</xsl:when>
150
										<xsl:otherwise>
151
											<xsl:choose>
152
												<xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'http://creativecommons.org') or starts-with(normalize-space(.), 'Creative Commons') or starts-with(normalize-space(.), 'GNU LESSER GENERAL PUBLIC LICENSE')]">
153
													<oaf:accessrights>
154
														<xsl:text>OPEN</xsl:text>
155
													</oaf:accessrights>
156
												</xsl:when>
157
												<xsl:when test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'http://creativecommons.org') or starts-with(normalize-space(.), 'http://opendatacommons.org')]">
158
													<oaf:accessrights>
159
														<xsl:text>OPEN</xsl:text>
160
													</oaf:accessrights>
161
												</xsl:when>
162
												<xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'Open access data at least for academic use')]">
163
													<oaf:accessrights>
164
														<xsl:text>RESTRICTED</xsl:text>
165
													</oaf:accessrights>
166
												</xsl:when>
167
												<xsl:otherwise>
168
													<oaf:accessrights>
169
														<xsl:text>UNKNOWN</xsl:text>
170
													</oaf:accessrights>
171
												</xsl:otherwise>
172
											</xsl:choose>
173
										</xsl:otherwise>
174
									</xsl:choose>
175
									<xsl:for-each select="//*[local-name()='rights']/@rightsURI[starts-with(normalize-space(.), 'http') and matches(., '.*(/licenses|/publicdomain|unlicense.org/|/legal-and-data-protection-notices|/download/license|/open-government-licence).*')]">
176
										<oaf:license>
177
											<xsl:value-of select="."/>
178
										</oaf:license>
179
									</xsl:for-each>
180
									<oaf:language>
181
										<xsl:value-of select="TransformationFunction:convert($tf, //*[local-name()='language'], 'Languages')"/>
182
									</oaf:language>
183
									<oaf:hostedBy>
184
										<xsl:attribute name="name">
185
											<xsl:value-of select="$varOfficialName"/>
186
										</xsl:attribute>
187
										<xsl:attribute name="id">
188
											<xsl:value-of select="$varDataSourceId"/>
189
										</xsl:attribute>
190
									</oaf:hostedBy>
191
									<oaf:collectedFrom>
192
										<xsl:attribute name="name">
193
											<xsl:value-of select="$varOfficialName"/>
194
										</xsl:attribute>
195
										<xsl:attribute name="id">
196
											<xsl:value-of select="$varDataSourceId"/>
197
										</xsl:attribute>
198
									</oaf:collectedFrom>
199
								</metadata>
200
								<xsl:copy-of select="//*[local-name() = 'about']"/>
201
							</record>
202
						</xsl:template>
203

    
204
						<xsl:template match="node()|@*">
205
							<xsl:copy>
206
								<xsl:apply-templates select="node()|@*"/>
207
							</xsl:copy>
208
						</xsl:template>
209

    
210
						<xsl:template match="//*[local-name() = 'metadata']//*[local-name() = 'resource']">
211
							<xsl:copy>
212
								<xsl:apply-templates select="node()|@*"/>
213
							</xsl:copy>
214
						</xsl:template>
215

    
216
						<xsl:template match="//*[local-name() = 'resource']/*[local-name()='identifier']">
217
							<xsl:if test=".[@identifierType='Handle'][contains(., '://hdl.handle.net/')]">
218
								<xsl:element name="identifier" namespace="http://datacite.org/schema/kernel-4">
219
									<xsl:attribute name="identifierType">
220
										<xsl:value-of select="'Handle'"/>
221
									</xsl:attribute>
222
									<xsl:value-of select="."/>
223
								</xsl:element>
224
							</xsl:if>
225
						</xsl:template>
226

    
227
						<xsl:template match="//*[local-name() = 'resource']/*[local-name()='alternateIdentifier']">
228
							<xsl:choose>
229
								<xsl:when test="@alternateIdentifierType">
230
									<xsl:copy-of select="."/>
231
								</xsl:when>
232
								<xsl:otherwise>
233
									<xsl:element name="alternateIdentifier" namespace="http://datacite.org/schema/kernel-4">
234
										<xsl:attribute name="alternateIdentifierType"><xsl:value-of select="./@identifierType"/></xsl:attribute>
235
										<xsl:value-of select="."/>
236
									</xsl:element>
237
								</xsl:otherwise>
238
							</xsl:choose>
239
						</xsl:template>
240

    
241

    
242
						<xsl:template match="//*[local-name() = 'header']">
243
							<xsl:copy>
244
								<xsl:apply-templates select="node()|@*"/>
245
								<xsl:element name="dr:dateOfTransformation">
246
									<xsl:value-of select="$transDate"/>
247
								</xsl:element>
248
							</xsl:copy>
249
						</xsl:template>
250
					</xsl:stylesheet>
251

    
252
				</CODE>
253
			</SCRIPT>
254
		</CONFIGURATION>
255
		<STATUS/>
256
		<SECURITY_PARAMETERS/>
257
	</BODY>
258
</RESOURCE_PROFILE>
(57-57/61)