Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3

    
4
	<xsl:param name="parentDatasourceId" />
5
	<xsl:param name="namespacePrefix" select="string('nsf_________')" />
6
	
7
	<xsl:template match="/">
8
		<record>
9

    
10
			<xsl:copy-of select=".//*[local-name()='header']"/>
11
			<metadata>
12
				<ROWS>
13
					<xsl:if test="string-length(normalize-space(.//AwardTitle)) &gt; 0 and string-length(normalize-space(.//AwardID)) &gt; 0">
14
						
15
						<xsl:variable name="projectId" select="concat($namespacePrefix, '::', normalize-space(.//AwardID))" />
16
						<xsl:variable name="orgId" select="concat($namespacePrefix, '::', translate(normalize-space(.//Institution/Name), ' ,.', '___'))" />
17
						<xsl:variable name="startDate" select=".//AwardEffectiveDate"/>
18
						<xsl:variable name="endDate" select=".//AwardExpirationDate"/>
19
												
20
						<ROW table="projects">
21
							<FIELD name="_dnet_resource_identifier_"><xsl:value-of select="$projectId" /></FIELD>
22
							<FIELD name="id"><xsl:value-of select="$projectId" /></FIELD>
23
							<FIELD name="code"><xsl:value-of select=".//AwardID"/></FIELD>
24
							<FIELD name="startdate" type="date" format="MM/dd/yyyy"><xsl:value-of select="$startDate" /></FIELD>
25
							<FIELD name="enddate" type="date" format="MM/dd/yyyy"><xsl:value-of  select="$endDate"/></FIELD>
26
							<FIELD name="title"><xsl:value-of select=".//AwardTitle" /></FIELD>
27
							<FIELD name="contracttypeclass"><xsl:value-of select=".//AwardInstrument/Value"/></FIELD>
28
							<FIELD name="contracttypescheme">nsf:contractTypes</FIELD>
29
							<FIELD name="acronym"> </FIELD>
30
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
31
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
32
							<FIELD name="collectedfrom"><xsl:value-of select="$parentDatasourceId" /></FIELD>
33
							<!-- <FIELD name="???"><xsl:value-of select=".//AbstractNarration" /></FIELD> -->
34
						</ROW>
35
						
36
						<ROW table="organizations">
37
							<FIELD name="_dnet_resource_identifier_"><xsl:value-of select="$orgId" /></FIELD>
38
							<FIELD name="id"><xsl:value-of select="$orgId" /></FIELD>
39
							<FIELD name="legalname"><xsl:value-of select=".//Institution/Name" /></FIELD>
40
							<FIELD name="collectedfrom"><xsl:value-of select="$parentDatasourceId" /></FIELD>
41
							<xsl:if test="string-length(normalize-space(.//Institution/CountryName)) &gt; 0">
42
								<FIELD name="countryclass"><xsl:value-of select=".//Institution/CountryName" /></FIELD>
43
							</xsl:if>
44
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
45
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
46
							<FIELD name="optional1"><xsl:value-of select=".//Institution/CityName" /></FIELD>
47
							<FIELD name="optional2"><xsl:value-of select=".//Institution/StreetAddress" /></FIELD>
48
						</ROW>					
49

    
50
						<xsl:for-each select=".//Investigator[./RoleCode='Principal Investigator'] | .//Investigator[./RoleCode='Co-Principal Investigator'] | .//Investigator[./RoleCode='Former Principal Investigator'] | .//Investigator[./RoleCode='Former Co-Principal Investigator']">
51
							<xsl:if test="position() = 1">
52
								<xsl:variable name="personName" select="normalize-space(./FirstName)"/>
53
								<xsl:variable name="personSurname" select="normalize-space(./LastName)"></xsl:variable>
54
								<xsl:if test="$personName != '' and $personSurname != '' and $personName != 'NO DATA AVAILABLE' and $personSurname != 'NO DATA AVAILABLE'">
55
									<xsl:variable name="personId" select="concat($projectId, '::', translate(concat($personName, ' ', $personSurname), ' ,.', '___'))" />
56
									<ROW table="persons">
57
										<FIELD name="_dnet_resource_identifier_"><xsl:value-of select="$personId" /></FIELD>
58
										<FIELD name="id"><xsl:value-of select="$personId" /></FIELD>
59
										<FIELD name="firstname"><xsl:value-of select="./FirstName" /></FIELD>
60
										<FIELD name="secondnames"><xsl:value-of select="./LastName" /></FIELD>
61
										<FIELD name="email"><xsl:value-of select="./EmailAddress" /></FIELD>
62
										<FIELD name="collectedfrom"><xsl:value-of select="$parentDatasourceId" /></FIELD>
63
										<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
64
										<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
65
										<FIELD name="optional1"><xsl:value-of select="./RoleCode" /></FIELD>
