Project

General

Profile

1
<!-- 
2
    (M): Mandatory
3
    (R): Reccomended
4
    (M w A): Mandatory when Applicable
5
-->
6
<xsl:stylesheet xmlns:dc="http://purl.org/dc/elements/1.1/"
7
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8
    xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
9
    xmlns:oaf="http://namespace.openaire.eu/oaf" version="2.0" exclude-result-prefixes="oaf">
10

    
11

    
12
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
13

    
14
    <xsl:variable name="openaireNamespace" select="string('oai:dnet:')"/>
15

    
16
    <xsl:template match="//oaf:entity">
17
        <oai_dc:dc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18
            xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
19
            <xsl:apply-templates/>
20
        </oai_dc:dc>
21
    </xsl:template>
22

    
23
    <!-- 
24
       Titles (M): based on title/@classname
25
        <dc:title>main title:subtitle</dc:title>
26
        <dc:title>alternative title</dc:title>
27
        <dc:title>translated title</dc:title>
28
        
29
        We have only "main title" for now: let's keep it simple here...
30
   -->
31
    <xsl:template match="oaf:result/title">
32
        <dc:title>
33
            <xsl:value-of select="normalize-space(./text())"/>
34
        </dc:title>
35
    </xsl:template>
36

    
37
    <!-- Creators (M) -->
38
    <xsl:template match="oaf:result//rel[./to/@class='hasAuthor']">
39
        <dc:creator>
40
            <xsl:value-of select="./fullname"/>
41
        </dc:creator>
42
    </xsl:template>
43

    
44
    <!-- Contributors (R) not currently available-->
45
    <xsl:template match="oaf:result//rel[./to/@class='hasContributor']">
46
        <dc:contributor>
47
            <xsl:value-of select="./fullname"/>
48
        </dc:contributor>
49
    </xsl:template>
50

    
51
    <!--
52
        projectId (M w A)
53
        <dc:relation>info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID/[Jurisdiction]/[ProjectName]/[ProjectAcronym]</dc:relation>
54
        <dc:relation>info:eu-repo/grantAgreement/EC/FP7/12345//The project name/ACRO</dc:relation>
55
        <dc:relation>info:eu-repo/grantAgreement/EC/FP7/67891/EU/The 2nd project name/ACRO2</dc:relation>
56
        
57
        The rel to project:
58
         <rel>
59
            <to scheme="dnet:result_project_relations" class="isProducedBy" type="project">project_openaireid</to>
60
            <code>249516</code>
61
            <acronym>VOICE</acronym>
62
            <title>xxx</title>
63
            <contracttype schemename="ec:FP7contractTypes" classname="aaa" schemeid="ec:FP7contractTypes" classid="aaa"/>
64
             <funding>
65
                <funding_level_0>FP7</funding_level_0>
66
                <funding_level_1>FP7::SP2</funding_level_1>
67
                <funding_level_2>FP7::SP2::ERC</funding_level_2>
68
             </funding>
69
        </rel>
70
        
71
        The funding program is funding_level_0.
72
        The funder must be inferred from the contract type - until the Funders won't be added explicitely in the record.
73
    -->
74
    <xsl:template match="oaf:result//rel[./to/@class='isProducedBy']">
75
        <xsl:variable name="funder">
76
            <xsl:choose>
77
                <xsl:when test="./contracttype/@schemeid = 'ec:FP7contractTypes'">
78
                    <xsl:value-of select="string('EC')"/>
79
                </xsl:when>
80
                <xsl:when test="./contracttype/@schemeid = 'wt:contractTypes'">
81
                    <xsl:value-of select="string('WT')"/>
82
                </xsl:when>
83
                <xsl:when test="./contracttype/@schemeid = 'fct:contractTypes'">
84
                    <xsl:value-of select="string('FCT')"/>
85
                </xsl:when>
86
            </xsl:choose>
87
        </xsl:variable>
88
        <xsl:variable name="fundingProgramme">
89
            <xsl:choose>
90
                <xsl:when test="$funder = 'EC'">
91
                    <xsl:value-of select="./funding/funding_level_0"/>
92
                </xsl:when>
93
                <xsl:when test="$funder = 'WT'">
