Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<RESOURCE_PROFILE>
3
    <HEADER>
4
        <RESOURCE_IDENTIFIER value="754faf14-fe72-46b3-a219-e0423f8bb732_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
5
        <RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
6
        <RESOURCE_KIND value="TransformationRuleDSResources"/>
7
        <RESOURCE_URI value=""/>
8
        <DATE_OF_CREATION value="2014-01-08T23:27:01+01:00"/>
9
    </HEADER>
10
    <BODY>
11
        <CONFIGURATION>
12
            <IMPORTED/>
13
            <SCRIPT>
14
                <TITLE>xslt_cleaning_datacite</TITLE>
15
                <CODE><![CDATA[
16
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1"
17
 		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18
                xmlns:oaf="http://namespace.openaire.eu/oaf"
19
                xmlns:dr="http://www.driver-repository.eu/namespace/dr"
20
        	xmlns:TransformationFunction="eu.dnetlib.data.collective.transformation.core.xsl.ext.TransformationFunctionProxy"
21
                extension-element-prefixes="TransformationFunction"
22
                exclude-result-prefixes="TransformationFunction">
23

    
24
  <xsl:param name="varOfficialName" />
25
  <xsl:param name="varDsType" />
26
  <xsl:param name="varDataSourceId" />
27
  <xsl:param name="varFP7" select="'corda_______::'"/>
28
  <xsl:param name="varH2020" select="'corda__h2020::'"/>
29
  <xsl:param name="varHostedByOfficialName" select="'Unknown Repository'"/>
30
  <xsl:param name="varHostedByDataSourceId" select="'openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18'"/>
31

    
32
  <xsl:param name="index" select="0"/>
33
  <xsl:param name="transDate" select="current-dateTime()"/>
34
  <xsl:variable name="tf" select="TransformationFunction:getInstance()"/>
35

    
36

    
37
  <xsl:template match="/">
38
    <xsl:variable name="datasourcePrefix"
39
             select="normalize-space(//oaf:datasourceprefix)" />
40

    
41
        <xsl:if test="not(//*[local-name()='title'][string-length(.)> 0]) or (//*[local-name()='resourceType'][lower-case(.)='article'] or not(lower-case(//*[local-name()='resourceType']/@resourceTypeGeneral)=('dataset', 'software', 'collection', 'film', 'sound', 'physicalobject', 'audiovisual') or //*[local-name()='resourceType'][@resourceTypeGeneral='Other' and .='Study']))">
42
              <xsl:call-template name="terminate"/>
43
         </xsl:if>
44

    
45

    
46
    <xsl:call-template name="validRecord" />
47
  </xsl:template>
48

    
49
 <xsl:template name="terminate">
50
  	<xsl:message terminate="yes">
51
  	record is not compliant, transformation is interrupted.
52
  	</xsl:message>
53
  </xsl:template>
54

    
55
  <xsl:template name="validRecord">
56
    <record>
57
      <xsl:apply-templates select="//*[local-name() = 'header']" />
58

    
59
      <metadata>
60

    
61
        <xsl:apply-templates select="//*[local-name() = 'metadata']/*[local-name() = 'resource']"/>
62

    
63
<!--
64
           <xsl:when test="not(//*[local-name()='resourceType'][lower-case(.)='article']) and lower-case(//*[local-name()='resourceType']/@resourceTypeGeneral)=('dataset', 'software', 'collection', 'film', 'sound', 'physicalobject', 'audiovisual') or //*[local-name()='resourceType'][@resourceTypeGeneral='Other' and .='Study']">
65
-->
66

    
67
             <dr:CobjCategory>
68
               <xsl:value-of
69
                     select="TransformationFunction:convertString($tf, //*[local-name()='resourceType']/@resourceTypeGeneral, 'TextTypologies')" />
70
             </dr:CobjCategory>
71

    
72
<!--
73
           </xsl:when>
74
           <xsl:otherwise>
75
                <xsl:call-template name="terminate"/>
76
           </xsl:otherwise>
77
         </xsl:choose>
78

    
79
        <xsl:if test="not(//*[local-name()='title'][string-length(.)> 0])">
80
              <xsl:call-template name="terminate"/>
81
         </xsl:if>
82
-->
83

    
84
         <xsl:if test="//*[local-name()='date']/@dateType='Available'">
85
            <xsl:variable name='varEmbargoEndDate'
86
                select="TransformationFunction:convertString($tf, normalize-space(//*[local-name()='date'][@dateType='Available']), 'DateISO8601')"/>
87
            <xsl:choose>
88
              <xsl:when test="string-length($varEmbargoEndDate) > 0">
89
                <oaf:embargoenddate>
90
                  <xsl:value-of select="$varEmbargoEndDate"/>
91
                </oaf:embargoenddate>
92
              </xsl:when>
93
              <xsl:otherwise>
94
                <xsl:call-template name="terminate"/>
95
              </xsl:otherwise>
96
            </xsl:choose>
97
         </xsl:if>
98

    
99

    
100
         <oaf:dateAccepted>
101
               <xsl:value-of select="TransformationFunction:convertString($tf, normalize-space(//*[local-name()='publicationYear']), 'DateISO8601')"/>
102
         </oaf:dateAccepted>
103

    
104
<!--
105
    <xsl:if test="//*[local-name() = 'datasourceprefix'][.='r310e4cd113d'] and not(boolean(//*[local-name() = 'rights']/@rightsURI ) )]">
106
                <xsl:call-template name="terminate"/>
107
    </xsl:if>
108
-->
109

    
110
            <xsl:choose>
111
          <xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics')][1]">
112
             <oaf:accessrights>
113
                <xsl:value-of select="TransformationFunction:convertString($tf, //*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics')][1], 'AccessRights')"/>
114
             </oaf:accessrights>
115
          </xsl:when>
116
<!--          <xsl:when test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')]">
117
             <oaf:accessrights>
118
                <xsl:value-of select="TransformationFunction:convertString($tf, //*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'info:eu-repo/semantics')], 'AccessRights')"/>
119
             </oaf:accessrights>
120
          </xsl:when>
121
-->
122
          <xsl:otherwise>
123
          <xsl:choose>
124
           <xsl:when test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'http://creativecommons.org') or starts-with(normalize-space(.), 'Creative Commons')]">