66
									</ROW>
67
								</xsl:if>
68
							</xsl:if>
69
						</xsl:for-each>
70
	
71
						<ROW table="project_organization">
72
							<FIELD name="_dnet_resource_identifier_"><xsl:value-of select="concat($projectId, '@@', $orgId)" /></FIELD>
73
							<FIELD name="participantnumber" type="int">1</FIELD>
74
							<FIELD name="startdate" type="date" format="MM/dd/yyyy"><xsl:value-of select="$startDate" /></FIELD>
75
							<FIELD name="enddate" type="date" format="MM/dd/yyyy"><xsl:value-of select="$endDate" /></FIELD>
76
							<FIELD name="project"><xsl:value-of select="$projectId" /></FIELD>
77
							<FIELD name="resporganization"><xsl:value-of select="$orgId" /></FIELD>
78
							<xsl:for-each select=".//Investigator[./RoleCode='Principal Investigator'] | .//Investigator[./RoleCode='Co-Principal Investigator'] | .//Investigator[./RoleCode='Former Principal Investigator'] | .//Investigator[./RoleCode='Former Co-Principal Investigator']">
79
								<xsl:if test="position() = 1">
80
									<xsl:variable name="personName" select="normalize-space(./FirstName)"/>
81
									<xsl:variable name="personSurname" select="normalize-space(./LastName)"></xsl:variable>
82
									<xsl:if test="$personName != '' and $personSurname != '' and $personName != 'NO DATA AVAILABLE' and $personSurname != 'NO DATA AVAILABLE'">
83
										<FIELD name="contactperson"><xsl:value-of select="concat($projectId, '::', translate(concat($personName, ' ', $personSurname), ' ,.', '___'))" /></FIELD>
84
									</xsl:if>
85
								</xsl:if>
86
							</xsl:for-each>
87

    
88
							<FIELD name="semanticclass">coordinator</FIELD>
89
							<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
90
						</ROW>
91
						
92
						<xsl:for-each select=".//FoaInformation">
93
							<xsl:variable name="subjectId" select="concat($namespacePrefix, '::', normalize-space(./Code))"/>
94
														
95
							<ROW table="subjects">
96
								<FIELD name="_dnet_resource_identifier_"><xsl:value-of select="$subjectId" /></FIELD>
97
								<FIELD name="id"><xsl:value-of select="$subjectId" /></FIELD>
98
								<FIELD name="name"><xsl:value-of select="./Name" /></FIELD>
99
								<FIELD name="semanticclass">nsf:fieldOfApplication</FIELD>
100
								<FIELD name="semanticscheme">dnet:subject_classification_typologies</FIELD>
101
							</ROW>
102
	
103
							<ROW table="project_subject">
104
								<FIELD name="_dnet_resource_identifier_"><xsl:value-of select="concat($projectId, '@@', $subjectId)" /></FIELD>
105
								<FIELD name="project"><xsl:value-of select="$projectId" /></FIELD>
106
								<FIELD name="subject"><xsl:value-of select="$subjectId" /></FIELD>
107
							</ROW>
108
						</xsl:for-each>
109
						<!--
110
						<xsl:for-each select=".//ProgramElement">
111
							<xsl:if test="string-length(normalize-space(./Code)) &gt; 0">
112
								<xsl:variable name="fundingId" select="concat($namespacePrefix, '::NSF::PEC::', normalize-space(./Code))" />
113
								<ROW table="project_fundingpath">
114
									<FIELD name="_dnet_resource_identifier_"><xsl:value-of select="concat($fundingId,'@@', $projectId)" /></FIELD>
115
									<FIELD name="funding"><xsl:value-of select="$fundingId" /></FIELD>
116
									<FIELD name="project"><xsl:value-of select="$projectId" /></FIELD>
117
									<FIELD name="startdate" type="date" format="MM/dd/yyyy"><xsl:value-of select="$startDate" /></FIELD>
118
									<FIELD name="enddate" type="date" format="MM/dd/yyyy"><xsl:value-of select="$endDate" /></FIELD>
119
								</ROW>
120
							</xsl:if>
121
						</xsl:for-each>
122

    
123
						<xsl:for-each select=".//ProgramReference">
124
							<xsl:if test="string-length(normalize-space(./Code)) &gt; 0">
125
								<xsl:variable name="fundingId" select="concat($namespacePrefix, '::NSF::PRC::', normalize-space(./Code))"/>
126
								<ROW table="project_fundingpath">
127
									<FIELD name="_dnet_resource_identifier_"><xsl:value-of select="concat($fundingId,'@@', $projectId)" /></FIELD>
128
									<FIELD name="funding"><xsl:value-of select="$fundingId" /></FIELD>
129
									<FIELD name="project"><xsl:value-of select="$projectId" /></FIELD>
