Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
                xmlns:fn="http://www.w3.org/2005/xpath-functions" version="2.0"
4
                exclude-result-prefixes="fn">
5

    
6
    <xsl:variable name="namespacePrefix" select="string('sgov________')"/>
7
    <xsl:variable name="funderID" select="concat($namespacePrefix, '::SGOV')"/>
8

    
9
    <xsl:template name="FirstLetterAndNumber">
10
        <xsl:param name="string" select="normalize-space(translate(., ', ', ' '))"/>
11

    
12
        <xsl:for-each select="tokenize($string, ' ')">
13
            <xsl:if test="string-length(.) != 0">
14
                <xsl:variable name="char" select="substring(., 1, 1)"/>
15
                <xsl:if test="fn:upper-case($char)=$char">
16
                    <xsl:value-of select="$char"/>
17
                </xsl:if>
18

    
19
            </xsl:if>
20
        </xsl:for-each>
21
    </xsl:template>
22

    
23
    <xsl:template match="/">
24
        <fundings>
25
            <fundingtree>
26
                <funder>
27
                    <id>
28
                        <xsl:value-of select="$funderID"/>
29
                    </id>
30
                    <shortname>SGOV</shortname>
31
                    <name>Gobierno de España</name>
32
                    <jurisdiction>ES</jurisdiction>
33
                </funder>
34
                <xsl:variable name="stream">
35
                    <xsl:call-template name="FirstLetterAndNumber">
36
                        <xsl:with-param name="string" select=".//column[@name = 'Entidad Convocante']"/>
37
                    </xsl:call-template>
38

    
39
                </xsl:variable>
40
                <xsl:variable name="streaml1">
41
                    <xsl:call-template name="FirstLetterAndNumber">
42
                        <xsl:with-param name="string" select=".//column[@name = 'Unidad Directiva']"/>
43
                    </xsl:call-template>
44
                </xsl:variable>
45
                <funding_level_1>
46
                    <id>
47
                        <xsl:value-of select="concat($funderID, '::', $stream,'::',$streaml1)"/>
48
                    </id>
49
                    <description>
50
                        <xsl:value-of select=".//column[@name='Unidad Directiva']"/>
51
                    </description>
52
                    <name>
53
                        <xsl:value-of select=".//column[@name='Unidad Directiva']"/>
54
                    </name>
55
                    <class>
56
                        <xsl:value-of select="concat('sgov:',fn:lower-case($streaml1),'fundings')"/></class>
57
                    <parent>
58
                        <funding_level_0>
59
                            <id>
60
                                <xsl:value-of select="concat($funderID, '::',$stream)"/>
61
                            </id>
62
                            <name><xsl:value-of select=".//column[@name='Entidad Convocante']"/></name>
63
                            <description><xsl:value-of select=".//column[@name='Entidad Convocante']"/></description>
64
                            <parent/>
65
                            <class>
66
                                <xsl:value-of select="concat('sgov:',fn:lower-case($stream),'fundings')"/>
67
                            </class>
68
                        </funding_level_0>
69
                    </parent>
70
                </funding_level_1>
71
            </fundingtree>
72
        </fundings>
73
    </xsl:template>
74

    
75
</xsl:stylesheet>
(17-17/21)