94
                    <xsl:value-of select="substring-after(./funding_level_1/text(), 'WT::')"/>
95
                </xsl:when>
96
                <xsl:when test="$funder = 'FCT'">
97
                    <xsl:value-of select="substring-after(./funding_level_1/text(), 'FCT::')"/>
98
                </xsl:when>
99
            </xsl:choose>
100
        </xsl:variable>
101
        <xsl:variable name="jurisdiction">
102
            <xsl:choose>
103
                <xsl:when test="$funder = 'EC'">
104
                    <xsl:value-of select="string('EU')"/>
105
                </xsl:when>
106
                <xsl:when test="$funder = 'WT'">
107
                    <xsl:value-of select="string('')"/>
108
                </xsl:when>
109
                <xsl:when test="$funder = 'FCT'">
110
                    <xsl:value-of select="string('PT')"/>
111
                </xsl:when>
112
                <xsl:otherwise/>
113
            </xsl:choose>
114
        </xsl:variable>
115
        <dc:relation>
116
            <xsl:value-of
117
                select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/', ./code, '/', $jurisdiction, '/' , ./title, '/', ./acronym)"
118
            />
119
        </dc:relation>
120
    </xsl:template>
121

    
122
    <!-- 
123
        Access level (M) [from bestlicense@classid] : one of 
124
        <dc:rights>info:eu-repo/semantics/closedAccess</dc:rights>
125
        <dc:rights>info:eu-repo/semantics/embargoedAccess</dc:rights>
126
        <dc:rights>info:eu-repo/semantics/restrictedAccess</dc:rights>
127
        <dc:rights>info:eu-repo/semantics/openAccess</dc:rights>
128
    -->
129
    <xsl:template match="oaf:result/bestlicense">
130
        <xsl:variable name="license">
131
            <xsl:choose>
132
                <xsl:when test="@classid='OPEN'">
133
                    <xsl:value-of select="string('info:eu-repo/semantics/openAccess')"/>
134
                </xsl:when>
135
                <xsl:when test="@classid='CLOSED'">
136
                    <xsl:value-of select="string('info:eu-repo/semantics/closedAccess')"/>
137
                </xsl:when>
138
                <xsl:when test="@classid='RESTRICTED'">
139
                    <xsl:value-of select="string('info:eu-repo/semantics/restrictedAccess')"/>
140
                </xsl:when>
141
                <xsl:when test="@classid='EMBARGO'">
142
                    <xsl:value-of select="string('info:eu-repo/semantics/embargoedAccess')"/>
143
                </xsl:when>
144
                <xsl:otherwise>
145
                    <xsl:value-of select="string('info:eu-repo/semantics/closedAccess')"/>
146
                </xsl:otherwise>
147
            </xsl:choose>
148
        </xsl:variable>
149
        <dc:rights>
150
            <xsl:value-of select="$license"/>
151
        </dc:rights>
152
    </xsl:template>
153

    
154
    <!-- EmbargoEnd (M w A)  (only when rights == info:eu-repo/semantics/embargoedAccess), from embargoenddate
155
    <dc:date>info:eu-repo/date/embargoEnd/1960-01-01</dc:date>
156
     -->
157
    <xsl:template match="oaf:result/embargoenddate/text()">
158
        <dc:date>
159
            <xsl:value-of select="concat('info:eu-repo/date/embargoEnd/', .)"/>
160
        </dc:date>
161
    </xsl:template>
162

    
163

    
164
    <!--
165
    <xsl:template match="oaf:result/originalId/text()">
166
        <dc:identifier>
167
            <xsl:value-of select="normalize-space(.)"/>
168
        </dc:identifier>
169
    </xsl:template>
170
    -->
171

    
172
    <!-- Alternative Identifier (R), idType from pid@classid  
173
    <dc:relation>
174
        info:eu-repo/semantics/altIdentifier/[idType]/[ID]
175
    </dc:relation>
176
    -->
177
    <xsl:template match="oaf:result/pid[./text()]">
178
        <dc:relation>
179
            <xsl:value-of
180
                select="concat('info:eu-repo/semantics/altIdentifier/', @classid, '/', ./text())"/>
181
        </dc:relation>
182
    </xsl:template>
183

    
184
    <xsl:template match="oaf:result/children/instance/webresource/url/text()">
