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"/>
6
	<xsl:param name="quote">"</xsl:param>
7

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

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

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

    
24
	<xsl:variable name="orgID" select="concat($namespacePrefix, '::', translate(.//Institution/Name, ' ,', '__'))"/>
25
	<!--
26
		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).
27
		At this stage we are somehow fine to loose one of the persons (the second project with the same id overwrites the previous project
28
	 -->
29
	<xsl:variable name="personID" select="concat($namespacePrefix, '::', .//Person/Alias[@Source='Wellcome Trust'])"/>
30
	<xsl:variable name="startDate" select="translate(.//Grant/StartDate,'/\','--')"/>
31
	<xsl:variable name="endDate" select="translate(.//Grant/EndDate,'/\','--')"/>
32

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

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

    
41
	<xsl:template match="/">
42
		<record>
43

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

    
70
							<FIELD name="acronym"></FIELD>
71
							<FIELD name="keywords"><xsl:value-of select="normalize-space(.//Grant/Type)"/></FIELD>
72
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
73
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
74
							<FIELD name="collectedfrom">
75
								<xsl:value-of select="$parentDatasourceId"/>
76
							</FIELD>
77
							<FIELD name="optional1">
78
								<xsl:value-of select="concat(.//Grant/Amount, ' ', .//Grant/Amount/@Currency)"/>
79
							</FIELD>
80
							<xsl:if test="string-length(normalize-space(.//Grant/Alias/text())) > 0">
81
								<xsl:variable name="projectAlias">
82
									<xsl:call-template name="getJson">
83
										<xsl:with-param name="varName">alias</xsl:with-param>
84
										<xsl:with-param name="value"><xsl:value-of select=".//Grant/Alias"/></xsl:with-param>
85
									</xsl:call-template>
86
								</xsl:variable>
87
								<xsl:variable name="jsonExtra">
88
									<xsl:value-of select="concat('{', $projectAlias, '}')"/>
89
								</xsl:variable>
90
								<FIELD name="jsonextrainfo"><xsl:value-of select="$jsonExtra"/></FIELD>
91
							</xsl:if>
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
						<ROW table="persons">
112
							<FIELD name="_dnet_resource_identifier_">
113
								<xsl:value-of select="$personID"/>
114
							</FIELD>
115
							<FIELD name="id">
116
								<xsl:value-of select="$personID"/>
117
							</FIELD>
118
							<FIELD name="firstname">
119
								<xsl:value-of select=".//Person/GivenName"/>
120
							</FIELD>
121
							<FIELD name="secondnames">
122
								<xsl:value-of select=".//Person/FamilyName"/>
123
							</FIELD>
124
							<FIELD name="collectedfrom">
125
								<xsl:value-of select="$parentDatasourceId"/>
126
							</FIELD>
127
							<FIELD name="optional1">
128
								<xsl:value-of select=".//Person/Title"/>
129
							</FIELD>
130
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
131
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
132
						</ROW>
133
						<xsl:if test="not(concat($namespacePrefix, '::') = $orgID)">
134
							<ROW table="organizations">
135
								<FIELD name="_dnet_resource_identifier_">
136
									<xsl:value-of select="$orgID"/>
137
								</FIELD>
138
								<FIELD name="id">
139
									<xsl:value-of select="$orgID"/>
140
								</FIELD>
141
								<FIELD name="legalname">
142
									<xsl:value-of select=".//Institution/Name"/>
143
								</FIELD>
144
								<FIELD name="collectedfrom">
145
									<xsl:value-of select="$parentDatasourceId"/>
146
								</FIELD>
147
								<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
148
								<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
149
								<FIELD name="trust" type="float">0.8</FIELD>
150
							</ROW>
151
							<ROW table="project_organization">
152
								<FIELD name="_dnet_resource_identifier_">
153
									<xsl:value-of select="concat($projectID, '@@', $orgID)"/>
154
								</FIELD>
155
								<FIELD name="participantnumber" type="int">1</FIELD>
156
								<FIELD name="startdate" type="date" format="{$dateFormat}">
157
									<xsl:value-of select="$startDate"/>
158
								</FIELD>
159
								<FIELD name="enddate" type="date" format="{$dateFormat}">
160
									<xsl:value-of select="$endDate"/>
161
								</FIELD>
162
								<FIELD name="project">
163
									<xsl:value-of select="$projectID"/>
164
								</FIELD>
165
								<FIELD name="resporganization">
166
									<xsl:value-of select="$orgID"/>
167
								</FIELD>
168
								<FIELD name="contactperson">
169
									<xsl:value-of select="$personID"/>
170
								</FIELD>
171
								<FIELD name="semanticclass">coordinator</FIELD>
172
								<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
173
							</ROW>
174
						</xsl:if>
175
					</xsl:if>
176
				</ROWS>
177
			</metadata>
178
		</record>
179
	</xsl:template>
180
</xsl:stylesheet>
(25-25/25)