Project

General

Profile

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

    
18
			<xsl:copy-of select=".//*[local-name()='header']"/>
19

    
20
			<metadata>
21
				<ROWS>
22
					<xsl:variable name="projectCode"
23
					              select="//*[local-name()='identifier' and ./@*[local-name()='type' and .='RCUK']]"/>
24
					<xsl:variable name="projectId"
25
					              select="concat($namespacePrefix, '::', $projectCode)"/>
26

    
27
					<xsl:variable name="sDate" select=".//*[local-name()='fund']/*[local-name()='start']"/>
28
					<xsl:variable name="eDate" select=".//*[local-name()='fund']/*[local-name()='end']"/>
29
					<xsl:variable name="startDate">
30
						<xsl:choose>
31
							<xsl:when test="contains($sDate, '+')">
32
								<xsl:value-of select="substring-before($sDate, '+')"/>
33
							</xsl:when>
34
							<xsl:when test="contains($sDate, 'Z')">
35
								<xsl:value-of select="substring-before($sDate, 'Z')"/>
36
							</xsl:when>
37
							<xsl:otherwise>
38
								<xsl:value-of select="$sDate"/>
39
							</xsl:otherwise>
40
						</xsl:choose>
41
					</xsl:variable>
42
					<xsl:variable name="endDate">
43
						<xsl:choose>
44
							<xsl:when test="contains($eDate, '+')">
45
								<xsl:value-of select="substring-before($eDate, '+')"/>
46
							</xsl:when>
47
							<xsl:when test="contains($eDate, 'Z')">
48
								<xsl:value-of select="substring-before($eDate, 'Z')"/>
49
							</xsl:when>
50
							<xsl:otherwise>
51
								<xsl:value-of select="$eDate"/>
52
							</xsl:otherwise>
53
						</xsl:choose>
54
					</xsl:variable>
55

    
56
					<xsl:variable name="personCode"
57
					              select=".//*[local-name()='person']/@*[local-name()='id']"/>
58
					<xsl:variable name="personId"
59
					              select="concat($namespacePrefix,'::',$personCode)"/>
60
					<xsl:variable name="personSurname" select=".//*[local-name()='surname']"/>
61
					<xsl:variable name="personFirstName" select=".//*[local-name()='firstName']"/>
62
					<xsl:variable name="fundingId"
63
					              select="concat($funderID ,'::' , .//*[local-name()='funder']/name)"/>
64

    
65
					<ROW table="projects">
66
						<FIELD name="_dnet_resource_identifier_">
67
							<xsl:value-of select="$projectId"/>
68
						</FIELD>
69
						<FIELD name="id">
70
							<xsl:value-of select="$projectId"/>
71
						</FIELD>
72
						<FIELD name="code">
73
							<xsl:value-of select="$projectCode"/>
74
						</FIELD>
75
						<FIELD name="title">
76
							<xsl:value-of select=".//*[local-name()='title']"/>
77
						</FIELD>
78
						<FIELD name="startdate" type="date" format="{$dateFormat}">
79
							<xsl:value-of select="$startDate"/>
80
						</FIELD>
81
						<FIELD name="enddate" type="date" format="{$dateFormat}">
82
							<xsl:value-of select="$endDate"/>
83
						</FIELD>
84
						<FIELD name="collectedfrom">
85
							<xsl:value-of select="$parentDatasourceId"/>
86
						</FIELD>
87
						<FIELD name="provenanceactionclass">sysimport:crosswalk:entityregistry</FIELD>
88
						<FIELD name="optional1">
89
							<xsl:value-of
90
									select="concat(.//*[local-name()='valuePounds']/@*[local-name()='amount'], ' ', .//*[local-name()='valuePounds']/@*[local-name()='currencyCode'])"/>
91
						</FIELD>
92
					</ROW>
93

    
94
					<ROW table="project_fundingpath">
95
						<FIELD name="_dnet_resource_identifier_">
96
							<xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
97
						</FIELD>
98
						<FIELD name="funding">
99
							<xsl:value-of select="$fundingId"/>
100
						</FIELD>
101
						<FIELD name="project">
