Project

General

Profile

1 34642 alessia.ba
<!--
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 28030 alessia.ba
    xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
9 34866 alessia.ba
    xmlns:oaf="http://namespace.openaire.eu/oaf" version="2.0" exclude-result-prefixes="oaf">
10 28030 alessia.ba
11 34642 alessia.ba
12 28030 alessia.ba
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
13
14 34866 alessia.ba
    <xsl:variable name="openaireNamespace" select="string('oai:dnet:')"/>
15 34903 alessia.ba
16 34642 alessia.ba
    <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 28030 alessia.ba
            <xsl:apply-templates/>
20
        </oai_dc:dc>
21
    </xsl:template>
22
23 34642 alessia.ba
    <!--
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 28030 alessia.ba
    </xsl:template>
36 34866 alessia.ba
37 34642 alessia.ba
    <!-- 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 28030 alessia.ba
    </xsl:template>
43 34866 alessia.ba
44 34642 alessia.ba
    <!-- 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 28030 alessia.ba
    </xsl:template>
50 34866 alessia.ba
51 34642 alessia.ba
    <!--
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 34866 alessia.ba
                <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 34642 alessia.ba
            </xsl:choose>
87
        </xsl:variable>
88
        <xsl:variable name="fundingProgramme">
89
            <xsl:choose>
90 34866 alessia.ba
                <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 34642 alessia.ba
            </xsl:choose>
100
        </xsl:variable>
101
        <xsl:variable name="jurisdiction">
102
            <xsl:choose>
103 34866 alessia.ba
                <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 34642 alessia.ba
                <xsl:otherwise/>
113
            </xsl:choose>
114
        </xsl:variable>
115
        <dc:relation>
116 34866 alessia.ba
            <xsl:value-of
117
                select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/', ./code, '/', $jurisdiction, '/' , ./title, '/', ./acronym)"
118
            />
119 34642 alessia.ba
        </dc:relation>
120 28030 alessia.ba
    </xsl:template>
121 34866 alessia.ba
122 34642 alessia.ba
    <!--
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 34866 alessia.ba
            <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 34892 alessia.ba
                    <xsl:value-of select="string('info:eu-repo/semantics/closedAccess')"/>
146 34866 alessia.ba
                </xsl:otherwise>
147
            </xsl:choose>
148 34642 alessia.ba
        </xsl:variable>
149
        <dc:rights>
150
            <xsl:value-of select="$license"/>
151
        </dc:rights>
152 28030 alessia.ba
    </xsl:template>
153 34866 alessia.ba
154 34642 alessia.ba
    <!-- 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 28030 alessia.ba
    </xsl:template>
162 34866 alessia.ba
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 34642 alessia.ba
    <!-- Alternative Identifier (R), idType from pid@classid
173
    <dc:relation>
174
        info:eu-repo/semantics/altIdentifier/[idType]/[ID]
175
    </dc:relation>
176
    -->
177 34866 alessia.ba
    <xsl:template match="oaf:result/pid[./text()]">
178 34642 alessia.ba
        <dc:relation>
179 34866 alessia.ba
            <xsl:value-of
180
                select="concat('info:eu-repo/semantics/altIdentifier/', @classid, '/', ./text())"/>
181 34642 alessia.ba
        </dc:relation>
182 28030 alessia.ba
    </xsl:template>
183 34866 alessia.ba
184
    <xsl:template match="oaf:result/children/instance/webresource/url/text()">
185
        <dc:identifier>
186 34642 alessia.ba
            <xsl:value-of select="."/>
187 34866 alessia.ba
        </dc:identifier>
188 28030 alessia.ba
    </xsl:template>
189 34642 alessia.ba
    <!--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 34903 alessia.ba
    <xsl:template match="extraInfo[@typology='citations']//citation/id[./@type]">
201 34642 alessia.ba
        <xsl:choose>
202
            <xsl:when test="@type='openaire'">
203
                <dc:relation>
204 34866 alessia.ba
                    <xsl:value-of
205
                        select="concat('info:eu-repo/semantics/reference/', @type, '/', $openaireNamespace, @value)"
206
                    />
207 34642 alessia.ba
                </dc:relation>
208 34866 alessia.ba
209 34642 alessia.ba
            </xsl:when>
210
            <xsl:otherwise>
211
                <dc:relation>
212 34866 alessia.ba
                    <xsl:value-of
