Project

General

Profile

« Previous | Next » 

Revision 48969

transformation for sgov funder

View differences:

modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/workflows/repo-hi/xslt/sgov2db.xsl
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" exclude-result-prefixes="fn">
4

  
5
    <xsl:param name="parentDatasourceId"/>
6
    <xsl:param name="namespacePrefix"/>
7
    <xsl:template name="FirstLetterAndNumber">
8
        <xsl:param name="string" select="normalize-space(translate(., ', ', ' '))"/>
9

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

  
17
            </xsl:if>
18
        </xsl:for-each>
19
    </xsl:template>
20

  
21

  
22
    <xsl:template match="/">
23

  
24
        <xsl:variable name="funderId" select="concat($namespacePrefix, '::SGOV')"/>
25
        <xsl:variable name="dateFormat" select="string('mm/DD/yyyy')"/>
26
        <xsl:variable name="stream">
27
            <xsl:call-template name="FirstLetterAndNumber">
28
                <xsl:with-param name="string" select=".//column[@name = 'Entidad Convocante']"/>
29
            </xsl:call-template>
30

  
31
        </xsl:variable>
32
        <xsl:variable name="streaml1">
33
            <xsl:call-template name="FirstLetterAndNumber">
34
                <xsl:with-param name="string" select=".//column[@name = 'Unidad Directiva']"/>
35
            </xsl:call-template>
36
        </xsl:variable>
37
        <xsl:variable name="fundingId">
38
            <xsl:choose>
39
                <xsl:when test="string-length($stream) &gt; 0">
40
                    <xsl:choose>
41
                        <xsl:when test="string-length($streaml1) &gt; 0">
42
                            <xsl:value-of select="concat($funderId, '::', $stream, '::', $streaml1)"
43
                            />
44
                        </xsl:when>
45
                        <xsl:otherwise>
46
                            <xsl:value-of select="concat($funderId, '::', $stream)"/>
47
                        </xsl:otherwise>
48
                    </xsl:choose>
49
                </xsl:when>
50
                <xsl:otherwise>
51
                    <xsl:value-of select="$funderId"/>
52
                </xsl:otherwise>
53
            </xsl:choose>
54
        </xsl:variable>
55

  
56

  
57
        <record>
58

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

  
61
            <metadata>
62
                <ROWS>
63
                    <xsl:variable name="projectId"
64
                                  select="concat($namespacePrefix, '::', normalize-space(.//column[@name = 'Referencia Proyecto']))"/>
65
                    <xsl:variable name="startDate" select=".//column[@name = 'fecha convocatoria']"/>
66
                    <xsl:variable name="endDate" select=".//column[@name = 'fecha resolucion']"/>
67

  
68
                    <ROW table="projects">
69
                        <FIELD name="_dnet_resource_identifier_">
70
                            <xsl:value-of select="$projectId"/>
71
                        </FIELD>
72
                        <FIELD name="id">
73
                            <xsl:value-of select="$projectId"/>
74
                        </FIELD>
75
                        <FIELD name="code">
76
                            <xsl:value-of select=".//column[@name = 'Referencia Proyecto']"/>
77
                        </FIELD>
78
                        <FIELD name="title">
79
                            <xsl:value-of select=".//column[@name = 'Título Proyecto']"/>
80
                        </FIELD>
81

  
82
                        <xsl:if test="not($startDate = 'abierta')">
83
                            <FIELD name="startdate" type="date" format="{$dateFormat}">
84
                                <xsl:value-of select="$startDate"/>
85
                            </FIELD>
86
                        </xsl:if>
87
                        <xsl:if test="not($endDate = 'abierta')">
88
                            <FIELD name="enddate" type="date" format="{$dateFormat}">
89
                                <xsl:value-of select="$endDate"/>
90
                            </FIELD>
91
                        </xsl:if>
92
                        <FIELD name="collectedfrom">
93
                            <xsl:value-of select="$parentDatasourceId"/>
94
                        </FIELD>
95
                        <FIELD name="provenanceActionClass"
96
                        >sysimport:crosswalk:entityregistry</FIELD>
97
                        <FIELD name="provenanceActionScheme">dnet:provenanceActions</FIELD>
98
                        <FIELD name="collectedfrom">
99
                            <xsl:value-of select="$parentDatasourceId"/>
100
                        </FIELD>
101

  
102
                        <FIELD name="oa_mandate_for_publications" type="boolean">false</FIELD>
103
                    </ROW>
104

  
105
                    <ROW table="project_fundingpath">
106
                        <FIELD name="_dnet_resource_identifier_">
107
                            <xsl:value-of select="concat($fundingId, '@@', $projectId)"/>
108
                        </FIELD>
109
                        <FIELD name="funding">
110
                            <xsl:value-of select="$fundingId"/>
111
                        </FIELD>
112
                        <FIELD name="project">
113
                            <xsl:value-of select="$projectId"/>
114
                        </FIELD>
115
                        <xsl:if test="not($startDate = 'abierta')">
116
                            <FIELD name="startdate" type="date" format="{$dateFormat}">
117
                                <xsl:value-of select="$startDate"/>
118
                            </FIELD>
119
                        </xsl:if>
120
                        <xsl:if test="not($endDate = 'abierta')">
121
                            <FIELD name="enddate" type="date" format="{$dateFormat}">
122
                                <xsl:value-of select="$endDate"/>
123
                            </FIELD>
124
                        </xsl:if>
125

  
126
                    </ROW>
127

  
128

  
129

  
130

  
131
                </ROWS>
132
            </metadata>
133
        </record>
134
    </xsl:template>
135

  
136
</xsl:stylesheet>

Also available in: Unified diff