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="2.0">
5

    
6
	<xsl:param name="parentDatasourceId"/>
7
	<xsl:param name="namespacePrefix"/>
8
	<xsl:param name="quote">"</xsl:param>
9

    
10
	<xsl:variable name="funderID" select="concat($namespacePrefix, '::WT')"/>
11

    
12
	<xsl:variable name="stream" select="normalize-space(.//Grant/Stream)"/>
13
	<xsl:variable name="fundingID">
14
		<xsl:choose>
15
			<xsl:when test="string-length($stream) &gt; 0">
16
				<xsl:value-of select="concat($funderID, '::', $stream)"/>
17
			</xsl:when>
18
			<xsl:otherwise>
19
				<xsl:value-of select="$funderID"/>
20
			</xsl:otherwise>
21
		</xsl:choose>
22
	</xsl:variable>
23

    
24
	<xsl:variable name="projectID" select="concat($namespacePrefix, '::', .//Grant/Id)"/>
25

    
26
	<xsl:variable name="orgID" select="concat($namespacePrefix, '::', translate(.//Institution/Name, ' ,', '__'))"/>
27
	<!--
28
		personID is fine as long as WT gives us one person per project. If they fix their export, we might have 2 persons (or more).
29
		At this stage we are somehow fine to loose one of the persons (the second project with the same id overwrites the previous project
30
	 -->
31
	<xsl:variable name="personID" select="concat($namespacePrefix, '::', .//Person/Alias[@Source='Wellcome Trust'])"/>
32
	<xsl:variable name="startDate" select="translate(.//Grant/StartDate,'/\','--')"/>
33
	<xsl:variable name="endDate" select="translate(.//Grant/EndDate,'/\','--')"/>
34

    
35
	<xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/>
36

    
37
	<xsl:template name="getJson">
38
		<xsl:param name="varName"/>
39
		<xsl:param name="value"/>
40
		<xsl:value-of select="concat($quote, $varName, $quote, ':', $quote, $value, $quote)"/>
41
	</xsl:template>
42

    
43
	<xsl:template match="/">
44
		<record>
45

    
46
			<xsl:copy-of select=".//*[local-name()='header']"/>
47
			<metadata>
48
				<ROWS>
49
					<xsl:if test="string-length(normalize-space(.//Grant/Title)) &gt; 0 and string-length($projectID) &gt; 0">
50
						<ROW table="projects">
51
							<FIELD name="_dnet_resource_identifier_">
52
								<xsl:value-of select="$projectID"/>
53
							</FIELD>
54
							<FIELD name="id">
55
								<xsl:value-of select="$projectID"/>
56
							</FIELD>
57
							<FIELD name="code">
58
								<xsl:value-of select=".//Grant/Id"/>
59
							</FIELD>
60
							<FIELD name="startdate" type="date" format="{$dateFormat}">
61
								<xsl:value-of select="$startDate"/>
62
							</FIELD>
63
							<FIELD name="enddate" type="date" format="{$dateFormat}">
64
								<xsl:value-of select="$endDate"/>
65
							</FIELD>
66
							<FIELD name="title">
67
								<xsl:value-of select=".//Grant/Title"/>
68
							</FIELD>
69
							<FIELD name="contracttypeclass">UNKNOWN</FIELD>
70
							<FIELD name="contracttypescheme">wt:contractTypes</FIELD>
71

    
72
							<FIELD name="acronym"></FIELD>
73
							<FIELD name="keywords">
74
								<xsl:value-of select="normalize-space(.//Grant/Type)"/>
75
							</FIELD>
76
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
77
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
78
							<FIELD name="collectedfrom">
79
								<xsl:value-of select="$parentDatasourceId"/>
80
							</FIELD>
81
							<FIELD name="optional1">
82
								<xsl:value-of select="concat(.//Grant/Amount, ' ', .//Grant/Amount/@Currency)"/>
83
							</FIELD>
84
							<xsl:if test="string-length(normalize-space(.//Grant/Alias[1]/text())) > 0">
85
								<xsl:variable name="projectAlias">
86
									<xsl:call-template name="getJson">
87
										<xsl:with-param name="varName">alias</xsl:with-param>
88
										<xsl:with-param name="value">
89
											<xsl:value-of select=".//Grant/Alias[1]"/>
90
										</xsl:with-param>
91
									</xsl:call-template>
92
								</xsl:variable>
93
								<xsl:variable name="jsonExtra">
94
									<xsl:value-of select="concat('{', $projectAlias, '}')"/>
95
								</xsl:variable>
96
								<FIELD name="jsonextrainfo">
97
									<xsl:value-of select="$jsonExtra"/>
98
								</FIELD>
99
							</xsl:if>
100
							<!-- oa_mandate_for_publications is true for projects started after 2005 -->
101
							<xsl:choose>
102
								<!-- Invalid date: we need at least YYYY -->
103
								<xsl:when test="string-length($startDate) &lt; 4">
104
									<FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD>
105
								</xsl:when>
106
								<xsl:when test="xs:date($startDate) >= xs:date('2015-01-01')">
107
									<FIELD name="oa_mandate_for_publications" type="boolean">true</FIELD>
108
								</xsl:when>
109
								<xsl:otherwise><FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD></xsl:otherwise>
110
							</xsl:choose>
111

    
112
							<xsl:variable name="personSurname" select=".//Person/FamilyName"/>
113
							<xsl:variable name="personFirstName" select=".//Person/GivenName"/>
114
							<xsl:variable name="contactfullname">
115
								<xsl:choose>
116
									<xsl:when test="string-length($personFirstName) &gt; 0 and string-length($personSurname) &gt; 0">
117
										<xsl:value-of select="normalize-space(concat($personSurname, ', ', $personFirstName))"/>
118
									</xsl:when>
119
									<xsl:when test="string-length($personFirstName) &gt; 0">
120
										<xsl:value-of select="normalize-space($personFirstName)"/>
121
									</xsl:when>
122
									<xsl:when test="string-length($personSurname) &gt; 0">
123
										<xsl:value-of select="normalize-space($personSurname)"/>
124
									</xsl:when>
125
									<xsl:otherwise>
126
										<xsl:value-of select="''"/>
127
									</xsl:otherwise>
128
								</xsl:choose>
129
							</xsl:variable>
130
							<xsl:if test="string-length($contactfullname) &gt; 0">
131
								<FIELD name="contactfullname">
132
									<xsl:value-of select="$contactfullname"/>
133
								</FIELD>
134
							</xsl:if>
135

    
136
						</ROW>
137

    
138
						<ROW table="project_fundingpath">
139
							<FIELD name="_dnet_resource_identifier_">
140
								<xsl:value-of select="concat($fundingID,'@@', $projectID)"/>
141
							</FIELD>
142
							<FIELD name="funding">
143
								<xsl:value-of select="$fundingID"/>
144
							</FIELD>
145
							<FIELD name="project">
146
								<xsl:value-of select="$projectID"/>
147
							</FIELD>
148
							<FIELD name="startdate" type="date" format="{$dateFormat}">
149
								<xsl:value-of select="$startDate"/>
150
							</FIELD>
151
							<FIELD name="enddate" type="date" format="{$dateFormat}">
152
								<xsl:value-of select="$endDate"/>
153
							</FIELD>
154
						</ROW>
155
						<xsl:if test="not(concat($namespacePrefix, '::') = $orgID)">
156
							<ROW table="organizations">
157
								<FIELD name="_dnet_resource_identifier_">
158
									<xsl:value-of select="$orgID"/>
159
								</FIELD>
160
								<FIELD name="id">
161
									<xsl:value-of select="$orgID"/>
162
								</FIELD>
163
								<FIELD name="legalname">
164
									<xsl:value-of select=".//Institution/Name"/>
165
								</FIELD>
166
								<FIELD name="collectedfrom">
167
									<xsl:value-of select="$parentDatasourceId"/>
168
								</FIELD>
169
								<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
170
								<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
171
								<FIELD name="trust" type="float">0.8</FIELD>
172
							</ROW>
173
							<ROW table="project_organization">
174
								<FIELD name="_dnet_resource_identifier_">
175
									<xsl:value-of select="concat($projectID, '@@', $orgID)"/>
176
								</FIELD>
177
								<FIELD name="participantnumber" type="int">1</FIELD>
178
								<FIELD name="startdate" type="date" format="{$dateFormat}">
179
									<xsl:value-of select="$startDate"/>
180
								</FIELD>
181
								<FIELD name="enddate" type="date" format="{$dateFormat}">
182
									<xsl:value-of select="$endDate"/>
183
								</FIELD>
184
								<FIELD name="project">
185
									<xsl:value-of select="$projectID"/>
186
								</FIELD>
187
								<FIELD name="resporganization">
188
									<xsl:value-of select="$orgID"/>
189
								</FIELD>
190
								<FIELD name="semanticclass">coordinator</FIELD>
191
								<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
192
							</ROW>
193
						</xsl:if>
194
					</xsl:if>
195
				</ROWS>
196
			</metadata>
197
		</record>
198
	</xsl:template>
199
</xsl:stylesheet>
(27-27/27)