185
        <dc:identifier>
186
            <xsl:value-of select="."/>
187
        </dc:identifier>
188
    </xsl:template>
189
    <!--Referenced Publication (R), from extraInfo[@typology='citations']/citation, idType from citation/id/@type, ID from citation/id/@value
190
    <dc:relation>
191
        info:eu-repo/semantics/reference/[idType]/[ID]
192
    </dc:relation>
193
    <dc:relation>
194
        info:eu-repo/semantics/reference/doi/10.1234/789.1
195
    </dc:relation>
196
    <dc:relation>
197
        info:eu-repo/semantics/reference/pmid/1234567
198
    </dc:relation>
199
     -->
200
    <xsl:template match="extraInfo[@typology='citations']//citation/id[./@type]">
201
        <xsl:choose>
202
            <xsl:when test="@type='openaire'">
203
                <dc:relation>
204
                    <xsl:value-of
205
                        select="concat('info:eu-repo/semantics/reference/', @type, '/', $openaireNamespace, @value)"
206
                    />
207
                </dc:relation>
208

    
209
            </xsl:when>
210
            <xsl:otherwise>
211
                <dc:relation>
212
                    <xsl:value-of
213
                        select="concat('info:eu-repo/semantics/reference/', @type, '/', @value)"/>
214
                </dc:relation>
215
            </xsl:otherwise>
216
        </xsl:choose>
217

    
218
    </xsl:template>
219

    
220
    <!-- Dataset reference (R), from: rel[./resulttyype/@classname='dataset'] 
221
    <dc:relation>info:eu-repo/semantics/dataset/[idType]/[ID]</dc:relation>
222
    only available when we'll expand the PIDs in the relationship 
223
    <dc:relation>info:eu-repo/semantics/dataset/doi/10.1234/789.1</dc:relation>
224
    For now we can only use openaire ids, from  rel[./resulttyype/@classname='dataset']/to/text()
225
    <dc:relation>info:eu-repo/semantics/dataset/openaire/oai:dnet:[OPENAIRE_ID]</dc:relation>
226
    -->
227
    <xsl:template match="oaf:result//rel[./resulttype/@classid='dataset']">
228
        <dc:relation>
229
            <xsl:value-of
230
                select="concat('info:eu-repo/semantics/dataset/openaire/', $openaireNamespace, ./to/text())"
231
            />
232
        </dc:relation>
233
    </xsl:template>
234

    
235

    
236
    <!-- Subjects (M w A)
237
    <dc:subject>bag of words</dc:subject>
238
     If subject@classname != keywords, then we have a classification scheme to encode
239
    <dc:subject>info:eu-repo/classification/[scheme]/[value]</dc:subject>
240
    <dc:subject>info:eu-repo/classification/dcc/whatever</dc:subject>
241
    -->
242
    <xsl:template match="oaf:result/subject[@classname='keyword']">
243
        <dc:subject>
244
            <xsl:value-of select="normalize-space(./text())"/>
245
        </dc:subject>
246
    </xsl:template>
247
    <xsl:template match="oaf:result/subject[not(@classname='keyword') and @classid != '']">
248
        <dc:subject>
249
            <xsl:value-of
250
                select="concat('info:eu-repo/classification/', @classid, '/', normalize-space(./text()))"
251
            />
252
        </dc:subject>
253
    </xsl:template>
254

    
255
    <!--description (M w A) from description-->
256
    <xsl:template match="oaf:result/description/text()">
257
        <dc:description>
258
            <xsl:value-of select="normalize-space(.)"/>
259
        </dc:description>
260
    </xsl:template>
261
    <!--publisher (M w A) from publisher -->
262
    <xsl:template match="oaf:result/publisher/text()">
263
        <dc:publisher>
264
            <xsl:value-of select="normalize-space(.)"/>
265
        </dc:publisher>
266
    </xsl:template>
267
    <!-- Publication date (M) from dateofacceptance -->
268
    <xsl:template match="oaf:result/dateofacceptance/text()">
269
        <dc:date>
270
            <xsl:value-of select="normalize-space(.)"/>
271
        </dc:date>
272
    </xsl:template>
273

    
274
    <!-- 
