Project

General

Profile

« Previous | Next » 

Revision 52368

fixed variable with xsl:choose

View differences:

modules/dnet-openaireplus-profiles/trunk/src/main/resources/eu/dnetlib/test/profiles/TransformationRuleDSResources/TransformationRuleDSResourceType/funders/rcuk_2_db.xml
13 13
				<TITLE>RCUK to DB</TITLE>
14 14
				<CODE>
15 15
					<![CDATA[
16

  
16 17
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
18
                exclude-result-prefixes="xs" version="2.0">
18
    xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
19 19

  
20
	<xsl:param name="parentDatasourceId"/>
21
	<xsl:param name="namespacePrefix"/>
20
    <xsl:param name="parentDatasourceId"/>
21
    <xsl:param name="namespacePrefix"/>
22 22

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

  
26
	<xsl:template match="/">
26
    <xsl:template match="/">
27 27

  
28 28

  
29
		<record>
29
        <record>
30 30

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

  
33
			<metadata>
34
				<ROWS>
35
					<xsl:variable name="projectCode"
36
					              select="//*[local-name()='identifier' and ./@*[local-name()='type' and .='RCUK']]"/>
37
					<xsl:variable name="projectId"
38
					              select="concat($namespacePrefix, '::', $projectCode)"/>
33
            <metadata>
34
                <ROWS>
35
                    <xsl:variable name="projectCode"
36
                        select="//*[local-name() = 'identifier' and ./@*[local-name() = 'type' and . = 'RCUK']]"/>
37
                    <xsl:variable name="projectId"
38
                        select="concat($namespacePrefix, '::', $projectCode)"/>
39 39

  
40
					<xsl:variable name="sDate" select=".//*[local-name()='fund']/*[local-name()='start']"/>
41
					<xsl:variable name="eDate" 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 select="substring-before($sDate, '+')"/>
46
							</xsl:when>
47
							<xsl:when test="contains($sDate, 'Z')">
48
								<xsl:value-of select="substring-before($sDate, 'Z')"/>
49
							</xsl:when>
50
							<xsl:otherwise>
51
								<xsl:value-of select="$sDate"/>
52
							</xsl:otherwise>
53
						</xsl:choose>
54
					</xsl:variable>
55
					<xsl:variable name="endDate">
56
						<xsl:choose>
57
							<xsl:when test="contains($eDate, '+')">
58
								<xsl:value-of select="substring-before($eDate, '+')"/>
59
							</xsl:when>
60
							<xsl:when test="contains($eDate, 'Z')">
61
								<xsl:value-of select="substring-before($eDate, 'Z')"/>
62
							</xsl:when>
63
							<xsl:otherwise>
64
								<xsl:value-of select="$eDate"/>
65
							</xsl:otherwise>
66
						</xsl:choose>
67
					</xsl:variable>
40
                    <xsl:variable name="sDate"
41
                        select=".//*[local-name() = 'fund']/*[local-name() = 'start']"/>
42
                    <xsl:variable name="eDate"
43
                        select=".//*[local-name() = 'fund']/*[local-name() = 'end']"/>
44
                    <xsl:variable name="startDate">
45
                        <xsl:choose>
46
                            <xsl:when test="contains($sDate, '+')">
47
                                <xsl:value-of select="substring-before($sDate, '+')"/>
48
                            </xsl:when>
49
                            <xsl:when test="contains($sDate, 'Z')">
50
                                <xsl:value-of 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 select="substring-before($eDate, '+')"/>
61
                            </xsl:when>
62
                            <xsl:when test="contains($eDate, 'Z')">
63
                                <xsl:value-of select="substring-before($eDate, 'Z')"/>
64
                            </xsl:when>
65
                            <xsl:otherwise>
66
                                <xsl:value-of select="$eDate"/>
67
                            </xsl:otherwise>
68
                        </xsl:choose>
69
                    </xsl:variable>
68 70

  
69
					<xsl:variable name="personCode"
70
					              select=".//*[local-name()='person']/@*[local-name()='id']"/>
71
					<xsl:variable name="personId"
72
					              select="concat($namespacePrefix,'::',$personCode)"/>
73
					<xsl:variable name="funding" select=".//*[local-name()='funder']/name"/>
74
					<xsl:variable name="fundingId">
75
							<xsl:if test="string-length($funding) > 0">
76
								<xsl:value-of select="concat($funderID ,'::' , .//*[local-name()='funder']/name)"/>
77
							</xsl:if>
78
							<xsl:otherwise><xsl:value-of select="$funderID"/></xsl:otherwise>
79
					</xsl:variable>
71
                    <xsl:variable name="personCode"
72
                        select=".//*[local-name() = 'person']/@*[local-name() = 'id']"/>
73
                    <xsl:variable name="personId"
74
                        select="concat($namespacePrefix, '::', $personCode)"/>
75
                    <xsl:variable name="funding" select=".//*[local-name() = 'funder']/name"/>
76
                    <xsl:variable name="fundingId">
77
                        <xsl:choose>
78
                            <xsl:when test="string-length($funding) > 0">
79
                                <xsl:value-of select="concat($funderID, '::', .//*[local-name() = 'funder']/name)"/>
80
                            </xsl:when>
81
                            <xsl:otherwise>
82
                                <xsl:value-of select="$funderID"/>
83
                            </xsl:otherwise>
84
                        </xsl:choose>
85
                    </xsl:variable>
80 86

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

  
109
						<xsl:variable name="personSurname" select="normalize-space(.//*[local-name()='surname'])"/>
110
						<xsl:variable name="personFirstName" select="normalize-space(.//*[local-name()='firstName'])"/>
111
						<xsl:variable name="contactfullname">
112
							<xsl:choose>
113
								<xsl:when test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
114
									<xsl:value-of select="normalize-space(concat($personSurname, ', ', $personFirstName))"/>
115
								</xsl:when>
116
								<xsl:when test="string-length($personFirstName) &gt; 0">
117
									<xsl:value-of select="$personFirstName"/>
118
								</xsl:when>
119
								<xsl:when test="string-length($personSurname) &gt; 0">
120
									<xsl:value-of select="$personSurname"/>
121
								</xsl:when>
122
								<xsl:otherwise>
123
									<xsl:value-of select="''"/>
124
								</xsl:otherwise>
125
							</xsl:choose>
126
						</xsl:variable>
127
						<xsl:if test="string-length($contactfullname) &gt; 0">
128
							<FIELD name="contactfullname">
129
								<xsl:value-of select="$contactfullname"/>
130
							</FIELD>
131
						</xsl:if>
132
						<FIELD name="lastupdate" type="date"><xsl:value-of select="current-dateTime()"/></FIELD>
133
					</ROW>
117
                        <xsl:variable name="personSurname"
118
                            select="normalize-space(.//*[local-name() = 'surname'])"/>
119
                        <xsl:variable name="personFirstName"
120
                            select="normalize-space(.//*[local-name() = 'firstName'])"/>
121
                        <xsl:variable name="contactfullname">
122
                            <xsl:choose>
123
                                <xsl:when
124
                                    test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
125
                                    <xsl:value-of
126
                                        select="normalize-space(concat($personSurname, ', ', $personFirstName))"
127
                                    />
128
                                </xsl:when>
129
                                <xsl:when test="string-length($personFirstName) &gt; 0">
130
                                    <xsl:value-of select="$personFirstName"/>
131
                                </xsl:when>
132
                                <xsl:when test="string-length($personSurname) &gt; 0">
133
                                    <xsl:value-of select="$personSurname"/>
134
                                </xsl:when>
135
                                <xsl:otherwise>
136
                                    <xsl:value-of select="''"/>
137
                                </xsl:otherwise>
138
                            </xsl:choose>
139
                        </xsl:variable>
140
                        <xsl:if test="string-length($contactfullname) &gt; 0">
141
                            <FIELD name="contactfullname">
142
                                <xsl:value-of select="$contactfullname"/>
143
                            </FIELD>
144
                        </xsl:if>
145
                        <FIELD name="lastupdate" type="date">
146
                            <xsl:value-of select="current-dateTime()"/>
147
                        </FIELD>
148
                    </ROW>
134 149

  
135
					<ROW table="project_fundingpath">
136
						<FIELD name="_dnet_resource_identifier_">
137
							<xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
138
						</FIELD>
139
						<FIELD name="funding">
140
							<xsl:value-of select="$fundingId"/>
141
						</FIELD>
142
						<FIELD name="project">
143
							<xsl:value-of select="$projectId"/>
144
						</FIELD>
145
						<FIELD name="startdate" type="date" format="{$dateFormat}">
146
							<xsl:value-of select="$startDate"/>
147
						</FIELD>
148
						<FIELD name="enddate" type="date" format="{$dateFormat}">
149
							<xsl:value-of select="$endDate"/>
150
						</FIELD>
151
					</ROW>
150
                    <ROW table="project_fundingpath">
151
                        <FIELD name="_dnet_resource_identifier_">
152
                            <xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
153
                        </FIELD>
154
                        <FIELD name="funding">
155
                            <xsl:value-of select="$fundingId"/>
156
                        </FIELD>
157
                        <FIELD name="project">
158
                            <xsl:value-of select="$projectId"/>
159
                        </FIELD>
160
                        <FIELD name="startdate" type="date" format="{$dateFormat}">
161
                            <xsl:value-of select="$startDate"/>
162
                        </FIELD>
163
                        <FIELD name="enddate" type="date" format="{$dateFormat}">
164
                            <xsl:value-of select="$endDate"/>
165
                        </FIELD>
166
                    </ROW>
152 167

  
153
					<xsl:for-each select=".//pp-org">
154
						<xsl:variable name="organizationId" select="concat($namespacePrefix, '::', normalize-space(./id))"/>
155
						<xsl:variable name="country" select="./country"/>
156
						<ROW table="dsm_organizations">
157
							<FIELD name="_dnet_resource_identifier_">
158
								<xsl:value-of select="$organizationId"/>
159
							</FIELD>
160
							<FIELD name="id">
161
								<xsl:value-of select="$organizationId"/>
162
							</FIELD>
163
							<FIELD name="legalname">
164
								<xsl:value-of select="./name"/>
165
							</FIELD>
168
                    <xsl:for-each select=".//pp-org">
169
                        <xsl:variable name="organizationId"
170
                            select="concat($namespacePrefix, '::', normalize-space(./id))"/>
171
                        <xsl:variable name="country" select="./country"/>
172
                        <ROW table="dsm_organizations">
173
                            <FIELD name="_dnet_resource_identifier_">
174
                                <xsl:value-of select="$organizationId"/>
175
                            </FIELD>
176
                            <FIELD name="id">
177
                                <xsl:value-of select="$organizationId"/>
178
                            </FIELD>
179
                            <FIELD name="legalname">
180
                                <xsl:value-of select="./name"/>
181
                            </FIELD>
166 182

  
167
							<xsl:if test="string-length($country) &gt; 0">
168
								<FIELD name="countryclass">
169
									<xsl:value-of select="$country"/>
170
								</FIELD>
171
								<FIELD name="countryscheme">dnet:countries</FIELD>
172
							</xsl:if>
183
                            <xsl:if test="string-length($country) &gt; 0">
184
                                <FIELD name="countryclass">
185
                                    <xsl:value-of select="$country"/>
186
                                </FIELD>
187
                                <FIELD name="countryscheme">dnet:countries</FIELD>
188
                            </xsl:if>
173 189

  
174
							<FIELD name="collectedfrom">
175
								<xsl:value-of select="$parentDatasourceId"/>
176
							</FIELD>
177
							<FIELD name="provenanceaction">sysimport:crosswalk:entityregistry</FIELD>
178
							<FIELD name="lastupdate" type="date"><xsl:value-of select="current-dateTime()"/></FIELD>
179
						</ROW>
180
						<ROW table="project_organization">
181
							<FIELD name="_dnet_resource_identifier_">
182
								<xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
183
							</FIELD>
184
							<FIELD name="project">
185
								<xsl:value-of select="$projectId"/>
186
							</FIELD>
187
							<FIELD name="organization">
188
								<xsl:value-of select="$organizationId"/>
189
							</FIELD>
190
                            <FIELD name="collectedfrom">
191
                                <xsl:value-of select="$parentDatasourceId"/>
192
                            </FIELD>
193
                            <FIELD name="provenanceaction"
194
                                >sysimport:crosswalk:entityregistry</FIELD>
195
                            <FIELD name="lastupdate" type="date">
196
                                <xsl:value-of select="current-dateTime()"/>
197
                            </FIELD>
198
                        </ROW>
199
                        <ROW table="project_organization">
200
                            <FIELD name="_dnet_resource_identifier_">
201
                                <xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
202
                            </FIELD>
203
                            <FIELD name="project">
204
                                <xsl:value-of select="$projectId"/>
205
                            </FIELD>
206
                            <FIELD name="organization">
207
                                <xsl:value-of select="$organizationId"/>
208
                            </FIELD>
190 209

  
191
							<FIELD name="role">participant</FIELD>
210
                            <FIELD name="role">participant</FIELD>
192 211

  
193
						</ROW>
212
                        </ROW>
194 213

  
195
					</xsl:for-each>
214
                    </xsl:for-each>
196 215

  
197
					<xsl:variable name="leadOrgId"
198
					              select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
199
					<ROW table="organizations">
200
						<FIELD name="_dnet_resource_identifier_">
201
							<xsl:value-of select="$leadOrgId"/>
202
						</FIELD>
203
						<FIELD name="id">
204
							<xsl:value-of select="$leadOrgId"/>
205
						</FIELD>
206
						<FIELD name="legalname">
207
							<xsl:value-of select=".//ld-org/name"/>
208
						</FIELD>
209
						<xsl:variable name="country" select=".//ld-org/country"/>
210
						<xsl:if test="string-length($country) &gt; 0">
211
							<FIELD name="countryclass">
212
								<xsl:value-of select="$country"/>
213
							</FIELD>
214
							<FIELD name="countryscheme">dnet:countries</FIELD>
215
						</xsl:if>
216
                    <xsl:variable name="leadOrgId"
217
                        select="concat($namespacePrefix, '::', normalize-space(.//ld-org/id))"/>
218
                    <ROW table="organizations">
219
                        <FIELD name="_dnet_resource_identifier_">
220
                            <xsl:value-of select="$leadOrgId"/>
221
                        </FIELD>
222
                        <FIELD name="id">
223
                            <xsl:value-of select="$leadOrgId"/>
224
                        </FIELD>
225
                        <FIELD name="legalname">
226
                            <xsl:value-of select=".//ld-org/name"/>
227
                        </FIELD>
228
                        <xsl:variable name="country" select=".//ld-org/country"/>
229
                        <xsl:if test="string-length($country) &gt; 0">
230
                            <FIELD name="countryclass">
231
                                <xsl:value-of select="$country"/>
232
                            </FIELD>
233
                            <FIELD name="countryscheme">dnet:countries</FIELD>
234
                        </xsl:if>
216 235

  
217
						<FIELD name="collectedfrom">
218
							<xsl:value-of select="$parentDatasourceId"/>
219
						</FIELD>
220
						<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
221
						<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
222
					</ROW>
236
                        <FIELD name="collectedfrom">
237
                            <xsl:value-of select="$parentDatasourceId"/>
238
                        </FIELD>
239
                        <FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
240
                        <FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
241
                    </ROW>
223 242

  
224
					<ROW table="project_organization">
225
						<FIELD name="_dnet_resource_identifier_">
226
							<xsl:value-of select='concat($projectId, "@@", $leadOrgId)'/>
227
						</FIELD>
228
						<FIELD name="project">
229
							<xsl:value-of select="$projectId"/>
230
						</FIELD>
231
						<FIELD name="resporganization">
232
							<xsl:value-of select="$leadOrgId"/>
233
						</FIELD>
234
						<FIELD name="participantnumber" type="int">1</FIELD>
235
						<FIELD name="semanticclass">coordinator</FIELD>
236
						<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
237
					</ROW>
243
                    <ROW table="project_organization">
244
                        <FIELD name="_dnet_resource_identifier_">
245
                            <xsl:value-of select='concat($projectId, "@@", $leadOrgId)'/>
246
                        </FIELD>
247
                        <FIELD name="project">
248
                            <xsl:value-of select="$projectId"/>
249
                        </FIELD>
250
                        <FIELD name="resporganization">
251
                            <xsl:value-of select="$leadOrgId"/>
252
                        </FIELD>
253
                        <FIELD name="participantnumber" type="int">1</FIELD>
254
                        <FIELD name="semanticclass">coordinator</FIELD>
255
                        <FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
256
                    </ROW>
238 257

  
239
				</ROWS>
240
			</metadata>
241
		</record>
242
	</xsl:template>
258
                </ROWS>
259
            </metadata>
260
        </record>
261
    </xsl:template>
243 262

  
244 263
</xsl:stylesheet>
264

  
245 265
		]]>
246 266
		</CODE>
247 267
		</SCRIPT>

Also available in: Unified diff