1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
<xsl:stylesheet version="1.0"
|
3
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions"
|
4
|
exclude-result-prefixes="fn">
|
5
|
|
6
|
<xsl:variable name="namespacePrefix" select="string('nsf_________')"/>
|
7
|
<xsl:variable name="funderID" select="concat($namespacePrefix, '::NSF')"/>
|
8
|
|
9
|
<xsl:template match="/">
|
10
|
<fundings>
|
11
|
<fundingtree>
|
12
|
<funder>
|
13
|
<id>
|
14
|
<xsl:value-of select="$funderID"/>
|
15
|
</id>
|
16
|
<shortname>NSF</shortname>
|
17
|
<name>National Science Foundation</name>
|
18
|
<jurisdiction>US</jurisdiction>
|
19
|
</funder>
|
20
|
</fundingtree>
|
21
|
<xsl:for-each select=".//funding">
|
22
|
<xsl:variable name="p1" select="normalize-space(./orgDirectorateAbbr)"/>
|
23
|
<xsl:variable name="p2" select="normalize-space(./orgDivisionAbbr)"/>
|
24
|
|
25
|
<fundingtree>
|
26
|
<funder>
|
27
|
<id>
|
28
|
<xsl:value-of select="$funderID"/>
|
29
|
</id>
|
30
|
<shortname>NSF</shortname>
|
31
|
<name>National Science Foundation</name>
|
32
|
<jurisdiction>US</jurisdiction>
|
33
|
</funder>
|
34
|
<xsl:if test="string-length($p1) > 0">
|
35
|
<xsl:choose>
|
36
|
<xsl:when test="string-length($p2) > 0">
|
37
|
<xsl:variable name="level0" select="concat($funderID, '::', $p1)"/>
|
38
|
<xsl:variable name="level1" select="concat($funderID, '::', $p1, '::', $p2)"/>
|
39
|
<funding_level_1>
|
40
|
<id>
|
41
|
<xsl:value-of select="$level1"/>
|
42
|
</id>
|
43
|
<description>
|
44
|
<xsl:value-of select="./orgDivisionName"/>
|
45
|
</description>
|
46
|
<name>
|
47
|
<xsl:value-of select="./orgDivisionName"/>
|
48
|
</name>
|
49
|
<parent>
|
50
|
<funding_level_0>
|
51
|
<id>
|
52
|
<xsl:value-of select="$level0"/>
|
53
|
</id>
|
54
|
<description>
|
55
|
<xsl:value-of select="./orgDirectorateName"/>
|
56
|
</description>
|
57
|
<name>
|
58
|
<xsl:value-of select="./orgDirectorateName"/>
|
59
|
</name>
|
60
|
<parent/>
|
61
|
<class>nsf:fundingStream</class>
|
62
|
</funding_level_0>
|
63
|
</parent>
|
64
|
</funding_level_1>
|
65
|
</xsl:when>
|
66
|
<xsl:otherwise>
|
67
|
<xsl:variable name="level0" select="concat($funderID, '::', $p1)"/>
|
68
|
<funding_level_0>
|
69
|
<id>
|
70
|
<xsl:value-of select="$level0"/>
|
71
|
</id>
|
72
|
<description>
|
73
|
<xsl:value-of select="./orgDirectorateName"/>
|
74
|
</description>
|
75
|
<name>
|
76
|
<xsl:value-of select="./orgDirectorateName"/>
|
77
|
</name>
|
78
|
<parent/>
|
79
|
<class>nsf:fundingStream</class>
|
80
|
</funding_level_0>
|
81
|
</xsl:otherwise>
|
82
|
</xsl:choose>
|
83
|
</xsl:if>
|
84
|
</fundingtree>
|
85
|
</xsl:for-each>
|
86
|
</fundings>
|
87
|
</xsl:template>
|
88
|
</xsl:stylesheet>
|