Project

General

Profile

« Previous | Next » 

Revision 60431

new TR for data got from the API

View differences:

modules/dnet-openaireplus-profiles/trunk/src/main/resources/eu/dnetlib/test/profiles/TransformationRuleDSResources/TransformationRuleDSResourceType/funders/fct_2_db.xml
14 14
				<CODE>
15 15
					<![CDATA[
16 16
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
18
                exclude-result-prefixes="xs" version="2.0">
17
    xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
19 18

  
20
	<xsl:param name="varDataSourceId"/>
21
	<xsl:variable name="namespacePrefix" select="string('fct_________')"/>
19
    <xsl:param name="varDataSourceId"/>
20
    <xsl:variable name="namespacePrefix" select="string('fct_________')"/>
22 21

  
23
	<xsl:variable name="invalid" select="' ,-'"/>
24
	<xsl:variable name="valid" select="'___'"/>
22
    <xsl:variable name="invalid" select="' ,-'"/>
23
    <xsl:variable name="valid" select="'___'"/>
25 24

  
26
	<xsl:variable name="prefix" select="string('fct_________')"/>
27
	<xsl:variable name="funderID" select="concat($prefix, '::FCT')"/>
25
    <xsl:variable name="prefix" select="string('fct_________')"/>
26
    <xsl:variable name="funderID" select="concat($prefix, '::FCT')"/>
28 27

  
29
	<xsl:template match="/">
30
		<record>
31
			<xsl:copy-of select=".//*[local-name()='header']"/>
32
			<metadata>
33
				<ROWS>
34
					<xsl:for-each select="//project">
35
						<xsl:call-template name="projectTemplate"/>
36
					</xsl:for-each>
37
				</ROWS>
38
			</metadata>
39 28

  
40
		</record>
41
	</xsl:template>
29
    <!--    TO BE USED COUPLED WITH THE OTHER
42 30

  
43
	<xsl:template name="projectTemplate">
31
<xsl:template name="terminate">
32
                <xsl:message terminate="yes">
44 33

  
45
		<xsl:variable name="projectId" select="concat($namespacePrefix, '::',  ./id)"/>
46
		<xsl:variable name="projectAcronym" select="./reference"/>
47
		<xsl:variable name="tokens" select="tokenize(./reference,'/')"/>
48
		<xsl:variable name="callID" select="concat($tokens[1], '/', $tokens[last()])"/>
34
                    funder is not FCT; transformation interrupeted
35
                </xsl:message>
36
            </xsl:template>
49 37

  
50
		<ROW table="projects">
51
			<FIELD name="_dnet_resource_identifier_">
52
				<xsl:value-of select="$projectId"/>
53
			</FIELD>
54
			<FIELD name="id">
55
				<xsl:value-of select="$projectId"/>
56
			</FIELD>
57
			<FIELD name="code">
58
				<xsl:value-of select="./id"/>
59
			</FIELD>
60
			<FIELD name="call_identifier">
61
				<xsl:value-of select="$callID"/>
62
			</FIELD>
63
			<FIELD name="websiteurl">
64
				<xsl:value-of select="./refUri"/>
65
			</FIELD>
66
			<FIELD name="acronym">
67
				<xsl:value-of select="./reference"/>
68
			</FIELD>
69
			<FIELD name="title">
70
				<xsl:value-of select="./name"/>
71
			</FIELD>
72
			<FIELD name="startdate" type="date" format="dd/MM/yyyy">
73
				<xsl:value-of select="./startDate"/>
74
			</FIELD>
75
			<FIELD name="enddate" type="date" format="dd/MM/yyyy">
76
				<xsl:value-of select="./endDate"/>
77
			</FIELD>
78
			<FIELD name="keywords">
79
				<xsl:for-each select="./classification/elem">
80
					<xsl:if test="position() &gt; 1">,</xsl:if>
81
					<xsl:value-of select="."/>
82
				</xsl:for-each>
83
			</FIELD>
84
			<FIELD name="collectedfrom">
85
				<xsl:value-of select="$varDataSourceId"/>
86
			</FIELD>
38
 -->
87 39

  
88 40

  
89
			<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
90
			<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
91
			<xsl:if test="string-length(normalize-space(./oaMandate)) &gt; 0">
92
				<FIELD name="oa_mandate_for_publications" type="boolean">
93
					<xsl:value-of select="./oaMandate"/>
94
				</FIELD>
95
			</xsl:if>
96
			<FIELD name="lastupdate" type="date"><xsl:value-of select="current-dateTime()"/></FIELD>
97
		</ROW>
41
    <xsl:template name="orgPid">
42
        <xsl:param name="organizationPidType"/>
43
        <xsl:param name="organizationPidValue"/>
44
        <xsl:param name="organizationId"/>
45
        <xsl:variable name="organizationPid"
46
            select="concat($organizationPidType, ':', $organizationPidValue)"/>
47
        <ROW table="dsm_identities">
48
            <FIELD name="_dnet_resource_identifier_">
49
                <xsl:value-of select="concat($organizationPid, '@@', $organizationPidType)"/>
50
            </FIELD>
51
            <FIELD name="pid">
52
                <xsl:value-of select="$organizationPid"/>
53
            </FIELD>
54
            <FIELD name="issuertype">
55
                <xsl:value-of select="$organizationPidType"/>
56
            </FIELD>
57
        </ROW>
58
        <ROW table="dsm_organizationpids">
59
            <FIELD name="organization">
60
                <xsl:value-of select="$organizationId"/>
61
            </FIELD>
62
            <FIELD name="_dnet_resource_identifier_">
63
                <xsl:value-of select="concat($organizationPid, '@@', $organizationId)"/>
64
            </FIELD>
65
            <FIELD name="pid">
66
                <xsl:value-of select="$organizationPid"/>
67
            </FIELD>
68
        </ROW>
98 69

  
99
		<xsl:for-each select="./funding">
100
			<xsl:variable name="p1" select="normalize-space(./program)"/>
101
			<xsl:variable name="p2" select="normalize-space(./program2)"/>
102 70

  
103
			<xsl:variable name="tmpFundingId">
104
				<xsl:choose>
105
					<xsl:when test="string-length($p1) &gt; 0 and string-length($p2) &gt; 0">
106
						<xsl:value-of select="concat($funderID, '::', $p1, '::', $p2)"/>
107
					</xsl:when>
108
					<xsl:when test="string-length($p1) &gt; 0">
109
						<xsl:value-of select="concat($funderID, '::', $p1)"/>
110
					</xsl:when>
111
					<xsl:otherwise></xsl:otherwise>
112
				</xsl:choose>
113
			</xsl:variable>
114 71

  
115
			<xsl:variable name="fundingId" select="normalize-space($tmpFundingId)"/>
116 72

  
117
			<xsl:if test="string-length($fundingId) &gt; 0">
118
				<ROW table="project_fundingpath">
119
					<FIELD name="_dnet_resource_identifier_">
120
						<xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
121
					</FIELD>
122
					<FIELD name="funding">
123
						<xsl:value-of select="$fundingId"/>
124
					</FIELD>
125
					<FIELD name="project">
126
						<xsl:value-of select="$projectId"/>
127
					</FIELD>
128
					<FIELD name="startdate" type="date" format="dd/MM/yyyy">
129
						<xsl:value-of select="../startDate"/>
130
					</FIELD>
131
					<FIELD name="enddate" type="date" format="dd/MM/yyyy">
132
						<xsl:value-of select="../endDate"/>
133
					</FIELD>
134
					<FIELD name="optional1">
135
						<xsl:value-of select="./amount"/>
136
					</FIELD>
137
					<FIELD name="optional2">
138
						<xsl:value-of select="./dateAwarded"/>
139
					</FIELD>
140
				</ROW>
141
			</xsl:if>
142
		</xsl:for-each>
73
    </xsl:template>
74
    <xsl:template name="orgTempalte">
143 75

  
144
	</xsl:template>
76
        <xsl:param name="elem"/>
77
        <xsl:param name="role"/>
78
        <xsl:param name="projectId"/>
79
        <xsl:variable name="organizationId"
80
            select="concat($namespacePrefix, '::', $elem/*[local-name() = 'OrgUnit']/@id)"/>
81
        <ROW table="dsm_organizations">
82
            <FIELD name="_dnet_resource_identifier_">
83
                <xsl:value-of select="$organizationId"/>
84
            </FIELD>
85
            <FIELD name="id">
86
                <xsl:value-of select="$organizationId"/>
87
            </FIELD>
88
            <FIELD name="legalname">
89
                <xsl:value-of select="normalize-space($elem//*[local-name() = 'Name'])"/>
90
            </FIELD>
91
            <FIELD name="legalshortname">
92
                <xsl:value-of select="normalize-space($elem//*[local-name() = 'Acronym'])"/>
93
            </FIELD>
94
            <xsl:for-each
95
                select=".//*[local-name() = 'Type'][@scheme = 'https://w3id.org/cerif/vocab/OrganisationTypes' and @xml:lang = 'en']">
96
                <xsl:choose>
97
                    <xsl:when test=". = 'Higher Education'">
98
                        <FIELD name="ec_highereducation" type="boolean">
99
                            <xsl:value-of select="true()"/>
100
                        </FIELD>
101
                    </xsl:when>
102
                    <xsl:when test=". = 'Research Institute'">
103
                        <FIELD name="ec_researchorganization" type="boolean">
104
                            <xsl:value-of select="true()"/>
105
                        </FIELD>
106
                    </xsl:when>
107
                    <xsl:when test=". = 'Private non-profit'">
108
                        <FIELD name="ec_nonprofit" type="boolean">
109
                            <xsl:value-of select="true()"/>
110
                        </FIELD>
111
                    </xsl:when>
112
                </xsl:choose>
113

  
114
            </xsl:for-each>
115

  
116
            <FIELD name="websiteurl">
117
                <xsl:value-of
118
                    select="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#URL']"
119
                />
120
            </FIELD>
121
            <FIELD name="collectedfrom">
122
                <xsl:value-of select="$varDataSourceId"/>
123
            </FIELD>
124
            <FIELD name="provenanceaction">sysimport:crosswalk:entityregistry</FIELD>
125
            <FIELD name="lastupdate" type="date">
126
                <xsl:value-of select="current-dateTime()"/>
127
            </FIELD>
128
        </ROW>
129
        <ROW table="project_organization">
130
            <FIELD name="_dnet_resource_identifier_">
131
                <xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
132
            </FIELD>
133
            <FIELD name="project">
134
                <xsl:value-of select="$projectId"/>
135
            </FIELD>
136
            <FIELD name="resporganization">
137
                <xsl:value-of select="$organizationId"/>
138
            </FIELD>
139

  
140
            <FIELD name="semanticclass">
141
                <xsl:value-of select="$role"/>
142
            </FIELD>
143

  
144
        </ROW>
145
        <xsl:if
146
            test="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#ISNI']">
147
            <xsl:call-template name="orgPid">
148
                <xsl:with-param name="organizationPidType" select="'ISNI'"/>
149
                <xsl:with-param name="organizationPidValue"
150
                    select="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#ISNI']"/>
151
                <xsl:with-param name="organizationId" select="$organizationId"/>
152
            </xsl:call-template>
153
        </xsl:if>
154
        <xsl:if
155
            test="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#RingGold']">
156
            <xsl:call-template name="orgPid">
157
                <xsl:with-param name="organizationPidType" select="'RingGold'"/>
158
                <xsl:with-param name="organizationPidValue"
159
                    select="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#RingGold']"/>
160
                <xsl:with-param name="organizationId" select="$organizationId"/>
161
            </xsl:call-template>
162
        </xsl:if>
163
        <xsl:if
164
            test="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#NIF']">
165
            <xsl:call-template name="orgPid">
166
                <xsl:with-param name="organizationPidType" select="'NIF'"/>
167
                <xsl:with-param name="organizationPidValue"
168
                    select="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#NIF']"/>
169
                <xsl:with-param name="organizationId" select="$organizationId"/>
170
            </xsl:call-template>
171
        </xsl:if>
172
        <xsl:if
173
            test="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#DGEEC']">
174
            <xsl:call-template name="orgPid">
175
                <xsl:with-param name="organizationPidType" select="'DGEEC'"/>
176
                <xsl:with-param name="organizationPidValue"
177
                    select="$elem//*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#DGEEC']"/>
178
                <xsl:with-param name="organizationId" select="$organizationId"/>
179
            </xsl:call-template>
180
        </xsl:if>
181
    </xsl:template>
182

  
183
    <!--    TO BE USED IF SOME OF THE PROJECTS ARE NOT FROM FCT
184

  
185
<xsl:template match="/">
186
<xsl:choose>
187
<xsl:when test="//*[local-name() = 'Funded']//*[local-name() = 'Acronym'] = 'FCT'">
188
        <record>
189
            <xsl:copy-of select=".//*[local-name() = 'header']"/>
190
            <metadata>
191
                <ROWS>
192
                    <xsl:for-each select="//*[local-name() = 'Project']">
193
                        <xsl:call-template name="projectTemplate"/>
194
                    </xsl:for-each>
195
                </ROWS>
196
            </metadata>
197

  
198
        </record>
199
</xsl:when>
200
<xsl:otherwise>
201
<FunderAcronym>
202
<xsl:value-of select="//*[local-name() = 'Funded']//*[local-name() = 'Acronym'] "/>
203
</FunderAcronym>
204
</xsl:otherwise>
205
</xsl:choose>
206
    </xsl:template>
207

  
208
-->
209

  
210
    <xsl:template match="/">
211

  
212
        <record>
213
            <xsl:copy-of select=".//*[local-name() = 'header']"/>
214
            <metadata>
215
                <ROWS>
216
                    <xsl:for-each select="//*[local-name() = 'Project']">
217
                        <xsl:call-template name="projectTemplate"/>
218
                    </xsl:for-each>
219
                </ROWS>
220
            </metadata>
221

  
222
        </record>
223

  
224
    </xsl:template>
225

  
226
    <xsl:template name="projectTemplate">
227
        <xsl:variable name="projectCode"
228
            select="./*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#ProjectReference']"/>
229
        <xsl:variable name="projectId" select="concat($namespacePrefix, '::', $projectCode)"/>
230
        <!--<xsl:variable name="projectAcronym" select="./*[local-name() = 'Acronym']"/>-->
231
        <xsl:variable name="projectTitle" select="./*[local-name() = 'Title'][@xml:lang = 'en']"/>
232
        <xsl:variable name="startDate" select="./*[local-name() = 'StartDate']"/>
233
        <xsl:variable name="endDate" select="./*[local-name() = 'EndDate']"/>
234
        <xsl:variable name="projectSummary" select="./*[local-name() = 'Abstract']"/>
235
        <xsl:variable name="tokens" select="tokenize($projectCode, '/')"/>
236
        <xsl:variable name="callID" select="concat($tokens[1], '/', $tokens[last()])"/>
237
        <xsl:variable name="projectKeywords"
238
            select="./*[local-name() = 'Keyword'][@xml:lang = 'en']"/>
239
        <xsl:variable name="contactPerson"
240
            select="./*[local-name() = 'Team']/*[local-name() = 'Contact']//*[local-name() = 'PersonName']"/>
241
        <xsl:variable name="fundedAmount"
242
            select=".//*[local-name() = 'Funding']/*[local-name() = 'Amount']"/>
243
        <xsl:variable name="fundedCurrency"
244
            select=".//*[local-name() = 'Funding']/*[local-name() = 'Amount']/@currency"/>
245
        <xsl:variable name="websiteUrl"
246
            select=".//*[local-name() = 'Funding']/*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#URL']"/>
247
        <xsl:variable name="coordinatorList" select=".//*[local-name() = 'Coordinator']"/>
248
        <xsl:variable name="participantList" select=".//*[local-name() = 'Partner']"/>
249

  
250
        <ROW table="projects">
251
            <FIELD name="_dnet_resource_identifier_">
252
                <xsl:value-of select="$projectId"/>
253
            </FIELD>
254
            <FIELD name="id">
255
                <xsl:value-of select="$projectId"/>
256
            </FIELD>
257
            <FIELD name="code">
258
                <xsl:value-of select="$projectCode"/>
259
            </FIELD>
260

  
261
            <!--   <FIELD name="websiteurl">
262
                <xsl:choose>
263
                    <xsl:when test="contains($websiteUrl,'?idProjecto')">
264
                        <xsl:value-of select="$websiteUrl"/>
265
                    </xsl:when>
266
                    <xsl:otherwise>
267
                        <xsl:variable name="prefix" select="substring-before($websiteUrl, 'idProjecto')"/>
268

  
269
                        <xsl:value-of select="concat($prefix, '?', substring-after($websiteUrl, $prefix))"/>
270
                    </xsl:otherwise>
271
                </xsl:choose>
272

  
273
            </FIELD> -->
274
            <!--   <FIELD name="call_identifier">
275
                <xsl:value-of select="$callID"/>
276
            </FIELD> -->
277
            <FIELD name="title">
278
                <xsl:value-of select="$projectTitle"/>
279
            </FIELD>
280
            <FIELD name="summary">
281
                <xsl:value-of select="$projectSummary"/>
282
            </FIELD>
283
            <FIELD name="startdate" type="date" format="yyyy/MM/dd">
284
                <xsl:value-of select="$startDate"/>
285
            </FIELD>
286
            <FIELD name="enddate" type="date" format="yyyy/MM/dd">
287
                <xsl:value-of select="$endDate"/>
288
            </FIELD>
289
            <FIELD name="keywords">
290
                <xsl:value-of select="$projectKeywords"/>
291
            </FIELD>
292
            <FIELD name="contactfullname">
293
                <xsl:value-of select="$contactPerson"/>
294
            </FIELD>
295

  
296
            <FIELD name="fundedamount" type="float">
297
                <xsl:value-of select="$fundedAmount"/>
298
            </FIELD>
299
            <FIELD name="currency">
300
                <xsl:value-of select="$fundedCurrency"/>
301
            </FIELD>
302

  
303
            <FIELD name="collectedfrom">
304
                <xsl:value-of select="$varDataSourceId"/>
305
            </FIELD>
306
            <FIELD name="contracttypescheme">fct:contractTypes</FIELD>
307
            <FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
308
            <FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
309
            <xsl:if test="//*[local-name() = 'OAMandate']">
310
                <FIELD name="oa_mandate_for_publications" type="boolean">
311
                    <xsl:value-of select="lower-case(//*[local-name() = 'OAMandate']/@mandated)"/>
312
                </FIELD>
313
            </xsl:if>
314
            <FIELD name="lastupdate" type="date">
315
                <xsl:value-of select="current-dateTime()"/>
316
            </FIELD>
317
        </ROW>
318

  
319
        <xsl:variable name="p1"
320
            select="normalize-space(./*[local-name() = 'Identifier'][@type = 'https://w3id.org/cerif/vocab/IdentifierTypes#FundingProgram'])"/>
321

  
322

  
323
        <xsl:variable name="fundingId">
324
            <xsl:choose>
325
                <xsl:when test="string-length($p1) > 0">
326
                    <xsl:value-of select="concat($funderID, '::', $p1)"/>
327
                </xsl:when>
328
                <xsl:otherwise>
329
                    <xsl:value-of select="$funderID"/>
330
                </xsl:otherwise>
331
            </xsl:choose>
332
        </xsl:variable>
333

  
334

  
335

  
336

  
337
        <ROW table="project_fundingpath">
338
            <FIELD name="_dnet_resource_identifier_">
339
                <xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
340
            </FIELD>
341
            <FIELD name="funding">
342
                <xsl:value-of select="$fundingId"/>
343
            </FIELD>
344
            <FIELD name="project">
345
                <xsl:value-of select="$projectId"/>
346
            </FIELD>
347
            <FIELD name="startdate" type="date" format="yyyy/MM/dd">
348
                <xsl:value-of select="$startDate"/>
349
            </FIELD>
350
            <FIELD name="enddate" type="date" format="yyyy/MM/dd">
351
                <xsl:value-of select="$endDate"/>
352
            </FIELD>
353
        </ROW>
354

  
355

  
356
        <xsl:for-each select="$coordinatorList">
357
            <xsl:variable name="role">
358
                <xsl:choose>
359
                    <xsl:when test="position() = 1">
360
                        <xsl:value-of select="coordinator"/>
361
                    </xsl:when>
362
                    <xsl:otherwise>
363
                        <xsl:value-of select="participant"/>
364
                    </xsl:otherwise>
365
                </xsl:choose>
366
            </xsl:variable>
367
            <xsl:call-template name="orgTempalte">
368
                <xsl:with-param name="elem" select="."/>
369
                <xsl:with-param name="role" select="$role"/>
370

  
371
                <xsl:with-param name="projectId" select="$projectId"/>
372
            </xsl:call-template>
373

  
374
        </xsl:for-each>
375

  
376
        <xsl:for-each select="$participantList">
377
            <xsl:variable name="role">
378
                <xsl:value-of select="participant"/>
379
            </xsl:variable>
380
            <xsl:call-template name="orgTempalte">
381
                <xsl:with-param name="elem" select="."/>
382
                <xsl:with-param name="role" select="$role"/>
383
                <xsl:with-param name="projectId" select="$projectId"/>
384
            </xsl:call-template>
385
        </xsl:for-each>
386

  
387

  
388

  
389
    </xsl:template>
145 390
</xsl:stylesheet>
391

  
146 392
]]>
147 393
				</CODE>
148 394
			</SCRIPT>

Also available in: Unified diff