Project

General

Profile

« Previous | Next » 

Revision 54301

Copied RCUK transformation from BETA

View differences:

rcuk_2_db.xml
1 1
<RESOURCE_PROFILE>
2 2
	<HEADER>
3
		<RESOURCE_IDENTIFIER value="b4ac3d3d-419d-4312-b243-c14d768bd766_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
3
		<RESOURCE_IDENTIFIER
4
				value="b4ac3d3d-419d-4312-b243-c14d768bd766_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
4 5
		<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
5 6
		<RESOURCE_KIND value="TransformationRuleDSResources"/>
6 7
		<RESOURCE_URI value=""/>
7
		<DATE_OF_CREATION value="2018-06-04T11:15:30+00:00"/>
8
		<DATE_OF_CREATION value="2018-07-31T12:24:40+00:00"/>
8 9
	</HEADER>
9 10
	<BODY>
10 11
		<CONFIGURATION>
......
12 13
			<SCRIPT>
13 14
				<TITLE>RCUK to DB</TITLE>
14 15
				<CODE>
15
					<![CDATA[
16
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:per="http://gtr.ukri.org/gtr/api/person" exclude-result-prefixes="xs" version="2.0">
18 16

  
19
    <xsl:param name="varDataSourceId"/>
20
    <xsl:variable name="namespacePrefix" select="string('rcuk________')"/>
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 21

  
22
    <xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
23
    <xsl:variable name="funderID" select="concat($namespacePrefix, '::RCUK')"/>
22
						<xsl:param name="varDataSourceId"/>
23
						<xsl:variable name="namespacePrefix" select="string('rcuk________')"/>
24 24

  
25
    <xsl:template match="/">
26
        <record>
27
            <xsl:copy-of select=".//*[local-name() = 'header']"/>
28
            <metadata>
29
                <ROWS>
30
                    <xsl:variable name="projectCode"
31
                        select="//*[local-name() = 'identifier' and ./@*[local-name() = 'type' and . = 'RCUK']]"/>
32
                    <xsl:variable name="projectId"
33
                        select="concat($namespacePrefix, '::', $projectCode)"/>
25
						<xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
26
						<xsl:variable name="funderID" select="concat($namespacePrefix, '::RCUK')"/>
34 27

  
35
                    <xsl:variable name="sDate"
36
                        select=".//*[local-name() = 'fund']/*[local-name() = 'start']"/>
37
                    <xsl:variable name="eDate"
38
                        select=".//*[local-name() = 'fund']/*[local-name() = 'end']"/>
39
                    <xsl:variable name="startDate">
40
                        <xsl:choose>
41
                            <xsl:when test="contains($sDate, '+')">
42
                                <xsl:value-of select="substring-before($sDate, '+')"/>
43
                            </xsl:when>
44
                            <xsl:when test="contains($sDate, 'Z')">
45
                                <xsl:value-of select="substring-before($sDate, 'Z')"/>
46
                            </xsl:when>
47
                            <xsl:otherwise>
48
                                <xsl:value-of select="$sDate"/>
49
                            </xsl:otherwise>
50
                        </xsl:choose>
51
                    </xsl:variable>
52
                    <xsl:variable name="endDate">
53
                        <xsl:choose>
54
                            <xsl:when test="contains($eDate, '+')">
55
                                <xsl:value-of select="substring-before($eDate, '+')"/>
56
                            </xsl:when>
57
                            <xsl:when test="contains($eDate, 'Z')">
58
                                <xsl:value-of select="substring-before($eDate, 'Z')"/>
59
                            </xsl:when>
60
                            <xsl:otherwise>
61
                                <xsl:value-of select="$eDate"/>
62
                            </xsl:otherwise>
63
                        </xsl:choose>
64
                    </xsl:variable>
65
                    <xsl:variable name="funding" select=".//*[local-name() = 'funder']/name"/>
66
                    <xsl:variable name="fundingId">
67
                        <xsl:choose>
68
                            <xsl:when test="string-length($funding) > 0">
69
                                <xsl:value-of select="concat($funderID, '::', .//*[local-name() = 'funder']/name)"/>
70
                            </xsl:when>
71
                            <xsl:otherwise>
72
                                <xsl:value-of select="$funderID"/>
73
                            </xsl:otherwise>
74
                        </xsl:choose>
75
                    </xsl:variable>
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)"/>
76 37

  
77
                    <ROW table="projects">
78
                        <FIELD name="_dnet_resource_identifier_">
79
                            <xsl:value-of select="$projectId"/>
80
                        </FIELD>
81
                        <FIELD name="id">
82
                            <xsl:value-of select="$projectId"/>
83
                        </FIELD>
84
                        <FIELD name="code">
85
                            <xsl:value-of select="$projectCode"/>
86
                        </FIELD>
87
                        <FIELD name="title">
88
                            <xsl:value-of select=".//*[local-name() = 'title']"/>
89
                        </FIELD>
90
                        <FIELD name="startdate" type="date" format="{$dateFormat}">
91
                            <xsl:value-of select="$startDate"/>
92
                        </FIELD>
93
                        <FIELD name="enddate" type="date" format="{$dateFormat}">
94
                            <xsl:value-of select="$endDate"/>
95
                        </FIELD>
96
                        <FIELD name="collectedfrom">
97
                            <xsl:value-of select="$varDataSourceId"/>
98
                        </FIELD>
99
                        <FIELD name="provenanceactionclass"
100
                            >sysimport:crosswalk:entityregistry</FIELD>
101
                        <FIELD name="optional1">
102
                            <xsl:value-of
103
                                select="concat(.//*[local-name() = 'valuePounds']/@*[local-name() = 'amount'], ' ', .//*[local-name() = 'valuePounds']/@*[local-name() = 'currencyCode'])"
104
                            />
105
                        </FIELD>
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>
106 86

  
107
                        <xsl:variable name="principalInvestigators">
108
                            <xsl:apply-templates select=".//*[local-name() = 'person']"/>
109
                        </xsl:variable>
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>
110 118

  
111
                        <xsl:if test="string-length($principalInvestigators) &gt; 0">
112
                            <FIELD name="contactfullname">
113
                                <xsl:value-of select="$principalInvestigators"/>
114
                            </FIELD>
115
                        </xsl:if>
116
                        <FIELD name="lastupdate" type="date">
117
                            <xsl:value-of select="current-dateTime()"/>
118
                        </FIELD>
119
                    </ROW>
119
											<xsl:variable name="principalInvestigators">
120
												<xsl:apply-templates
121
														select=".//*[local-name() = 'person']"/>
122
											</xsl:variable>
120 123

  
121
                    <ROW table="project_fundingpath">
122
                        <FIELD name="_dnet_resource_identifier_">
123
                            <xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
124
                        </FIELD>
125
                        <FIELD name="funding">
126
                            <xsl:value-of select="$fundingId"/>
127
                        </FIELD>
128
                        <FIELD name="project">
129
                            <xsl:value-of select="$projectId"/>
130
                        </FIELD>
131
                        <FIELD name="startdate" type="date" format="{$dateFormat}">
132
                            <xsl:value-of select="$startDate"/>
133
                        </FIELD>
134
                        <FIELD name="enddate" type="date" format="{$dateFormat}">
135
                            <xsl:value-of select="$endDate"/>
136
                        </FIELD>
137
                    </ROW>
124
											<xsl:if
125
													test="string-length($principalInvestigators) &amp;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>
138 134

  
139
                    <xsl:for-each select=".//pp-org">
140
                        <xsl:variable name="organizationId"
141
                            select="concat($namespacePrefix, '::', normalize-space(./id))"/>
142
                        <xsl:variable name="country" select="./country"/>
143
                        <ROW table="dsm_organizations">
144
                            <FIELD name="_dnet_resource_identifier_">
145
                                <xsl:value-of select="$organizationId"/>
146
                            </FIELD>
147
                            <FIELD name="id">
148
                                <xsl:value-of select="$organizationId"/>
149
                            </FIELD>
150
                            <FIELD name="legalname">
151
                                <xsl:value-of select="./name"/>
152
                            </FIELD>
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>
153 154

  
154
                            <xsl:if test="string-length($country) &gt; 0">
155
                                <FIELD name="country">
156
                                    <xsl:value-of select="$country"/>
157
                                </FIELD>
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>
158 169

  
159
                            </xsl:if>
170
												<xsl:if test="string-length($country) &amp;gt; 0">
171
													<FIELD name="country">
172
														<xsl:value-of select="$country"/>
173
													</FIELD>
174
												</xsl:if>
160 175

  
161
                            <FIELD name="collectedfrom">
162
                                <xsl:value-of select="$varDataSourceId"/>
163
                            </FIELD>
164
                            <FIELD name="provenanceaction"
165
                                >sysimport:crosswalk:entityregistry</FIELD>
166
                            <FIELD name="lastupdate" type="date">
167
                                <xsl:value-of select="current-dateTime()"/>
168
                            </FIELD>
169
                        </ROW>
170
                        <ROW table="project_organization">
171
                            <FIELD name="_dnet_resource_identifier_">
172
                                <xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
173
                            </FIELD>
174
                            <FIELD name="project">
175
                                <xsl:value-of select="$projectId"/>
176
                            </FIELD>
177
                            <FIELD name="resporganization">
178
                                <xsl:value-of select="$organizationId"/>
179
                            </FIELD>
180
                            <FIELD name="semanticclass">participant</FIELD>
181
                        </ROW>
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>
182 197

  
183
                    </xsl:for-each>
198
												<FIELD name="semanticclass">participant</FIELD>
184 199

  
185
                    <xsl:variable name="leadOrgId"
186
                        select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
187
                    <ROW table="dsm_organizations">
188
                        <FIELD name="_dnet_resource_identifier_">
189
                            <xsl:value-of select="$leadOrgId"/>
190
                        </FIELD>
191
                        <FIELD name="id">
192
                            <xsl:value-of select="$leadOrgId"/>
193
                        </FIELD>
194
                        <FIELD name="legalname">
195
                            <xsl:value-of select=".//ld-org/name"/>
196
                        </FIELD>
197
                        <xsl:variable name="country" select=".//ld-org/country"/>
198
                        <xsl:if test="string-length($country) &gt; 0">
199
                            <FIELD name="countryclass">
200
                                <xsl:value-of select="$country"/>
201
                            </FIELD>
202
                            <FIELD name="countryscheme">dnet:countries</FIELD>
203
                        </xsl:if>
200
											</ROW>
204 201

  
205
                        <FIELD name="collectedfrom">
206
                            <xsl:value-of select="$varDataSourceId"/>
207
                        </FIELD>
208
                        <FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
209
                        <FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
210
                    </ROW>
202
										</xsl:for-each>
211 203

  
212
                    <ROW table="project_organization">
213
                        <FIELD name="_dnet_resource_identifier_">
214
                            <xsl:value-of select='concat($projectId, "@@", $leadOrgId)'/>
215
                        </FIELD>
216
                        <FIELD name="project">
217
                            <xsl:value-of select="$projectId"/>
218
                        </FIELD>
219
                        <FIELD name="resporganization">
220
                            <xsl:value-of select="$leadOrgId"/>
221
                        </FIELD>
222
                        <FIELD name="participantnumber" type="int">1</FIELD>
223
                        <FIELD name="semanticclass">coordinator</FIELD>
224
                    </ROW>
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) &amp;gt; 0">
218
												<FIELD name="country">