275
        Publication type (M)  where [type] is /instancetype[1]/classname (dnet:publication_resource vocabulary). 
276
        A second dc:type (uncontrolled) can be used. 
277
        <dc:type>info:eu-repo/semantics/[type]</dc:type>
278
    -->
279
    <xsl:template match="oaf:result/children/instance/instancetype | oaf:result/resourcetype">
280
        <xsl:variable name="theInstanceType">
281
            <xsl:choose>
282
                <xsl:when test="@classname='Unknown'">
283
                    <xsl:value-of select="string('info:eu-repo/semantics/other')"/>
284
                </xsl:when>
285
                <xsl:when test="@classname=''">
286
                    <xsl:value-of select="string('info:eu-repo/semantics/other')"/>
287
                </xsl:when>
288
                <xsl:otherwise>
289
                    <xsl:call-template name="ConvertWordsToCamelCase">
290
                        <xsl:with-param name="text">
291
                            <xsl:value-of select="lower-case(./@classname)"/>
292
                        </xsl:with-param>
293
                    </xsl:call-template>
294
                </xsl:otherwise>
295
            </xsl:choose>
296

    
297
        </xsl:variable>
298
        <dc:type>
299
            <xsl:value-of select="concat('info:eu-repo/semantics/',$theInstanceType)"/>
300
        </dc:type>
301
    </xsl:template>
302
    <!--
303
    <xsl:template match="oaf:result/resulttype">
304
        <dc:type>
305
            <xsl:value-of select="./@classname"/>
306
        </dc:type>
307
    </xsl:template>
308
    -->
309

    
310
    <!-- Format (R), in theory from format, not sure we are filling it
311
    <dc:format>mediaType of the digital manifestation of the resource</dc:format>
312
    <dc:format>application/pdf</dc:format>
313
    -->
314
    <xsl:template match="oaf:result/format/text()">
315
        <dc:format>
316
            <xsl:value-of select="normalize-space(.)"/>
317
        </dc:format>
318
    </xsl:template>
319

    
320
    <!-- source (R) from source-->
321
    <xsl:template match="oaf:result/source/text()">
322
        <dc:source>
323
            <xsl:value-of select="normalize-space(.)"/>
324
        </dc:source>
325
    </xsl:template>
326

    
327
    <xsl:template match="oaf:result/collectedfrom">
328
        <dc:source>
329
            <xsl:value-of select="normalize-space(@name)"/>
330
        </dc:source>
331
    </xsl:template>
332

    
333
    <!-- Language (R) from language@classid -->
334
    <xsl:template match="oaf:result/language">
335
        <dc:language>
336
            <xsl:value-of select="./@classid"/>
337
        </dc:language>
338
    </xsl:template>
339

    
340
    <!-- Override default template -->
341
    <xsl:template match="text()|@*"/>
342

    
343
    <!-- =========================================================================== -->
344
    <!-- === Convert camel case text to cameCaseText  === -->
345
    <!-- === Modified from http://blog.inventic.eu/2013/08/xslt-snippet-to-convert-string-from-hyphens-to-camelcase/  === -->
346
    <!-- === (c) Inventic s.r.o. ORM Designer team (http://www.orm-designer.com) === -->
347
    <!-- =========================================================================== -->
348
    <xsl:template name="ConvertWordsToCamelCase">
349
        <xsl:param name="text"/>
350
        <xsl:param name="firstLower" select="true()"/>
351

    
352
        <xsl:variable name="Upper">ABCDEFGHIJKLMNOPQRSTUVQXYZ</xsl:variable>
353
        <xsl:variable name="Lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
354

    
355
        <xsl:for-each select="tokenize($text,' ')">
356
            <xsl:choose>
357
                <xsl:when test="position()=1 and $firstLower = true()">
358
                    <xsl:value-of select="substring(.,1,1)"/>
359
                </xsl:when>
360
                <xsl:otherwise>
361
                    <xsl:value-of select="translate(substring(.,1,1),$Lower,$Upper)"/>
362
                </xsl:otherwise>
363
            </xsl:choose>
364
            <xsl:value-of select="substring(.,2,string-length(.))"/>
365
        </xsl:for-each>
366
    </xsl:template>
367

    
368
</xsl:stylesheet>
(3-3/3)