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

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

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

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

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

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

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

    
69
							<FIELD name="acronym"></FIELD>
70
							<FIELD name="keywords"><xsl:value-of select="normalize-space(.//Grant/Type)"/></FIELD>
71
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
72
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
73
							<FIELD name="collectedfrom">
74
								<xsl:value-of select="$parentDatasourceId"/>
75
							</FIELD>
76
							<FIELD name="optional1">
77
								<xsl:value-of select="concat(.//Grant/Amount, ' ', .//Grant/Amount/@Currency)"/>
78
							</FIELD>
79
							<xsl:if test="string-length(normalize-space(.//Grant/Alias/text())) > 0">
80
								<xsl:variable name="projectAlias">
81
									<xsl:call-template name="getJson">
82
										<xsl:with-param name="varName">alias</xsl:with-param>
83
										<xsl:with-param name="value"><xsl:value-of select=".//Grant/Alias"/></xsl:with-param>
84
									</xsl:call-template>
85
								</xsl:variable>
86
								<xsl:variable name="jsonExtra">
87
									<xsl:value-of select="concat('{', $projectAlias, '}')"/>
88
								</xsl:variable>
89
								<FIELD name="jsonextrainfo"><xsl:value-of select="$jsonExtra"/></FIELD>
90
							</xsl:if>
91
						</ROW>
92

    
93
						<ROW table="project_fundingpath">
94
							<FIELD name="_dnet_resource_identifier_">
95
								<xsl:value-of select="concat($fundingID,'@@', $projectID)"/>
96
							</FIELD>
97
							<FIELD name="funding">
98
								<xsl:value-of select="$fundingID"/>
99
							</FIELD>
100
							<FIELD name="project">
101
								<xsl:value-of select="$projectID"/>
102
							</FIELD>
103
							<FIELD name="startdate" type="date" format="{$dateFormat}">
104
								<xsl:value-of select="$startDate"/>
105
							</FIELD>
106
							<FIELD name="enddate" type="date" format="{$dateFormat}">
107
								<xsl:value-of select="$endDate"/>
108
							</FIELD>
109
						</ROW>
110
						<ROW table="persons">
111
							<FIELD name="_dnet_resource_identifier_">
112
								<xsl:value-of select="$personID"/>
113
							</FIELD>
114
							<FIELD name="id">
115
								<xsl:value-of select="$personID"/>
116
							</FIELD>
117
							<FIELD name="firstname">
118
								<xsl:value-of select=".//Person/GivenName"/>
119
							</FIELD>
120
							<FIELD name="secondnames">
121
								<xsl:value-of select=".//Person/FamilyName"/>
122
							</FIELD>
123
							<FIELD name="collectedfrom">
124
								<xsl:value-of select="$parentDatasourceId"/>
125
							</FIELD>
126
							<FIELD name="optional1">
127
								<xsl:value-of select=".//Person/Title"/>
128
							</FIELD>
129
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
130
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
131
						</ROW>
132
						<xsl:if test="string-length($orgID) &gt; 4">
133
							<ROW table="organizations">
134
								<FIELD name="_dnet_resource_identifier_">
135
									<xsl:value-of select="$orgID"/>
136
								</FIELD>
137
								<FIELD name="id">
138
									<xsl:value-of select="$orgID"/>
139
								</FIELD>
140
								<FIELD name="legalname">
141
									<xsl:value-of select=".//Institution/Name"/>
142
								</FIELD>
143
								<FIELD name="collectedfrom">
144
									<xsl:value-of select="$parentDatasourceId"/>
145
								</FIELD>
146
								<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
147
								<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
148
								<FIELD name="trust" type="float">0.8</FIELD>
149
							</ROW>
150
							<ROW table="project_organization">
151
								<FIELD name="_dnet_resource_identifier_">
152
									<xsl:value-of select="concat($projectID, '@@', $orgID)"/>
153
								</FIELD>
154
								<FIELD name="participantnumber" type="int">1</FIELD>
155
								<FIELD name="startdate" type="date" format="{$dateFormat}">
156
									<xsl:value-of select="$startDate"/>
157
								</FIELD>
158
								<FIELD name="enddate" type="date" format="{$dateFormat}">
159
									<xsl:value-of select="$endDate"/>
160
								</FIELD>
161
								<FIELD name="project">
162
									<xsl:value-of select="$projectID"/>
163
								</FIELD>
164
								<FIELD name="resporganization">
165
									<xsl:value-of select="$orgID"/>
166
								</FIELD>
167
								<FIELD name="contactperson">
168
									<xsl:value-of select="$personID"/>
169
								</FIELD>
170
								<FIELD name="semanticclass">coordinator</FIELD>
171
								<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
172
							</ROW>
173
						</xsl:if>
174
					</xsl:if>
175
				</ROWS>
176
			</metadata>
177
		</record>
178
	</xsl:template>
179
</xsl:stylesheet>
(24-24/24)