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="fundingId"
61
					              select="concat($funderID ,'::' , .//*[local-name()='funder']/name)"/>
62

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

    
91
						<xsl:variable name="personSurname" select=".//*[local-name()='surname']"/>
92
						<xsl:variable name="personFirstName" select=".//*[local-name()='firstName']"/>
93
						<xsl:variable name="contactfullname">
94
							<xsl:choose>
95
								<xsl:when test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
96
									<xsl:value-of select="normalize-space(concat($personSurname, ', ', $personFirstName))"/>
97
								</xsl:when>
98
								<xsl:when test="string-length($personFirstName) &gt; 0">
99
									<xsl:value-of select="normalize-space($personFirstName)"/>
100
								</xsl:when>
101
								<xsl:when test="string-length($personSurname) &gt; 0">
102
									<xsl:value-of select="normalize-space($personSurname)"/>
103
								</xsl:when>
104
								<xsl:otherwise>
105
									<xsl:value-of select="''"/>
106
								</xsl:otherwise>
107
							</xsl:choose>
108
						</xsl:variable>
109
						<xsl:if test="string-length($contactfullname) &gt; 0">
110
							<FIELD name="contactfullname">
111
								<xsl:value-of select="$contactfullname"/>
112
							</FIELD>
113
						</xsl:if>
114
					</ROW>
115

    
116
					<ROW table="project_fundingpath">
117
						<FIELD name="_dnet_resource_identifier_">
118
							<xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
119
						</FIELD>
120
						<FIELD name="funding">
121
							<xsl:value-of select="$fundingId"/>
122
						</FIELD>
123
						<FIELD name="project">
124
							<xsl:value-of select="$projectId"/>
125
						</FIELD>
126
						<FIELD name="startdate" type="date" format="{$dateFormat}">
127
							<xsl:value-of select="$startDate"/>
128
						</FIELD>
129
						<FIELD name="enddate" type="date" format="{$dateFormat}">
130
							<xsl:value-of select="$endDate"/>
131
						</FIELD>
132
					</ROW>
133

    
134
					<xsl:for-each select=".//pp-org">
135
						<xsl:variable name="organizationId" select="concat($namespacePrefix, '::', normalize-space(./id))"/>
136
						<xsl:variable name="country" select="./country"/>
137
						<ROW table="organizations">
138
							<FIELD name="_dnet_resource_identifier_">
139
								<xsl:value-of select="$organizationId"/>
140
							</FIELD>
141
							<FIELD name="id">
142
								<xsl:value-of select="$organizationId"/>
143
							</FIELD>
144
							<FIELD name="legalname">
145
								<xsl:value-of select="./name"/>
146
							</FIELD>
147

    
148
							<xsl:if test="string-length($country) &gt; 0">
149
								<FIELD name="countryclass">
150
									<xsl:value-of select="$country"/>
151
								</FIELD>
152
								<FIELD name="countryscheme">dnet:countries</FIELD>
153
							</xsl:if>
154

    
155
							<FIELD name="collectedfrom">
156
								<xsl:value-of select="$parentDatasourceId"/>
157
							</FIELD>
158
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
159
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
160
						</ROW>
161
						<ROW table="project_organization">
162
							<FIELD name="_dnet_resource_identifier_">
163
								<xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
164
							</FIELD>
165
							<FIELD name="project">
166
								<xsl:value-of select="$projectId"/>
167
							</FIELD>
168
							<FIELD name="resporganization">
169
								<xsl:value-of select="$organizationId"/>
170
							</FIELD>
171

    
172
							<FIELD name="semanticclass">participant</FIELD>
173
							<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
174
						</ROW>
175

    
176
					</xsl:for-each>
177

    
178
					<xsl:variable name="leadOrgId"
179
					              select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
180
					<ROW table="organizations">
181
						<FIELD name="_dnet_resource_identifier_">
182
							<xsl:value-of select="$leadOrgId"/>
183
						</FIELD>
184
						<FIELD name="id">
185
							<xsl:value-of select="$leadOrgId"/>
186
						</FIELD>
187
						<FIELD name="legalname">
188
							<xsl:value-of select=".//ld-org/name"/>
189
						</FIELD>
190
						<xsl:variable name="country" select=".//ld-org/country"/>
191
						<xsl:if test="string-length($country) &gt; 0">
192
							<FIELD name="countryclass">
193
								<xsl:value-of select="$country"/>
194
							</FIELD>
195
							<FIELD name="countryscheme">dnet:countries</FIELD>
196
						</xsl:if>
197

    
198
						<FIELD name="collectedfrom">
199
							<xsl:value-of select="$parentDatasourceId"/>
200
						</FIELD>
201
						<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
202
						<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
203
					</ROW>
204

    
205
					<ROW table="project_organization">
206
						<FIELD name="_dnet_resource_identifier_">
207
							<xsl:value-of select='concat($projectId, "@@", $leadOrgId)'/>
208
						</FIELD>
209
						<FIELD name="project">
210
							<xsl:value-of select="$projectId"/>
211
						</FIELD>
212
						<FIELD name="resporganization">
213
							<xsl:value-of select="$leadOrgId"/>
214
						</FIELD>
215
						<FIELD name="participantnumber" type="int">1</FIELD>
216
						<FIELD name="semanticclass">coordinator</FIELD>
217
						<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
218
					</ROW>
219

    
220
				</ROWS>
221
			</metadata>
222
		</record>
223
	</xsl:template>
224

    
225
</xsl:stylesheet>
(20-20/27)