Revision 48139
Added by Alessia Bardi over 6 years ago
fwf_2_db.xsl | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
|
2 |
<xsl:stylesheet xmlns:fwf="eu.dnetlib.data.transform.xml.FWFXsltFunctions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
|
3 | 3 |
|
4 | 4 |
<xsl:param name="parentDatasourceId"/> |
5 | 5 |
<xsl:param name="namespacePrefix"/> |
6 | 6 |
|
7 | 7 |
<xsl:variable name="funderID" select="concat($namespacePrefix, '::FWF')"/> |
8 |
<xsl:variable name="fundingName" select="normalize-space(.//column[@name='Grant_Type'])"/> |
|
9 |
<xsl:variable name="fundingCode" select="normalize-space(.//column[@name='Grant_Type_Code'])"/> |
|
8 |
|
|
9 |
<xsl:variable name="fundingCode" select="normalize-space(substring-before(.//column[@name='project number'],' –'))"/> |
|
10 |
<xsl:variable name="projectNumber" select="normalize-space(substring-after(.//column[@name='project number'],' – '))"/> |
|
10 | 11 |
<xsl:variable name="fundingID"> |
11 | 12 |
<xsl:choose> |
12 |
<xsl:when test="string-length(normalize-space(.//column[@name='Grant_Type_Code'])) > 0">
|
|
13 |
<xsl:value-of select="concat($funderID, '::', normalize-space(.//column[@name='Grant_Type_Code']))"/>
|
|
13 |
<xsl:when test="string-length($fundingCode) > 0">
|
|
14 |
<xsl:value-of select="concat($funderID, '::', $fundingCode)"/>
|
|
14 | 15 |
</xsl:when> |
15 | 16 |
<xsl:otherwise> |
16 | 17 |
<xsl:value-of select="$funderID"/> |
... | ... | |
18 | 19 |
</xsl:choose> |
19 | 20 |
</xsl:variable> |
20 | 21 |
|
21 |
<xsl:variable name="projectID" select="concat($namespacePrefix, '::', translate(.//column[@name='Project Identifier (Grant)'], ' ', '_'))"/> |
|
22 |
<xsl:variable name="projectCode" select=".//column[@name='Project Identifier (Grant)']"/> |
|
23 |
<xsl:variable name="projectTitle" select=".//column[@name='Grant_Title']"/> |
|
24 | 22 |
|
25 |
<xsl:variable name="startDate" select=".//column[@name='Start_date']"/>
|
|
26 |
<xsl:variable name="endDate" select=".//column[@name='End_date']"/>
|
|
23 |
<xsl:variable name="projectID" select="concat($namespacePrefix, '::', concat($fundingCode,'_',$projectNumber))"/>
|
|
24 |
<xsl:variable name="projectCode" select="concat($fundingCode,' ',$projectNumber)"/>
|
|
27 | 25 |
|
28 |
<xsl:variable name="dateFormat" select="string('dd-MMM-yyyy')"/>
|
|
26 |
<xsl:variable name="projectTitle" select=".//column[@name='project title']"/>
|
|
29 | 27 |
|
28 |
<xsl:variable name="startDate" select=".//column[@name='from']"/> |
|
29 |
<xsl:variable name="endDate" select=".//column[@name='till']"/> |
|
30 |
<xsl:variable name="personId" select="concat($namespacePrefix,translate(normalize-space(.//column[@name='project lead']),' ','_'))"/> |
|
31 |
<xsl:variable name="dateFormat" select="string('yyyy-MM-dd')"/> |
|
32 |
<xsl:variable name="organizationId" select="concat($namespacePrefix,fwf:getMd5(.//column[@name='research place and institute']))"/> |
|
30 | 33 |
<xsl:template match="/"> |
31 |
<record> |
|
32 |
<xsl:copy-of select=".//*[local-name()='header']"/> |
|
33 |
<metadata> |
|
34 |
<ROWS> |
|
35 |
<xsl:if test="string-length($projectTitle) > 0 and string-length($projectID) > 0"> |
|
34 |
<xsl:if test="string-length($projectTitle) > 0 and |
|
35 |
string-length($projectID) > 0"> |
|
36 |
<record> |
|
37 |
|
|
38 |
<xsl:copy-of select=".//*[local-name()='header']"/> |
|
39 |
|
|
40 |
<metadata> |
|
41 |
|
|
42 |
<ROWS> |
|
43 |
|
|
36 | 44 |
<ROW table="projects"> |
37 | 45 |
<FIELD name="_dnet_resource_identifier_"> |
38 | 46 |
<xsl:value-of select="$projectID"/> |
... | ... | |
41 | 49 |
<xsl:value-of select="$projectID"/> |
42 | 50 |
</FIELD> |
43 | 51 |
<FIELD name="code"> |
44 |
<xsl:value-of select=".//column[@name='Project Identifier (Grant)']"/>
|
|
52 |
<xsl:value-of select="$projectCode"/>
|
|
45 | 53 |
</FIELD> |
46 | 54 |
<FIELD name="startdate" type="date" format="{$dateFormat}"> |
47 | 55 |
<xsl:value-of select="$startDate"/> |
... | ... | |
50 | 58 |
<xsl:value-of select="$endDate"/> |
51 | 59 |
</FIELD> |
52 | 60 |
<FIELD name="title"> |
53 |
<xsl:value-of select=".//column[@name='Grant_Title']"/>
|
|
61 |
<xsl:value-of select="$projectTitle"/>
|
|
54 | 62 |
</FIELD> |
63 |
<FIELD name="keywords"> |
|
64 |
<xsl:value-of select=".//column[@name='keywords']"/> |
|
65 |
</FIELD> |
|
66 |
<FIELD name="optional1"> |
|
67 |
<xsl:variable name="grantAmount" select=".//column[@name='grants awarded']"/> |
|
68 |
<xsl:variable name="tmp" select="substring(normalize-space($grantAmount),1,1)"/> |
|
69 |
<xsl:value-of select="concat($tmp,' ',substring-after($grantAmount,$tmp))"/> |
|
70 |
</FIELD> |
|
71 |
|
|
55 | 72 |
<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD> |
56 | 73 |
<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD> |
57 |
<FIELD name="collectedfrom"><xsl:value-of select="$parentDatasourceId"/></FIELD> |
|
74 |
<FIELD name="collectedfrom"> |
|
75 |
<xsl:value-of select="$parentDatasourceId"/> |
|
76 |
</FIELD> |
|
58 | 77 |
</ROW> |
59 | 78 |
<ROW table="project_fundingpath"> |
60 | 79 |
<FIELD name="_dnet_resource_identifier_"> |
... | ... | |
74 | 93 |
<xsl:value-of select="$endDate"/> |
75 | 94 |
</FIELD> |
76 | 95 |
</ROW> |
77 |
</xsl:if> |
|
78 |
</ROWS> |
|
79 |
</metadata> |
|
80 |
</record> |
|
96 |
<xsl:if test="string-length($organizationId) > 0"> |
|
97 |
<ROW table="organizations"> |
|
98 |
|
|
99 |
<FIELD name="_dnet_resource_identifier_"> |
|
100 |
<xsl:value-of select="$organizationId"/> |
|
101 |
</FIELD> |
|
102 |
<FIELD name="id"> |
|
103 |
<xsl:value-of select="$organizationId"/> |
|
104 |
</FIELD> |
|
105 |
<FIELD name="legalname"> |
|
106 |
<xsl:variable name="orgName" select="normalize-space(.//column[@name='research place and institute'])"/> |
|
107 |
<xsl:choose> |
|
108 |
<xsl:when test="string-length( $orgName) > 255"> |
|
109 |
<xsl:value-of select="substring($orgName,0,254)"/> |
|
110 |
</xsl:when> |
|
111 |
<xsl:otherwise> |
|
112 |
<xsl:value-of select="normalize-space($orgName)"/> |
|
113 |
</xsl:otherwise> |
|
114 |
</xsl:choose> |
|
115 |
|
|
116 |
|
|
117 |
</FIELD> |
|
118 |
<FIELD name="collectedfrom"> |
|
119 |
<xsl:value-of select="$parentDatasourceId"/> |
|
120 |
</FIELD> |
|
121 |
<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD> |
|
122 |
<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD> |
|
123 |
</ROW> |
|
124 |
</xsl:if> |
|
125 |
<xsl:if test="string-length($personId) > 0"> |
|
126 |
<ROW table="persons"> |
|
127 |
<FIELD name="_dnet_resource_identifier_"> |
|
128 |
<xsl:value-of select="$personId"/> |
|
129 |
</FIELD> |
|
130 |
<FIELD name="id"> |
|
131 |
<xsl:value-of select="$personId"/> |
|
132 |
</FIELD> |
|
133 |
<FIELD name="firstname"> |
|
134 |
<xsl:value-of select="fwf:getName(.//column[@name='project lead'],true())"/> |
|
135 |
</FIELD> |
|
136 |
<FIELD name="secondnames"> |
|
137 |
<xsl:value-of select="fwf:getName(.//column[@name='project lead'],false())"/> |
|
138 |
</FIELD> |
|
139 |
<FIELD name="collectedfrom"> |
|
140 |
<xsl:value-of select="$parentDatasourceId"/> |
|
141 |
</FIELD> |
|
142 |
<FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD> |
|
143 |
<FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD> |
|
144 |
</ROW> |
|
145 |
</xsl:if> |
|
146 |
|
|
147 |
<xsl:if test="string-length($organizationId) > 0"> |
|
148 |
<ROW table="project_organization"> |
|
149 |
<FIELD name="_dnet_resource_identifier_"> |
|
150 |
<xsl:value-of select='concat($projectID, "@@", $organizationId)'/> |
|
151 |
</FIELD> |
|
152 |
<FIELD name="project"> |
|
153 |
<xsl:value-of select="$projectID"/> |
|
154 |
</FIELD> |
|
155 |
<FIELD name="resporganization"> |
|
156 |
<xsl:value-of select="$organizationId"/> |
|
157 |
</FIELD> |
|
158 |
<FIELD name="contactperson"> |
|
159 |
<xsl:value-of select="$personId"/> |
|
160 |
</FIELD> |
|
161 |
<FIELD name="semanticclass">participant</FIELD> |
|
162 |
<FIELD name="semanticscheme">dnet:project_organization_relations</FIELD> |
|
163 |
</ROW> |
|
164 |
</xsl:if> |
|
165 |
|
|
166 |
</ROWS> |
|
167 |
</metadata> |
|
168 |
</record> |
|
169 |
</xsl:if> |
|
81 | 170 |
</xsl:template> |
82 | 171 |
</xsl:stylesheet> |
Also available in: Unified diff
integrated (hopefully) all required changes from dnet40