1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
3
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
4
|
exclude-result-prefixes="xs" version="1.0">
|
5
|
|
6
|
<xsl:param name="parentDatasourceId"/>
|
7
|
<xsl:param name="namespacePrefix"/>
|
8
|
|
9
|
<xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
|
10
|
<xsl:variable name="funderID" select="concat($namespacePrefix, '::RCUK')"/>
|
11
|
|
12
|
<xsl:template match="/">
|
13
|
|
14
|
|
15
|
<record>
|
16
|
|
17
|
<xsl:copy-of select=".//*[local-name()='header']"/>
|
18
|
|
19
|
<metadata>
|
20
|
<ROWS>
|
21
|
<xsl:variable name="projectCode"
|
22
|
select="//*[local-name()='identifier' and ./@*[local-name()='type' and .='RCUK']]"/>
|
23
|
<xsl:variable name="projectId"
|
24
|
select="concat($namespacePrefix, '::', $projectCode)"/>
|
25
|
|
26
|
<xsl:variable name="sDate" select=".//*[local-name()='fund']/*[local-name()='start']"/>
|
27
|
<xsl:variable name="eDate" select=".//*[local-name()='fund']/*[local-name()='end']"/>
|
28
|
<xsl:variable name="startDate">
|
29
|
<xsl:choose>
|
30
|
<xsl:when test="contains($sDate, '+')">
|
31
|
<xsl:value-of select="substring-before($sDate, '+')"/>
|
32
|
</xsl:when>
|
33
|
<xsl:when test="contains($sDate, 'Z')">
|
34
|
<xsl:value-of select="substring-before($sDate, 'Z')"/>
|
35
|
</xsl:when>
|
36
|
<xsl:otherwise>
|
37
|
<xsl:value-of select="$sDate"/>
|
38
|
</xsl:otherwise>
|
39
|
</xsl:choose>
|
40
|
</xsl:variable>
|
41
|
<xsl:variable name="endDate">
|
42
|
<xsl:choose>
|
43
|
<xsl:when test="contains($eDate, '+')">
|
44
|
<xsl:value-of select="substring-before($eDate, '+')"/>
|
45
|
</xsl:when>
|
46
|
<xsl:when test="contains($eDate, 'Z')">
|
47
|
<xsl:value-of select="substring-before($eDate, 'Z')"/>
|
48
|
</xsl:when>
|
49
|
<xsl:otherwise>
|
50
|
<xsl:value-of select="$eDate"/>
|
51
|
</xsl:otherwise>
|
52
|
</xsl:choose>
|
53
|
</xsl:variable>
|
54
|
|
55
|
<xsl:variable name="personCode"
|
56
|
select=".//*[local-name()='person']/@*[local-name()='id']"/>
|
57
|
<xsl:variable name="personId"
|
58
|
select="concat($namespacePrefix,'::',$personCode)"/>
|
59
|
<xsl:variable name="fundingId"
|
60
|
select="concat($funderID ,'::' , .//*[local-name()='funder']/name)"/>
|
61
|
|
62
|
<ROW table="projects">
|
63
|
<FIELD name="_dnet_resource_identifier_">
|
64
|
<xsl:value-of select="$projectId"/>
|
65
|
</FIELD>
|
66
|
<FIELD name="id">
|
67
|
<xsl:value-of select="$projectId"/>
|
68
|
</FIELD>
|
69
|
<FIELD name="code">
|
70
|
<xsl:value-of select="$projectCode"/>
|
71
|
</FIELD>
|
72
|
<FIELD name="title">
|
73
|
<xsl:value-of select=".//*[local-name()='title']"/>
|
74
|
</FIELD>
|
75
|
<FIELD name="startdate" type="date" format="{$dateFormat}">
|
76
|
<xsl:value-of select="$startDate"/>
|
77
|
</FIELD>
|
78
|
<FIELD name="enddate" type="date" format="{$dateFormat}">
|
79
|
<xsl:value-of select="$endDate"/>
|
80
|
</FIELD>
|
81
|
<FIELD name="collectedfrom">
|
82
|
<xsl:value-of select="$parentDatasourceId"/>
|
83
|
</FIELD>
|
84
|
<FIELD name="provenanceactionclass">sysimport:crosswalk:entityregistry</FIELD>
|
85
|
<FIELD name="optional1">
|
86
|
<xsl:value-of
|
87
|
select="concat(.//*[local-name()='valuePounds']/@*[local-name()='amount'], ' ', .//*[local-name()='valuePounds']/@*[local-name()='currencyCode'])"/>
|
88
|
</FIELD>
|
89
|
|
90
|
<xsl:variable name="personSurname" select="normalize-space(.//*[local-name()='surname'])"/>
|
91
|
<xsl:variable name="personFirstName" select="normalize-space(.//*[local-name()='firstName'])"/>
|
92
|
<xsl:variable name="contactfullname">
|
93
|
<xsl:choose>
|
94
|
<xsl:when test="string-length($personFirstName) > 0 and string-length($personSurname) > 0">
|
95
|
<xsl:value-of select="normalize-space(concat($personSurname, ', ', $personFirstName))"/>
|
96
|
</xsl:when>
|
97
|
<xsl:when test="string-length($personFirstName) > 0">
|
98
|
<xsl:value-of select="$personFirstName"/>
|
99
|
</xsl:when>
|
100
|
<xsl:when test="string-length($personSurname) > 0">
|
101
|
<xsl:value-of select="$personSurname"/>
|
102
|
</xsl:when>
|
103
|
<xsl:otherwise>
|
104
|
<xsl:value-of select="''"/>
|
105
|
</xsl:otherwise>
|
106
|
</xsl:choose>
|
107
|
</xsl:variable>
|
108
|
<xsl:if test="string-length($contactfullname) > 0">
|
109
|
<FIELD name="contactfullname">
|
110
|
<xsl:value-of select="$contactfullname"/>
|
111
|
</FIELD>
|
112
|
</xsl:if>
|
113
|
</ROW>
|
114
|
|
115
|
<ROW table="project_fundingpath">
|
116
|
<FIELD name="_dnet_resource_identifier_">
|
117
|
<xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
|
118
|
</FIELD>
|
119
|
<FIELD name="funding">
|
120
|
<xsl:value-of select="$fundingId"/>
|
121
|
</FIELD>
|
122
|
<FIELD name="project">
|
123
|
<xsl:value-of select="$projectId"/>
|
124
|
</FIELD>
|
125
|
<FIELD name="startdate" type="date" format="{$dateFormat}">
|
126
|
<xsl:value-of select="$startDate"/>
|
127
|
</FIELD>
|
128
|
<FIELD name="enddate" type="date" format="{$dateFormat}">
|
129
|
<xsl:value-of select="$endDate"/>
|
130
|
</FIELD>
|
131
|
</ROW>
|
132
|
|
133
|
<xsl:for-each select=".//pp-org">
|
134
|
<xsl:variable name="organizationId" select="concat($namespacePrefix, '::', normalize-space(./id))"/>
|
135
|
<xsl:variable name="country" select="./country"/>
|
136
|
<ROW table="organizations">
|
137
|
<FIELD name="_dnet_resource_identifier_">
|
138
|
<xsl:value-of select="$organizationId"/>
|
139
|
</FIELD>
|
140
|
<FIELD name="id">
|
141
|
<xsl:value-of select="$organizationId"/>
|
142
|
</FIELD>
|
143
|
<FIELD name="legalname">
|
144
|
<xsl:value-of select="./name"/>
|
145
|
</FIELD>
|
146
|
|
147
|
<xsl:if test="string-length($country) > 0">
|
148
|
<FIELD name="countryclass">
|
149
|
<xsl:value-of select="$country"/>
|
150
|
</FIELD>
|
151
|
<FIELD name="countryscheme">dnet:countries</FIELD>
|
152
|
</xsl:if>
|
153
|
|
154
|
<FIELD name="collectedfrom">
|
155
|
<xsl:value-of select="$parentDatasourceId"/>
|
156
|
</FIELD>
|
157
|
<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
|
158
|
<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
|
159
|
</ROW>
|
160
|
<ROW table="project_organization">
|
161
|
<FIELD name="_dnet_resource_identifier_">
|
162
|
<xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
|
163
|
</FIELD>
|
164
|
<FIELD name="project">
|
165
|
<xsl:value-of select="$projectId"/>
|
166
|
</FIELD>
|
167
|
<FIELD name="resporganization">
|
168
|
<xsl:value-of select="$organizationId"/>
|
169
|
</FIELD>
|
170
|
|
171
|
<FIELD name="semanticclass">participant</FIELD>
|
172
|
<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
|
173
|
</ROW>
|
174
|
|
175
|
</xsl:for-each>
|
176
|
|
177
|
<xsl:variable name="leadOrgId"
|
178
|
select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
|
179
|
<ROW table="organizations">
|
180
|
<FIELD name="_dnet_resource_identifier_">
|
181
|
<xsl:value-of select="$leadOrgId"/>
|
182
|
</FIELD>
|
183
|
<FIELD name="id">
|
184
|
<xsl:value-of select="$leadOrgId"/>
|
185
|
</FIELD>
|
186
|
<FIELD name="legalname">
|
187
|
<xsl:value-of select=".//ld-org/name"/>
|
188
|
</FIELD>
|
189
|
<xsl:variable name="country" select=".//ld-org/country"/>
|
190
|
<xsl:if test="string-length($country) > 0">
|
191
|
<FIELD name="countryclass">
|
192
|
<xsl:value-of select="$country"/>
|
193
|
</FIELD>
|
194
|
<FIELD name="countryscheme">dnet:countries</FIELD>
|
195
|
</xsl:if>
|
196
|
|
197
|
<FIELD name="collectedfrom">
|
198
|
<xsl:value-of select="$parentDatasourceId"/>
|
199
|
</FIELD>
|
200
|
<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
|
201
|
<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
|
202
|
</ROW>
|
203
|
|
204
|
<ROW table="project_organization">
|
205
|
<FIELD name="_dnet_resource_identifier_">
|
206
|
<xsl:value-of select='concat($projectId, "@@", $leadOrgId)'/>
|
207
|
</FIELD>
|
208
|
<FIELD name="project">
|
209
|
<xsl:value-of select="$projectId"/>
|
210
|
</FIELD>
|
211
|
<FIELD name="resporganization">
|
212
|
<xsl:value-of select="$leadOrgId"/>
|
213
|
</FIELD>
|
214
|
<FIELD name="participantnumber" type="int">1</FIELD>
|
215
|
<FIELD name="semanticclass">coordinator</FIELD>
|
216
|
<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
|
217
|
</ROW>
|
218
|
|
219
|
</ROWS>
|
220
|
</metadata>
|
221
|
</record>
|
222
|
</xsl:template>
|
223
|
|
224
|
</xsl:stylesheet>
|