125
              <oaf:accessrights>
126
                 <xsl:text>OPEN</xsl:text>
127
              </oaf:accessrights>
128
            </xsl:when>
129
            <xsl:when test="//*[local-name() = 'rights']/@rightsURI[starts-with(normalize-space(.), 'http://creativecommons.org') or starts-with(normalize-space(.), 'http://opendatacommons.org')]">
130
             <oaf:accessrights>
131
                 <xsl:text>OPEN</xsl:text>
132
             </oaf:accessrights>
133
            </xsl:when>
134
            <xsl:otherwise>
135
              <oaf:accessrights>
136
                 <xsl:text>UNKNOWN</xsl:text>
137
              </oaf:accessrights>
138
            </xsl:otherwise>
139
          </xsl:choose>
140
         </xsl:otherwise>
141
        </xsl:choose>
142

    
143
         <oaf:language>
144
           <xsl:value-of select="TransformationFunction:convert($tf, //*[local-name()='language'], 'Languages')" />
145
         </oaf:language>
146

    
147
<!--
148
    <xsl:if test="//*[local-name() = 'rights'][starts-with(normalize-space(.), 'info:eu-repo/semantics/embargoedAccess')]">
149
        <oaf:embargoenddate>
150
          <xsl:value-of select="//*[local-name()='date']/@dateType='Available'"/>
151
        </oaf:embargoenddate>
152
    </xsl:if>
153
-->
154

    
155
         <xsl:for-each select="//*[local-name()='nameIdentifier']">
156
            <xsl:if test="matches(normalize-space(.), '(info:eu-repo/grantagreement/ec/fp7/)(\d\d\d\d\d\d)(.*)', 'i')">
157
                <oaf:projectid>
158
                    <xsl:value-of select="concat($varFP7, replace(normalize-space(.), '(info:eu-repo/grantagreement/ec/fp7/)(\d\d\d\d\d\d)(.*)', '$2', 'i'))"/>
159
                </oaf:projectid>
160
            </xsl:if>
161
            <xsl:if test="matches(normalize-space(.), '(info:eu-repo/grantagreement/ec/h2020/)(\d\d\d\d\d\d)(.*)', 'i')">
162
                <oaf:projectid>
163
                    <xsl:value-of select="concat($varH2020, replace(normalize-space(.), '(info:eu-repo/grantagreement/ec/h2020/)(\d\d\d\d\d\d)(.*)', '$2', 'i'))"/>
164
                </oaf:projectid>
165
            </xsl:if>
166
         </xsl:for-each>
167

    
168
         <oaf:hostedBy>
169
            <xsl:attribute name="name">
170
               <xsl:value-of select="$varHostedByOfficialName"/>
171
            </xsl:attribute>
172
            <xsl:attribute name="id">
173
               <xsl:value-of select="$varHostedByDataSourceId"/>
174
            </xsl:attribute>
175
         </oaf:hostedBy>
176
         <oaf:collectedFrom>
177
            <xsl:attribute name="name">
178
               <xsl:value-of select="$varOfficialName"/>
179
            </xsl:attribute>
