1
|
<RESOURCE_PROFILE>
|
2
|
<HEADER>
|
3
|
<RESOURCE_IDENTIFIER
|
4
|
value="b4ac3d3d-419d-4312-b243-c14d768bd766_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
|
5
|
<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
|
6
|
<RESOURCE_KIND value="TransformationRuleDSResources"/>
|
7
|
<RESOURCE_URI value=""/>
|
8
|
<DATE_OF_CREATION value="2018-07-31T12:24:40+00:00"/>
|
9
|
</HEADER>
|
10
|
<BODY>
|
11
|
<CONFIGURATION>
|
12
|
<IMPORTED/>
|
13
|
<SCRIPT>
|
14
|
<TITLE>RCUK to DB</TITLE>
|
15
|
<CODE>
|
16
|
|
17
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
18
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
19
|
xmlns:per="http://gtr.ukri.org/gtr/api/person" exclude-result-prefixes="xs"
|
20
|
version="2.0">
|
21
|
|
22
|
<xsl:param name="varDataSourceId"/>
|
23
|
<xsl:variable name="namespacePrefix" select="string('rcuk________')"/>
|
24
|
|
25
|
<xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
|
26
|
<xsl:variable name="funderID" select="concat($namespacePrefix, '::RCUK')"/>
|
27
|
|
28
|
<xsl:template match="/">
|
29
|
<record>
|
30
|
<xsl:copy-of select=".//*[local-name() = 'header']"/>
|
31
|
<metadata>
|
32
|
<ROWS>
|
33
|
<xsl:variable name="projectCode"
|
34
|
select="//*[local-name() = 'identifier' and ./@*[local-name() = 'type' and . = 'RCUK']]"/>
|
35
|
<xsl:variable name="projectId"
|
36
|
select="concat($namespacePrefix, '::', $projectCode)"/>
|
37
|
|
38
|
<xsl:variable name="sDate"
|
39
|
select=".//*[local-name() = 'fund']/*[local-name() = 'start']"/>
|
40
|
<xsl:variable name="eDate"
|
41
|
select=".//*[local-name() = 'fund']/*[local-name() = 'end']"/>
|
42
|
<xsl:variable name="startDate">
|
43
|
<xsl:choose>
|
44
|
<xsl:when test="contains($sDate, '+')">
|
45
|
<xsl:value-of
|
46
|
select="substring-before($sDate, '+')"/>
|
47
|
</xsl:when>
|
48
|
<xsl:when test="contains($sDate, 'Z')">
|
49
|
<xsl:value-of
|
50
|
select="substring-before($sDate, 'Z')"/>
|
51
|
</xsl:when>
|
52
|
<xsl:otherwise>
|
53
|
<xsl:value-of select="$sDate"/>
|
54
|
</xsl:otherwise>
|
55
|
</xsl:choose>
|
56
|
</xsl:variable>
|
57
|
<xsl:variable name="endDate">
|
58
|
<xsl:choose>
|
59
|
<xsl:when test="contains($eDate, '+')">
|
60
|
<xsl:value-of
|
61
|
select="substring-before($eDate, '+')"/>
|
62
|
</xsl:when>
|
63
|
<xsl:when test="contains($eDate, 'Z')">
|
64
|
<xsl:value-of
|
65
|
select="substring-before($eDate, 'Z')"/>
|
66
|
</xsl:when>
|
67
|
<xsl:otherwise>
|
68
|
<xsl:value-of select="$eDate"/>
|
69
|
</xsl:otherwise>
|
70
|
</xsl:choose>
|
71
|
</xsl:variable>
|
72
|
<xsl:variable name="funding"
|
73
|
select=".//*[local-name() = 'funder']/name"/>
|
74
|
<xsl:variable name="fundingId">
|
75
|
<xsl:choose>
|
76
|
<xsl:when test="string-length($funding) > 0">
|
77
|
<xsl:value-of
|
78
|
select="concat($funderID, '::', .//*[local-name() = 'funder']/name)"
|
79
|
/>
|
80
|
</xsl:when>
|
81
|
<xsl:otherwise>
|
82
|
<xsl:value-of select="$funderID"/>
|
83
|
</xsl:otherwise>
|
84
|
</xsl:choose>
|
85
|
</xsl:variable>
|
86
|
|
87
|
<ROW table="projects">
|
88
|
<FIELD name="_dnet_resource_identifier_">
|
89
|
<xsl:value-of select="$projectId"/>
|
90
|
</FIELD>
|
91
|
<FIELD name="id">
|
92
|
<xsl:value-of select="$projectId"/>
|
93
|
</FIELD>
|
94
|
<FIELD name="code">
|
95
|
<xsl:value-of select="$projectCode"/>
|
96
|
</FIELD>
|
97
|
<FIELD name="title">
|
98
|
<xsl:value-of select=".//*[local-name() = 'title']"
|
99
|
/>
|
100
|
</FIELD>
|
101
|
<FIELD name="startdate" type="date"
|
102
|
format="{$dateFormat}">
|
103
|
<xsl:value-of select="$startDate"/>
|
104
|
</FIELD>
|
105
|
<FIELD name="enddate" type="date" format="{$dateFormat}">
|
106
|
<xsl:value-of select="$endDate"/>
|
107
|
</FIELD>
|
108
|
<FIELD name="collectedfrom">
|
109
|
<xsl:value-of select="$varDataSourceId"/>
|
110
|
</FIELD>
|
111
|
<FIELD name="provenanceactionclass"
|
112
|
>sysimport:crosswalk:entityregistry</FIELD>
|
113
|
<FIELD name="optional1">
|
114
|
<xsl:value-of
|
115
|
select="concat(.//*[local-name() = 'valuePounds']/@*[local-name() = 'amount'], ' ', .//*[local-name() = 'valuePounds']/@*[local-name() = 'currencyCode'])"
|
116
|
/>
|
117
|
</FIELD>
|
118
|
|
119
|
<xsl:variable name="principalInvestigators">
|
120
|
<xsl:apply-templates
|
121
|
select=".//*[local-name() = 'person']"/>
|
122
|
</xsl:variable>
|
123
|
|
124
|
<xsl:if
|
125
|
test="string-length($principalInvestigators) &gt; 0">
|
126
|
<FIELD name="contactfullname">
|
127
|
<xsl:value-of select="$principalInvestigators"/>
|
128
|
</FIELD>
|
129
|
</xsl:if>
|
130
|
<FIELD name="lastupdate" type="date">
|
131
|
<xsl:value-of select="current-dateTime()"/>
|
132
|
</FIELD>
|
133
|
</ROW>
|
134
|
|
135
|
<ROW table="project_fundingpath">
|
136
|
<FIELD name="_dnet_resource_identifier_">
|
137
|
<xsl:value-of
|
138
|
select="concat($fundingId, '@@', $projectId)"/>
|
139
|
</FIELD>
|
140
|
<FIELD name="funding">
|
141
|
<xsl:value-of select="$fundingId"/>
|
142
|
</FIELD>
|
143
|
<FIELD name="project">
|
144
|
<xsl:value-of select="$projectId"/>
|
145
|
</FIELD>
|
146
|
<FIELD name="startdate" type="date"
|
147
|
format="{$dateFormat}">
|
148
|
<xsl:value-of select="$startDate"/>
|
149
|
</FIELD>
|
150
|
<FIELD name="enddate" type="date" format="{$dateFormat}">
|
151
|
<xsl:value-of select="$endDate"/>
|
152
|
</FIELD>
|
153
|
</ROW>
|
154
|
|
155
|
<xsl:for-each select=".//pp-org">
|
156
|
<xsl:variable name="organizationId"
|
157
|
select="concat($namespacePrefix, '::', normalize-space(./id))"/>
|
158
|
<xsl:variable name="country" select="./country"/>
|
159
|
<ROW table="dsm_organizations">
|
160
|
<FIELD name="_dnet_resource_identifier_">
|
161
|
<xsl:value-of select="$organizationId"/>
|
162
|
</FIELD>
|
163
|
<FIELD name="id">
|
164
|
<xsl:value-of select="$organizationId"/>
|
165
|
</FIELD>
|
166
|
<FIELD name="legalname">
|
167
|
<xsl:value-of select="./name"/>
|
168
|
</FIELD>
|
169
|
|
170
|
<xsl:if test="string-length($country) &gt; 0">
|
171
|
<FIELD name="country">
|
172
|
<xsl:value-of select="$country"/>
|
173
|
</FIELD>
|
174
|
</xsl:if>
|
175
|
|
176
|
<FIELD name="collectedfrom">
|
177
|
<xsl:value-of select="$varDataSourceId"/>
|
178
|
</FIELD>
|
179
|
<FIELD name="provenanceaction"
|
180
|
>sysimport:crosswalk:entityregistry</FIELD>
|
181
|
<FIELD name="lastupdate" type="date">
|
182
|
<xsl:value-of select="current-dateTime()"/>
|
183
|
</FIELD>
|
184
|
</ROW>
|
185
|
<ROW table="project_organization">
|
186
|
<FIELD name="_dnet_resource_identifier_">
|
187
|
<xsl:value-of
|
188
|
select='concat($projectId, "@@", $organizationId)'
|
189
|
/>
|
190
|
</FIELD>
|
191
|
<FIELD name="project">
|
192
|
<xsl:value-of select="$projectId"/>
|
193
|
</FIELD>
|
194
|
<FIELD name="resporganization">
|
195
|
<xsl:value-of select="$organizationId"/>
|
196
|
</FIELD>
|
197
|
|
198
|
<FIELD name="semanticclass">participant</FIELD>
|
199
|
|
200
|
</ROW>
|
201
|
|
202
|
</xsl:for-each>
|
203
|
|
204
|
<xsl:variable name="leadOrgId"
|
205
|
select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
|
206
|
<ROW table="dsm_organizations">
|
207
|
<FIELD name="_dnet_resource_identifier_">
|
208
|
<xsl:value-of select="$leadOrgId"/>
|
209
|
</FIELD>
|
210
|
<FIELD name="id">
|
211
|
<xsl:value-of select="$leadOrgId"/>
|
212
|
</FIELD>
|
213
|
<FIELD name="legalname">
|
214
|
<xsl:value-of select=".//ld-org/name"/>
|
215
|
</FIELD>
|
216
|
<xsl:variable name="country" select=".//ld-org/country"/>
|
217
|
<xsl:if test="string-length($country) &gt; 0">
|
218
|
<FIELD name="country">
|
219
|
<xsl:value-of select="$country"/>
|
220
|
</FIELD>
|
221
|
</xsl:if>
|
222
|
|
223
|
<FIELD name="collectedfrom">
|
224
|
<xsl:value-of select="$varDataSourceId"/>
|
225
|
</FIELD>
|
226
|
<FIELD name="provenanceAction"
|
227
|
>sysimport:crosswalk:entityregistry</FIELD>
|
228
|
</ROW>
|
229
|
|
230
|
<ROW table="project_organization">
|
231
|
<FIELD name="_dnet_resource_identifier_">
|
232
|
<xsl:value-of
|
233
|
select='concat($projectId, "@@", $leadOrgId)'/>
|
234
|
</FIELD>
|
235
|
<FIELD name="project">
|
236
|
<xsl:value-of select="$projectId"/>
|
237
|
</FIELD>
|
238
|
<FIELD name="resporganization">
|
239
|
<xsl:value-of select="$leadOrgId"/>
|
240
|
</FIELD>
|
241
|
<FIELD name="participantnumber" type="int">1</FIELD>
|
242
|
<FIELD name="semanticclass">coordinator</FIELD>
|
243
|
</ROW>
|
244
|
|
245
|
</ROWS>
|
246
|
</metadata>
|
247
|
</record>
|
248
|
</xsl:template>
|
249
|
|
250
|
<xsl:template match="per:person">
|
251
|
<xsl:variable name="personSurname"
|
252
|
select="normalize-space(.//*[local-name() = 'surname'])"/>
|
253
|
<xsl:variable name="personFirstName"
|
254
|
select="normalize-space(.//*[local-name() = 'firstName'])"/>
|
255
|
<xsl:variable name="contactfullname">
|
256
|
<xsl:choose>
|
257
|
<xsl:when
|
258
|
test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
|
259
|
<xsl:value-of
|
260
|
select="normalize-space(concat($personSurname, ', ', $personFirstName))"
|
261
|
/>
|
262
|
</xsl:when>
|
263
|
<xsl:when test="string-length($personFirstName) &gt; 0">
|
264
|
<xsl:value-of select="$personFirstName"/>
|
265
|
</xsl:when>
|
266
|
<xsl:when test="string-length($personSurname) &gt; 0">
|
267
|
<xsl:value-of select="$personSurname"/>
|
268
|
</xsl:when>
|
269
|
<xsl:otherwise>
|
270
|
<xsl:value-of select="''"/>
|
271
|
</xsl:otherwise>
|
272
|
</xsl:choose>
|
273
|
</xsl:variable>
|
274
|
<xsl:value-of select="concat($contactfullname,';')"/>
|
275
|
</xsl:template>
|
276
|
</xsl:stylesheet>
|
277
|
|
278
|
|
279
|
</CODE>
|
280
|
</SCRIPT>
|
281
|
</CONFIGURATION>
|
282
|
<STATUS/>
|
283
|
<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
|
284
|
</BODY>
|
285
|
</RESOURCE_PROFILE>
|