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
    <!-- 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
            <!-- Title -->
28
            <xsl:text>"</xsl:text>
29
            <xsl:call-template name="escape-quot-string">
30
                <xsl:with-param name="s" select="../../../title"/>
31
            </xsl:call-template>
32
            <xsl:text>",</xsl:text>
33

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

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

    
59
            <!-- Download from -->
60
            <xsl:value-of select="../../../children/instance[1]/webresource[1]"/>
61
            <xsl:text>,</xsl:text>
62

    
63

    
64
            <!-- Publication Type -->
65
            <xsl:value-of select="../../../children/instance[1]/instancetype/@classname"/>
66
            <xsl:text>,</xsl:text>
67

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

    
73

    
74
            <!-- Funder -->
75
            <xsl:value-of select="../funding/funder/@name"/>
76
            <xsl:text>(</xsl:text>
77
            <xsl:value-of select="../funding/funder/@shortname"/>
78
            <xsl:text>),</xsl:text>
79

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

    
95
            <!-- Access -->
96
            <xsl:value-of select="../../../bestaccessright/@classname"/>
97
            <xsl:text>&#xd;</xsl:text>
98

    
99
        </xsl:for-each>
100

    
101
    </xsl:template>
102

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

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

    
147
</xsl:stylesheet>
(12-12/51)