180
            <xsl:attribute name="id">
181
               <xsl:value-of select="$varDataSourceId"/>
182
            </xsl:attribute>
183
         </oaf:collectedFrom>
184
      </metadata>
185
      <xsl:copy-of select="//*[local-name() = 'about']" />
186
   </record>
187
  </xsl:template>
188

    
189
<xsl:template match="node()|@*">
190
     <xsl:copy>
191
       <xsl:apply-templates select="node()|@*"/>
192
     </xsl:copy>
193
 </xsl:template>
194

    
195
  <xsl:template match="//*[local-name() = 'metadata']//*[local-name() = 'resource']">
196
    <xsl:copy>
197
       <xsl:apply-templates select="node()|@*"/>
198
     </xsl:copy>
199
  </xsl:template>
200

    
201
  <xsl:template match="//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers']">
202
      <xsl:element name="alternateIdentifiers" namespace="http://www.openarchives.org/OAI/2.0/">
203

    
204
     <xsl:copy-of select="./*"/>
205

    
206
    <xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='Handle']">
207
      <xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
208
          <xsl:attribute name="alternateIdentifierType">
209
             <xsl:value-of select="'URL'"/>
210
          </xsl:attribute>
211
              <xsl:value-of
212
                  select="concat('http://hdl.handle.net/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
213
      </xsl:element>
214
    </xsl:if>
215

    
216
    <xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='URN']">
217
      <xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
218
          <xsl:attribute name="alternateIdentifierType">
219
             <xsl:value-of select="'URL'"/>
220
          </xsl:attribute>
221
              <xsl:value-of
222
                  select="concat('http://nbn-resolving.org/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
223
      </xsl:element>
224
    </xsl:if>
225

    
226
    <xsl:if test="//*[local-name() = 'resource']/*[local-name()='identifier'][@identifierType='DOI']">
227
      <xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
228
          <xsl:attribute name="alternateIdentifierType">
229
             <xsl:value-of select="'URL'"/>
230
          </xsl:attribute>
231
              <xsl:value-of
232
                  select="concat('http://dx.doi.org/', //*[local-name() = 'resource']/*[local-name()='identifier'])" />
233
      </xsl:element>
234
    </xsl:if>
235

    
236
      </xsl:element>
237

    
238
  </xsl:template>
239

    
240
  <xsl:template match="//*[local-name() = 'resource']/*[local-name()='identifier']">
241
     <xsl:copy-of select="."/>
242
    <xsl:if test="not(//*[local-name() = 'resource']/*[local-name()='alternateIdentifiers'])">
243
      <xsl:element name="alternateIdentifiers" namespace="http://www.openarchives.org/OAI/2.0/">
244
    <xsl:if test=".[@identifierType='Handle']">
245
    <xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
246
        <xsl:attribute name="alternateIdentifierType">
247
           <xsl:value-of select="'URL'"/>
248
        </xsl:attribute>
249
            <xsl:value-of
250
                select="concat('http://hdl.handle.net/', .)" />
251
    </xsl:element>
252
    </xsl:if>
253
    <xsl:if test=".[@identifierType='URN']">
254
    <xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
255
        <xsl:attribute name="alternateIdentifierType">
256
           <xsl:value-of select="'URL'"/>
257
        </xsl:attribute>
258
            <xsl:value-of
259
                select="concat('http://nbn-resolving.org/', .)" />
260
    </xsl:element>
261
    </xsl:if>
262
    <xsl:if test=".[@identifierType='DOI']">
263
    <xsl:element name="alternateIdentifier" namespace="http://www.openarchives.org/OAI/2.0/">
264
        <xsl:attribute name="alternateIdentifierType">
265
           <xsl:value-of select="'URL'"/>
266
        </xsl:attribute>
267
            <xsl:value-of
268
                select="concat('http://dx.doi.org/', .)" />
269
    </xsl:element>
270
    </xsl:if>
271

    
272
    </xsl:element>
273
    </xsl:if>
274

    
275

    
276
  </xsl:template>
277

    
278
                       <xsl:template match="//*[local-name() = 'header']">
279
<xsl:copy>
280
     <xsl:apply-templates  select="node()|@*"/>
281
                             <xsl:element name="dr:dateOfTransformation">
282
                                 <xsl:value-of select="$transDate"/>
283
                             </xsl:element>
284
  </xsl:copy>
285
                        </xsl:template>
286

    
287
</xsl:stylesheet>
288
]]></CODE>
289
            </SCRIPT>
290
        </CONFIGURATION>
291
        <STATUS/>
292
        <SECURITY_PARAMETERS/>
293
    </BODY>
294
</RESOURCE_PROFILE>
295

    
(1-1/54)