213
                        select="concat('info:eu-repo/semantics/reference/', @type, '/', @value)"/>
214 34642 alessia.ba
                </dc:relation>
215
            </xsl:otherwise>
216
        </xsl:choose>
217 34866 alessia.ba
218 28030 alessia.ba
    </xsl:template>
219 34866 alessia.ba
220 34642 alessia.ba
    <!-- 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 34866 alessia.ba
            <xsl:value-of
230
                select="concat('info:eu-repo/semantics/dataset/openaire/', $openaireNamespace, ./to/text())"
231
            />
232 34642 alessia.ba
        </dc:relation>
233 28030 alessia.ba
    </xsl:template>
234 34866 alessia.ba
235
236 34642 alessia.ba
    <!-- 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 28030 alessia.ba
    </xsl:template>
247 34866 alessia.ba
    <xsl:template match="oaf:result/subject[not(@classname='keyword') and @classid != '']">
248 34642 alessia.ba
        <dc:subject>
249 34866 alessia.ba
            <xsl:value-of
250
                select="concat('info:eu-repo/classification/', @classid, '/', normalize-space(./text()))"
251
            />
252 34642 alessia.ba
        </dc:subject>
253 28030 alessia.ba
    </xsl:template>
254 34866 alessia.ba
255 34642 alessia.ba
    <!--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 28030 alessia.ba
    </xsl:template>
261 34642 alessia.ba
    <!--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 34866 alessia.ba
274 34642 alessia.ba
    <!--
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 34903 alessia.ba
    <xsl:template match="oaf:result/children/instance/instancetype | oaf:result/resourcetype">
280 34866 alessia.ba
        <xsl:variable name="theInstanceType">
281 34899 alessia.ba
            <xsl:choose>
282 34903 alessia.ba
                <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 34899 alessia.ba
                <xsl:otherwise>
289
                    <xsl:call-template name="ConvertWordsToCamelCase">
290 34903 alessia.ba
                        <xsl:with-param name="text">
291
                            <xsl:value-of select="lower-case(./@classname)"/>
292
                        </xsl:with-param>
293 34899 alessia.ba
                    </xsl:call-template>
294
                </xsl:otherwise>
295
            </xsl:choose>
296 34903 alessia.ba
297 34866 alessia.ba
        </xsl:variable>
298 34642 alessia.ba
        <dc:type>
299 34866 alessia.ba
            <xsl:value-of select="concat('info:eu-repo/semantics/',$theInstanceType)"/>
300 34642 alessia.ba
        </dc:type>
301 34866 alessia.ba
    </xsl:template>
302
    <!--
303
    <xsl:template match="oaf:result/resulttype">
304 34642 alessia.ba
        <dc:type>
305
            <xsl:value-of select="./@classname"/>
306
        </dc:type>
307 28030 alessia.ba
    </xsl:template>
308 34866 alessia.ba
    -->
309
310 34642 alessia.ba
    <!-- 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 28030 alessia.ba
    </xsl:template>
319 34866 alessia.ba
320 34642 alessia.ba
    <!-- source (R) from source-->
321 34866 alessia.ba
    <xsl:template match="oaf:result/source/text()">
322 34642 alessia.ba
        <dc:source>
323
            <xsl:value-of select="normalize-space(.)"/>
324
        </dc:source>
325 28030 alessia.ba
    </xsl:template>
326 34866 alessia.ba
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 34642 alessia.ba
    <!-- Language (R) from language@classid -->
334 34866 alessia.ba
    <xsl:template match="oaf:result/language">
335 34642 alessia.ba
        <dc:language>
336 34866 alessia.ba
            <xsl:value-of select="./@classid"/>
337 34642 alessia.ba
        </dc:language>
338 28030 alessia.ba
    </xsl:template>
339 34866 alessia.ba
340 28030 alessia.ba
    <!-- Override default template -->
341 34642 alessia.ba
    <xsl:template match="text()|@*"/>
342 34903 alessia.ba
343 34866 alessia.ba
    <!-- =========================================================================== -->
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 34903 alessia.ba
352 34866 alessia.ba
        <xsl:variable name="Upper">ABCDEFGHIJKLMNOPQRSTUVQXYZ</xsl:variable>
353
        <xsl:variable name="Lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
354 34903 alessia.ba
355 34866 alessia.ba
        <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 34903 alessia.ba
368 28030 alessia.ba
</xsl:stylesheet>