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

    
5
	<xsl:param name="parentDatasourceId"/>
6
	<xsl:param name="namespacePrefix"/>
7

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

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

    
21
	<xsl:variable name="fundingID" select="normalize-space($fundingIDtemp)"/>
22
	<xsl:variable name="projectID" select="concat($namespacePrefix, '::', .//Grant/Id)"/>
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 match="/">
35
		<record
36
		>
37

    
38
			<xsl:copy-of select=".//*[local-name()='header']"/>
39
			<metadata>
40
				<ROWS>
41
					<xsl:if test="string-length(normalize-space(.//Grant/Title)) &gt; 0 and string-length($projectID) &gt; 0">
42
						<ROW table="projects">
43
							<FIELD name="_dnet_resource_identifier_">
44
								<xsl:value-of select="$projectID"/>
45
							</FIELD>
46
							<FIELD name="id">
47
								<xsl:value-of select="$projectID"/>
48
							</FIELD>
49
							<FIELD name="code">
50
								<xsl:value-of select=".//Grant/Id"/>
51
							</FIELD>
52
							<FIELD name="startdate" type="date" format="{$dateFormat}">
53
								<xsl:value-of select="$startDate"/>
54
							</FIELD>
55
							<FIELD name="enddate" type="date" format="{$dateFormat}">
56
								<xsl:value-of select="$endDate"/>
57
							</FIELD>
58
							<FIELD name="title">
59
								<xsl:value-of select=".//Grant/Title"/>
60
							</FIELD>
61
							<FIELD name="contracttypeclass">UNKNOWN</FIELD>
62
							<FIELD name="contracttypescheme">wt:contractTypes</FIELD>
63
							<FIELD name="acronym"></FIELD>
64
							<FIELD name="keywords">
65
								<xsl:value-of select=".//Grant/Type"/>
66
							</FIELD>
67
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
68
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
69
							<FIELD name="collectedfrom">
70
								<xsl:value-of select="$parentDatasourceId"/>
71
							</FIELD>
72
							<FIELD name="optional1">
73
								<xsl:value-of select="concat(.//Grant/Amount, ' ', .//Grant/Amount/@Currency)"/>
74
							</FIELD>
75
						</ROW>
76
						<ROW table="project_fundingpath">
77
							<FIELD name="_dnet_resource_identifier_">
78
								<xsl:value-of select="concat($fundingID,'@@', $projectID)"/>
79
							</FIELD>
80
							<FIELD name="funding">
81
								<xsl:value-of select="$fundingID"/>
82
							</FIELD>
83
							<FIELD name="project">
84
								<xsl:value-of select="$projectID"/>
85
							</FIELD>
86
							<FIELD name="startdate" type="date" format="{$dateFormat}">
87
								<xsl:value-of select="$startDate"/>
88
							</FIELD>
89
							<FIELD name="enddate" type="date" format="{$dateFormat}">
90
								<xsl:value-of select="$endDate"/>
91
							</FIELD>
92
						</ROW>
93
						<ROW table="persons">
94
							<FIELD name="_dnet_resource_identifier_">
95
								<xsl:value-of select="$personID"/>
96
							</FIELD>
97
							<FIELD name="id">
98
								<xsl:value-of select="$personID"/>
99
							</FIELD>
100
							<FIELD name="firstname">
101
								<xsl:value-of select=".//Person/GivenName"/>
102
							</FIELD>
103
							<FIELD name="secondnames">
104
								<xsl:value-of select=".//Person/FamilyName"/>
105
							</FIELD>
106
							<FIELD name="collectedfrom">
107
								<xsl:value-of select="$parentDatasourceId"/>
108
							</FIELD>
109
							<FIELD name="optional1">
110
								<xsl:value-of select=".//Person/Title"/>
111
							</FIELD>
112
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
113
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
114
						</ROW>
115
						<xsl:if test="string-length($orgID) &gt; 4">
116
							<ROW table="organizations">
117
								<FIELD name="_dnet_resource_identifier_">
118
									<xsl:value-of select="$orgID"/>
119
								</FIELD>
120
								<FIELD name="id">
121
									<xsl:value-of select="$orgID"/>
122
								</FIELD>
123
								<FIELD name="legalname">
124
									<xsl:value-of select=".//Institution/Name"/>
125
								</FIELD>
126
								<FIELD name="collectedfrom">
127
									<xsl:value-of select="$parentDatasourceId"/>
128
								</FIELD>
129
								<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
130
								<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
131
								<FIELD name="trust" type="float">0.8</FIELD>
132
							</ROW>
133
							<ROW table="project_organization">
134
								<FIELD name="_dnet_resource_identifier_">
135
									<xsl:value-of select="concat($projectID, '@@', $orgID)"/>
136
								</FIELD>
137
								<FIELD name="participantnumber" type="int">1</FIELD>
138
								<FIELD name="startdate" type="date" format="{$dateFormat}">
139
									<xsl:value-of select="$startDate"/>
140
								</FIELD>
141
								<FIELD name="enddate" type="date" format="{$dateFormat}">
142
									<xsl:value-of select="$endDate"/>
143
								</FIELD>
144
								<FIELD name="project">
145
									<xsl:value-of select="$projectID"/>
146
								</FIELD>
147
								<FIELD name="resporganization">
148
									<xsl:value-of select="$orgID"/>
149
								</FIELD>
150
								<FIELD name="contactperson">
151
									<xsl:value-of select="$personID"/>
152
								</FIELD>
153
								<FIELD name="semanticclass">coordinator</FIELD>
154
								<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
155
							</ROW>
156
						</xsl:if>
157
					</xsl:if>
158
				</ROWS>
159
			</metadata>
160
		</record>
161
	</xsl:template>
162
</xsl:stylesheet>
(21-21/21)