130
									<FIELD name="startdate" type="date" format="MM/dd/yyyy"><xsl:value-of select="$startDate" /></FIELD>
131
									<FIELD name="enddate" type="date" format="MM/dd/yyyy"><xsl:value-of select="$endDate" /></FIELD>
132
								</ROW>
133
							</xsl:if>
134
						</xsl:for-each>
135
						-->
136

    
137
						
138
						<xsl:for-each select="//funding">
139
							<xsl:variable name="directorate" select="normalize-space(./orgDirectorateAbbr)"/>
140
							<xsl:variable name="division" select="normalize-space(./orgDivisionAbbr)"/>
141
							<xsl:variable name="fundingId">
142
								<xsl:choose>
143
									<xsl:when test="string-length($directorate) &gt; 0">
144
										<xsl:choose>
145
											<xsl:when test="string-length($division) &gt; 0">
146
												<xsl:value-of select="concat($namespacePrefix, '::NSF::', $directorate, '::', $division)"/>
147
											</xsl:when>
148
											<xsl:otherwise>
149
												<xsl:value-of select="concat($namespacePrefix, '::NSF::', $directorate)"/>
150
											</xsl:otherwise>
151
										</xsl:choose>
152
									</xsl:when>
153
									<xsl:otherwise>
154
										<xsl:value-of select="concat($namespacePrefix, '::NSF')"/>
155
									</xsl:otherwise>
156
								</xsl:choose>
157
							</xsl:variable>
158

    
159
							<ROW table="project_fundingpath">
160
								<FIELD name="_dnet_resource_identifier_">
161
									<xsl:value-of select="concat($fundingId,'@@', $projectId)"/>
162
								</FIELD>
163
								<FIELD name="funding">
164
									<xsl:value-of select="$fundingId"/>
165
								</FIELD>
166
								<FIELD name="project">
167
									<xsl:value-of select="$projectId"/>
168
								</FIELD>
169
								<FIELD name="startdate" type="date" format="MM/dd/yyyy">
170
									<xsl:value-of select="$startDate"/>
171
								</FIELD>
172
								<FIELD name="enddate" type="date" format="MM/dd/yyyy">
173
									<xsl:value-of select="$endDate"/>
174
								</FIELD>
175
							</ROW>
176
						</xsl:for-each>
177

    
178
						<!-- If there is no funding element at all, let's add a funding path that contains only the funder. -->
179
						<xsl:if test="not(//funding)">
180
							<xsl:variable name="fundingId" select="concat($namespacePrefix, '::NSF')"/>
181
							<ROW table="project_fundingpath">
182
								<FIELD name="_dnet_resource_identifier_">
183
									<xsl:value-of select="concat($fundingId,'@@', $projectId)"/>
184
								</FIELD>
185
								<FIELD name="funding">
186
									<xsl:value-of select="$fundingId"/>
187
								</FIELD>
188
								<FIELD name="project">
189
									<xsl:value-of select="$projectId"/>
190
								</FIELD>
191
								<FIELD name="startdate" type="date" format="MM/dd/yyyy">
192
									<xsl:value-of select="$startDate"/>
193
								</FIELD>
194
								<FIELD name="enddate" type="date" format="MM/dd/yyyy">
195
									<xsl:value-of select="$endDate"/>
196
								</FIELD>
197
							</ROW>
198
						</xsl:if>
199

    
200
					</xsl:if>
201
				</ROWS>
202
			</metadata>
203
		</record>
204
	</xsl:template>
205

    
206
	<xsl:template name="getContactPersonId">
207
		<xsl:param name="projectID"/>
208
		<xsl:for-each select=".//Investigator[./RoleCode='Principal Investigator'] | .//Investigator[./RoleCode='Co-Principal Investigator'] | .//Investigator[./RoleCode='Former Principal Investigator'] | .//Investigator[./RoleCode='Former Co-Principal Investigator']">
209
			<xsl:if test="position() = 1">
210
				<xsl:variable name="personName" select="normalize-space(./FirstName)"/>
211
				<xsl:variable name="personSurname" select="normalize-space(./LastName)"></xsl:variable>
212
				<xsl:choose>
213
					<xsl:when test="$personName != '' and $personSurname != '' and $personName != 'NO DATA AVAILABLE' and $personSurname != 'NO DATA AVAILABLE'">
214
						<xsl:value-of select="concat($projectID, '::', translate(concat($personName, ' ', $personSurname), ' ,.', '___'))" />
215
					</xsl:when>
216
					<xsl:otherwise><xsl:value-of select="string('NA')"/></xsl:otherwise>
217
				</xsl:choose>
218
			</xsl:if>
219
		</xsl:for-each>
220
	</xsl:template>
221
</xsl:stylesheet>
(15-15/26)