102
							<xsl:value-of select="$projectId"/>
103
						</FIELD>
104
						<FIELD name="startdate" type="date" format="{$dateFormat}">
105
							<xsl:value-of select="$startDate"/>
106
						</FIELD>
107
						<FIELD name="enddate" type="date" format="{$dateFormat}">
108
							<xsl:value-of select="$endDate"/>
109
						</FIELD>
110
					</ROW>
111

    
112
					<xsl:for-each select=".//pp-org">
113
						<xsl:variable name="organizationId" select="concat($namespacePrefix, '::', normalize-space(./id))"/>
114
						<xsl:variable name="country" select="./country"/>
115
						<ROW table="organizations">
116
							<FIELD name="_dnet_resource_identifier_">
117
								<xsl:value-of select="$organizationId"/>
118
							</FIELD>
119
							<FIELD name="id">
120
								<xsl:value-of select="$organizationId"/>
121
							</FIELD>
122
							<FIELD name="legalname">
123
								<xsl:value-of select="./name"/>
124
							</FIELD>
125

    
126
							<xsl:if test="string-length($country) &gt; 0">
127
								<FIELD name="countryclass">
128
									<xsl:value-of select="$country"/>
129
								</FIELD>
130
								<FIELD name="countryscheme">dnet:countries</FIELD>
131
							</xsl:if>
132

    
133
							<FIELD name="collectedfrom">
134
								<xsl:value-of select="$parentDatasourceId"/>
135
							</FIELD>
136
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
137
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
138
						</ROW>
139
						<ROW table="project_organization">
140
							<FIELD name="_dnet_resource_identifier_">
141
								<xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
142
							</FIELD>
143
							<FIELD name="project">
144
								<xsl:value-of select="$projectId"/>
145
							</FIELD>
146
							<FIELD name="resporganization">
147
								<xsl:value-of select="$organizationId"/>
148
							</FIELD>
149

    
150
							<FIELD name="semanticclass">participant</FIELD>
151
							<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
152
						</ROW>
153

    
154
					</xsl:for-each>
155

    
156
					<xsl:variable name="leadOrgId"
157
					              select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
158
					<ROW table="organizations">
159
						<FIELD name="_dnet_resource_identifier_">
160
							<xsl:value-of select="$leadOrgId"/>
161
						</FIELD>
162
						<FIELD name="id">
163
							<xsl:value-of select="$leadOrgId"/>
164
						</FIELD>
165
						<FIELD name="legalname">
166
							<xsl:value-of select=".//ld-org/name"/>
167
						</FIELD>
168
						<xsl:variable name="country" select=".//ld-org/country"/>
169
						<xsl:if test="string-length($country) &gt; 0">
170
							<FIELD name="countryclass">
171
								<xsl:value-of select="$country"/>
172
							</FIELD>
173
							<FIELD name="countryscheme">dnet:countries</FIELD>
174
						</xsl:if>
175

    
176
						<FIELD name="collectedfrom">
177
							<xsl:value-of select="$parentDatasourceId"/>
178
						</FIELD>
179
						<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
180
						<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
181
					</ROW>
182

    
183
					<xsl:if test="string-length($personFirstName) &gt; 0">
184
						<ROW table="persons">
185
							<FIELD name="_dnet_resource_identifier_">
186
								<xsl:value-of select="$personId"/>
187
							</FIELD>
188
							<FIELD name="id">
189
								<xsl:value-of select="$personId"/>
190
							</FIELD>
191
							<FIELD name="firstname">
192
								<xsl:value-of select="$personFirstName"/>
193
							</FIELD>
194
							<FIELD name="secondnames">
195
								<xsl:value-of select="$personSurname"/>
196
							</FIELD>
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
					</xsl:if>
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
						<xsl:if test="string-length($personFirstName) &gt; 0">
218
							<FIELD name="contactperson">
219
								<xsl:value-of select="$personId"/>
220
							</FIELD>
221
						</xsl:if>
222
					</ROW>
223

    
224
				</ROWS>
225
			</metadata>
226
		</record>
227
	</xsl:template>
228

    
229
</xsl:stylesheet>
(19-19/25)