Project

General

Profile

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

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

    
8
	<xsl:template name="formatDate">
9
		<xsl:param name="datename"/>
10
		<xsl:param name="datevalue"/>
11
		<xsl:choose>
12
			<xsl:when test="string-length($datevalue) = 4 and $datename = 'startdate'">
13
				<FIELD name="{$datename}" type="date" format="yyyy-MM-dd">
14
					<xsl:value-of select="concat($datevalue, '-01-01')"/>
15
				</FIELD>
16
			</xsl:when>
17
			<xsl:when test="string-length($datevalue) = 4 and $datename = 'enddate'">
18
				<FIELD name="{$datename}" type="date" format="yyyy-MM-dd">
19
					<xsl:value-of select="concat($datevalue, '-12-31')"/>
20
				</FIELD>
21
			</xsl:when>
22
			<xsl:when test="string-length($datevalue) = 10">
23
				<FIELD name="{$datename}" type="date" format="yyyy-MM-dd">
24
					<xsl:value-of select="$datevalue"/>
25
				</FIELD>
26
			</xsl:when>
27
		</xsl:choose>
28
	</xsl:template>
29

    
30
	<xsl:variable name="namespacePrefix" select="string('irb_hr______')"/>
31

    
32
	<xsl:template match="/">
33
		<record>
34
			<xsl:if test="contains(//column[@name='FUNDER_NAME'], $funderAcronym)">
35

    
36
				<xsl:variable name="fundingId" select="normalize-space(concat($namespacePrefix, '::', $funderAcronym))"/>
37
				<xsl:copy-of select=".//*[local-name()='header']"/>
38
				<metadata>
39
					<ROWS>
40
						<xsl:variable name="projectId" select="concat($namespacePrefix, '::', normalize-space(//column[@name = 'PROJECT_IDENTIFIER']))"/>
41
						<xsl:variable name="projectTitle">
42
							<xsl:choose>
43
								<xsl:when test="//column[@name = 'PROJECT_TITLE'] != ''">
44
									<xsl:value-of select="//column[@name = 'PROJECT_TITLE']"/>
45
								</xsl:when>
46
								<xsl:otherwise>
47
									<xsl:value-of select="//column[@name = 'PROJECT_IDENTIFIER']"/>
48
								</xsl:otherwise>
49
							</xsl:choose>
50
						</xsl:variable>
51

    
52
						<ROW table="projects">
53
							<FIELD name="_dnet_resource_identifier_">
54
								<xsl:value-of select="$projectId"/>
55
							</FIELD>
56
							<FIELD name="id">
57
								<xsl:value-of select="$projectId"/>
58
							</FIELD>
59
							<FIELD name="code">
60
								<xsl:value-of select="//column[@name = 'PROJECT_IDENTIFIER']"/>
61
							</FIELD>
62
							<FIELD name="title">
63
								<xsl:value-of select="$projectTitle"/>
64
							</FIELD>
65
							<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
66
							<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
67
							<FIELD name="collectedfrom">
68
								<xsl:value-of select="$parentDatasourceId"/>
69
							</FIELD>
70
							<xsl:call-template name="formatDate">
71
								<xsl:with-param name="datename">startdate</xsl:with-param>
72
								<xsl:with-param name="datevalue" select="//column[@name = 'START_DATE']"></xsl:with-param>
73
							</xsl:call-template>
74
							<xsl:call-template name="formatDate">
75
								<xsl:with-param name="datename">enddate</xsl:with-param>
76
								<xsl:with-param name="datevalue" select="//column[@name = 'END_DATE']"></xsl:with-param>
77
							</xsl:call-template>
78
						</ROW>
79
						<xsl:if test="string-length(normalize-space(//column[@name = 'ORGANIZATION_INVOLVED'])) &gt; 0">
80
							<xsl:variable name="organizationId" select="concat($namespacePrefix, '::', normalize-space(//column[@name = 'ORGANIZATION_INVOLVED']))"/>
81
							<ROW table="organizations">
82
								<FIELD name="_dnet_resource_identifier_">
83
									<xsl:value-of select="$organizationId"/>
84
								</FIELD>
85
								<FIELD name="id">
86
									<xsl:value-of select="$organizationId"/>
87
								</FIELD>
88
								<FIELD name="legalname">
89
									<xsl:value-of select="//column[@name = 'ORGANIZATION_INVOLVED']"/>
90
								</FIELD>
91
								<FIELD name="countryclass">HR</FIELD>
92
								<FIELD name="countryscheme">dnet:countries</FIELD>
93
								<FIELD name="collectedfrom">
94
									<xsl:value-of select="$parentDatasourceId"/>
95
								</FIELD>
96
								<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
97
								<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
98
							</ROW>
99
							<ROW table="project_organization">
100
								<FIELD name="_dnet_resource_identifier_">
101
									<xsl:value-of select='concat($projectId, "@@", $organizationId)'/>
102
								</FIELD>
103
								<FIELD name="project">
104
									<xsl:value-of select="$projectId"/>
105
								</FIELD>
106
								<FIELD name="resporganization">
107
									<xsl:value-of select="$organizationId"/>
108
								</FIELD>
109
								<FIELD name="participantnumber" type="int">1</FIELD>
110
								<FIELD name="semanticclass">coordinator</FIELD>
111
								<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD>
112
							</ROW>
113
						</xsl:if>
114
						<xsl:if test="string-length($fundingId) &gt; 0">
115
							<ROW table="project_fundingpath">
116
								<FIELD name="_dnet_resource_identifier_">
117
									<xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
118
								</FIELD>
119
								<FIELD name="funding">
120
									<xsl:value-of select="$fundingId"/>
121
								</FIELD>
122
								<FIELD name="project">
123
									<xsl:value-of select="$projectId"/>
124
								</FIELD>
125
								<xsl:call-template name="formatDate">
126
									<xsl:with-param name="datename">startdate</xsl:with-param>
127
									<xsl:with-param name="datevalue" select="//column[@name = 'START_DATE']"></xsl:with-param>
128
								</xsl:call-template>
129
								<xsl:call-template name="formatDate">
130
									<xsl:with-param name="datename">enddate</xsl:with-param>
131
									<xsl:with-param name="datevalue" select="//column[@name = 'END_DATE']"></xsl:with-param>
132
								</xsl:call-template>
133
							</ROW>
134
						</xsl:if>
135
					</ROWS>
136
				</metadata>
137

    
138
			</xsl:if>
139
		</record>
140
	</xsl:template>
141
</xsl:stylesheet>
(8-8/31)