219
													<xsl:value-of select="$country"/>
220
												</FIELD>
221
											</xsl:if>
225 222

  
226
                </ROWS>
227
            </metadata>
228
        </record>
229
    </xsl:template>
223
											<FIELD name="collectedfrom">
224
												<xsl:value-of select="$varDataSourceId"/>
225
											</FIELD>
226
											<FIELD name="provenanceAction"
227
											>sysimport:crosswalk:entityregistry</FIELD>
228
										</ROW>
230 229

  
231
    <xsl:template match="per:person">
232
        <xsl:variable name="personSurname"
233
            select="normalize-space(.//*[local-name() = 'surname'])"/>
234
        <xsl:variable name="personFirstName"
235
            select="normalize-space(.//*[local-name() = 'firstName'])"/>
236
        <xsl:variable name="contactfullname">
237
        <xsl:choose>
238
            <xsl:when
239
                test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
240
                <xsl:value-of
241
                    select="normalize-space(concat($personSurname, ', ', $personFirstName))"
242
                />
243
            </xsl:when>
244
            <xsl:when test="string-length($personFirstName) &gt; 0">
245
                <xsl:value-of select="$personFirstName"/>
246
            </xsl:when>
247
            <xsl:when test="string-length($personSurname) &gt; 0">
248
                <xsl:value-of select="$personSurname"/>
249
            </xsl:when>
250
            <xsl:otherwise>
251
                <xsl:value-of select="''"/>
252
            </xsl:otherwise>
253
        </xsl:choose>
254
        </xsl:variable>
255
        <xsl:value-of select="concat($contactfullname,';')"/>
256
    </xsl:template>
257
</xsl:stylesheet>
258
                    ]]>
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) &amp;gt; 0 and string-length($personSurname) &amp;gt; 0">
259
										<xsl:value-of
260
												select="normalize-space(concat($personSurname, ', ', $personFirstName))"
261
										/>
262
									</xsl:when>
263
									<xsl:when test="string-length($personFirstName) &amp;gt; 0">
264
										<xsl:value-of select="$personFirstName"/>
265
									</xsl:when>
266
									<xsl:when test="string-length($personSurname) &amp;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

  
259 279
				</CODE>
260 280
			</SCRIPT>
261 281
		</CONFIGURATION>
262 282
		<STATUS/>
263 283
		<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
264 284
	</BODY>
265
</RESOURCE_PROFILE>
285
</RESOURCE_PROFILE>

Also available in: Unified diff