Project

General

Profile

1
<RESOURCE_PROFILE>
2
	<HEADER>
3
		<RESOURCE_IDENTIFIER value="bb8e0e1c-5b53-4af5-a783-e074336624f9_VHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZXMvVHJhbnNmb3JtYXRpb25SdWxlRFNSZXNvdXJjZVR5cGU="/>
4
		<RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
5
		<RESOURCE_KIND value="TransformationRuleDSResources"/>
6
		<RESOURCE_URI value=""/>
7
		<DATE_OF_CREATION value="2018-06-04T11:15:30+00:00"/>
8
	</HEADER>
9
	<BODY>
10
		<CONFIGURATION>
11
			<IMPORTED/>
12
			<SCRIPT>
13
				<TITLE>SGOV to DB</TITLE>
14
				<CODE>
15
					<![CDATA[
16
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17
                xmlns:fn="http://www.w3.org/2005/xpath-functions" version="2.0" exclude-result-prefixes="fn">
18

    
19
    <xsl:param name="varDataSourceId"/>
20
    <xsl:variable name="namespacePrefix" select="string('sgov________')"/>
21
    <xsl:template name="FirstLetterAndNumber">
22
        <xsl:param name="string" select="normalize-space(translate(., ', ', ' '))"/>
23

    
24
        <xsl:for-each select="tokenize($string, ' ')">
25
            <xsl:if test="string-length(.) != 0">
26
                <xsl:variable name="char" select="substring(., 1, 1)"/>
27
                <xsl:if test="fn:upper-case($char)=$char">
28
                    <xsl:value-of select="$char"/>
29
                </xsl:if>
30

    
31
            </xsl:if>
32
        </xsl:for-each>
33
    </xsl:template>
34

    
35

    
36
    <xsl:template match="/">
37

    
38
        <xsl:variable name="funderId" select="concat($namespacePrefix, '::SGOV')"/>
39
        <xsl:variable name="dateFormat" select="string('mm/DD/yyyy')"/>
40
        <xsl:variable name="stream">
41
            <xsl:call-template name="FirstLetterAndNumber">
42
                <xsl:with-param name="string" select=".//column[@name = 'Entidad Convocante']"/>
43
            </xsl:call-template>
44

    
45
        </xsl:variable>
46
        <xsl:variable name="streaml1">
47
            <xsl:call-template name="FirstLetterAndNumber">
48
                <xsl:with-param name="string" select=".//column[@name = 'Unidad Directiva']"/>
49
            </xsl:call-template>
50
        </xsl:variable>
51
        <xsl:variable name="fundingId">
52
            <xsl:choose>
53
                <xsl:when test="string-length($stream) &gt; 0">
54
                    <xsl:choose>
55
                        <xsl:when test="string-length($streaml1) &gt; 0">
56
                            <xsl:value-of select="concat($funderId, '::', $stream, '::', $streaml1)"
57
                            />
58
                        </xsl:when>
59
                        <xsl:otherwise>
60
                            <xsl:value-of select="concat($funderId, '::', $stream)"/>
61
                        </xsl:otherwise>
62
                    </xsl:choose>
63
                </xsl:when>
64
                <xsl:otherwise>
65
                    <xsl:value-of select="$funderId"/>
66
                </xsl:otherwise>
67
            </xsl:choose>
68
        </xsl:variable>
69

    
70

    
71
        <record>
72

    
73
            <xsl:copy-of select=".//*[local-name() = 'header']"/>
74

    
75
            <metadata>
76
                <ROWS>
77
                    <xsl:variable name="projectId"
78
                                  select="concat($namespacePrefix, '::', normalize-space(.//column[@name = 'Referencia Proyecto']))"/>
79
                    <xsl:variable name="startDate" select=".//column[@name = 'fecha convocatoria']"/>
80
                    <xsl:variable name="endDate" select=".//column[@name = 'fecha resolucion']"/>
81

    
82
                    <ROW table="projects">
83
                        <FIELD name="_dnet_resource_identifier_">
84
                            <xsl:value-of select="$projectId"/>
85
                        </FIELD>
86
                        <FIELD name="id">
87
                            <xsl:value-of select="$projectId"/>
88
                        </FIELD>
89
                        <FIELD name="code">
90
                            <xsl:value-of select=".//column[@name = 'Referencia Proyecto']"/>
91
                        </FIELD>
92
                        <FIELD name="title">
93
                            <xsl:value-of select=".//column[@name = 'Título Proyecto']"/>
94
                        </FIELD>
95

    
96
                        <xsl:if test="not($startDate = 'abierta')">
97
                            <FIELD name="startdate" type="date" format="{$dateFormat}">
98
                                <xsl:value-of select="$startDate"/>
99
                            </FIELD>
100
                        </xsl:if>
101
                        <xsl:if test="not($endDate = 'abierta')">
102
                            <FIELD name="enddate" type="date" format="{$dateFormat}">
103
                                <xsl:value-of select="$endDate"/>
104
                            </FIELD>
105
                        </xsl:if>
106
                        <FIELD name="collectedfrom">
107
                            <xsl:value-of select="$varDataSourceId"/>
108
                        </FIELD>
109
                        <FIELD name="provenanceActionClass">sysimport:crosswalk:entityregistry</FIELD>
110
                        <FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
111
                        <FIELD name="collectedfrom">
112
                            <xsl:value-of select="$varDataSourceId"/>
113
                        </FIELD>
114

    
115
                        <FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD>
116
                        <FIELD name="lastupdate" type="date"><xsl:value-of select="current-dateTime()"/></FIELD>
117
                    </ROW>
118

    
119
                    <ROW table="project_fundingpath">
120
                        <FIELD name="_dnet_resource_identifier_">
121
                            <xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
122
                        </FIELD>
123
                        <FIELD name="funding">
124
                            <xsl:value-of select="$fundingId"/>
125
                        </FIELD>
126
                        <FIELD name="project">
127
                            <xsl:value-of select="$projectId"/>
128
                        </FIELD>
129
                        <xsl:if test="not($startDate = 'abierta')">
130
                            <FIELD name="startdate" type="date" format="{$dateFormat}">
131
                                <xsl:value-of select="$startDate"/>
132
                            </FIELD>
133
                        </xsl:if>
134
                        <xsl:if test="not($endDate = 'abierta')">
135
                            <FIELD name="enddate" type="date" format="{$dateFormat}">
136
                                <xsl:value-of select="$endDate"/>
137
                            </FIELD>
138
                        </xsl:if>
139

    
140
                    </ROW>
141
                </ROWS>
142
            </metadata>
143
        </record>
144
    </xsl:template>
145

    
146
</xsl:stylesheet>
147
]]>
148
				</CODE>
149
			</SCRIPT>
150
		</CONFIGURATION>
151
		<STATUS/>
152
		<SECURITY_PARAMETERS>SECURITY_PARAMETERS</SECURITY_PARAMETERS>
153
	</BODY>
154
</RESOURCE_PROFILE>
(23-23/27)