Project

General

Profile

1

    
2
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
                xmlns:dri="http://www.driver-repository.eu/namespace/dri"
4
                xmlns:oaf="http://namespace.openaire.eu/oaf"
5
                xmlns:dc="http://purl.org/dc/elements/1.1/">
6

    
7
    <!-- Turn off auto-insertion of <?xml> tag and set indenting on -->
8
    <xsl:output method="text" encoding="utf-8" omit-xml-declaration="yes" media-type="text/csv" />
9

    
10
    <!-- strip whitespace from whitespace-only nodes -->
11
    <xsl:strip-space elements="*"/>
12

    
13
    <xsl:variable name="apos">'</xsl:variable>
14

    
15
    <xsl:template match = "/">
16
        <xsl:apply-templates select="//oaf:result"/>
17
    </xsl:template>
18

    
19
    <xsl:template match="text()">
20
        <xsl:value-of select="replace(., '[&#x007F;-&#x009F;]', ' ')"/>
21
    </xsl:template>
22

    
23
    <!-- Type, Title, Authors, Publication Year, DOI, Download from, Publication Type, Journal, Funder, Project Name (GA Number), Access -->
24

    
25
    <xsl:template match="oaf:result">
26
        <xsl:for-each select="rels/rel/to[@class='isProducedBy']">
27
            <!-- Type -->
28
            <xsl:value-of select="../../../resulttype/@classname"/>
29
            <xsl:text>,</xsl:text>
30

    
31
            <!-- Title -->
32
            <xsl:text>"</xsl:text>
33
            <xsl:call-template name="escape-quot-string">
34
                <xsl:with-param name="s" select="../../../title"/>
35
            </xsl:call-template>
36
            <xsl:text>",</xsl:text>
37

    
38
            <!-- Authors -->
39
            <xsl:text>"</xsl:text>
40
            <xsl:for-each select="../../../creator">
41
                <xsl:sort select="@rank"/>
42
                <xsl:value-of select="."/>
43
                <xsl:if test="not(position()=last())">
44
                    <xsl:text>;</xsl:text>
45
                </xsl:if>
46
            </xsl:for-each>
47
            <xsl:text>"</xsl:text>
48
            <xsl:text>,</xsl:text>
49
            
50
            <!-- Publication Year -->
51
            <xsl:value-of select="../../../dateofacceptance"/>
52
            <xsl:text>,</xsl:text>
53

    
54
            <!-- DOI -->
55
            <xsl:for-each select="../../../pid[@classid='doi']">
56
                <xsl:value-of select="."/>
57
                <xsl:if test="not(position()=last())">
58
                    <xsl:text>;</xsl:text>
59
                </xsl:if>
60
            </xsl:for-each>
61
            <xsl:text>,</xsl:text>
62

    
63
            <!-- Download from -->
64
            <xsl:value-of select="../../../children/instance[1]/webresource[1]"/>
65
            <xsl:text>,</xsl:text>
66

    
67

    
68
            <!-- Publication Type -->
69
            <xsl:value-of select="../../../children/instance[1]/instancetype/@classname"/>
70
            <xsl:text>,</xsl:text>
71

    
72
            <!-- Journal -->
73
            <xsl:text>"</xsl:text>
74
            <xsl:copy-of select="replace(../../../source, '&lt;/?\w+[^&lt;]*&gt;', '')"/>
75
            <xsl:text>",</xsl:text>
76

    
77

    
78
            <!-- Funder -->
79
            <xsl:value-of select="../funding/funder/@name"/>
80
            <xsl:text>(</xsl:text>
81
            <xsl:value-of select="../funding/funder/@shortname"/>
82
            <xsl:text>),</xsl:text>
83

    
84
            <!-- Project Name (GA Number) -->
85
            <xsl:choose>
86
                <xsl:when test="../acronym">
87
                    <xsl:value-of select="../acronym"/>
88
                </xsl:when>
89
                <xsl:otherwise>
90
                    <xsl:text>"</xsl:text>
91
                    <xsl:value-of select="../title"/>
92
                    <xsl:text>"</xsl:text>
93
                </xsl:otherwise>
94
            </xsl:choose>
95
            <xsl:text>(</xsl:text>
96
            <xsl:value-of select="../code"/>
97
            <xsl:text>),</xsl:text>
98

    
99
            <!-- Access -->
100
            <xsl:value-of select="../../../bestaccessright/@classname"/>
101
            <xsl:text>&#xd;</xsl:text>
102

    
103
        </xsl:for-each>
104

    
105
    </xsl:template>
106

    
107
    <xsl:template name="escape-quot-string">
108
        <xsl:param name="s"/>
109
        <xsl:choose>
110
            <xsl:when test="contains($s,'&quot;')">
111
                <xsl:call-template name="encode-string">
112
                    <xsl:with-param name="s" select="concat(substring-before($s,'&quot;'),$apos)"/>
113
                </xsl:call-template>
114
                <xsl:call-template name="escape-quot-string">
115
                    <xsl:with-param name="s" select="substring-after($s,'&quot;')"/>
116
                </xsl:call-template>
117
            </xsl:when>
118
            <xsl:otherwise>
119
                <xsl:call-template name="encode-string">
120
                    <xsl:with-param name="s" select="$s"/>
121
                </xsl:call-template>
122
            </xsl:otherwise>
123
        </xsl:choose>
124
    </xsl:template>
125

    
126
    <xsl:template name="encode-string">
127
        <xsl:param name="s"/>
128
        <xsl:choose>
129
            <!-- tab -->
130
            <xsl:when test="contains($s,'&#x9;')">
131
                <xsl:call-template name="encode-string">
132
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#x9;'),'\t',substring-after($s,'&#x9;'))"/>
133
                </xsl:call-template>
134
            </xsl:when>
135
            <!-- line feed -->
136
            <xsl:when test="contains($s,'&#xA;')">
137
                <xsl:call-template name="encode-string">
138
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#xA;'),'\n',substring-after($s,'&#xA;'))"/>
139
                </xsl:call-template>
140
            </xsl:when>
141
            <!-- carriage return -->
142
            <xsl:when test="contains($s,'&#xD;')">
143
                <xsl:call-template name="encode-string">
144
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#xD;'),'\r',substring-after($s,'&#xD;'))"/>
145
                </xsl:call-template>
146
            </xsl:when>
147
            <xsl:otherwise><xsl:value-of select="$s"/></xsl:otherwise>
148
        </xsl:choose>
149
    </xsl:template>
150

    
151
</xsl:stylesheet>
(14-14/51)