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
    <!-- Type, Title, Authors, Publication Year, DOI, Funder, Project Name (GA Number), Access -->
20

    
21
    <xsl:template match="oaf:result">
22

    
23
        <!-- Type -->
24
        <xsl:value-of select="resulttype/@classname"/>
25
        <xsl:text>,</xsl:text>
26

    
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
        <!-- Funder|Project Name (GA Number) -->
60
        <xsl:for-each select="rels/rel/to[@class='isProducedBy']">
61
            <xsl:value-of select="../funding/funder/@shortname"/>
62
            <xsl:text>|</xsl:text>
63
            <xsl:choose>
64
                <xsl:when test="../acronym">
65
                    <xsl:value-of select="../acronym"/>
66
                </xsl:when>
67
                <xsl:otherwise>
68
                    <xsl:text>"</xsl:text>
69
                    <xsl:value-of select="../title"/>
70
                    <xsl:text>"</xsl:text>
71
                </xsl:otherwise>
72
            </xsl:choose>
73
            <xsl:text>(</xsl:text>
74
            <xsl:value-of select="../code"/>
75
            <xsl:text>)</xsl:text>
76
            <xsl:if test="not(position()=last())">
77
                <xsl:text>;</xsl:text>
78
            </xsl:if>
79
        </xsl:for-each>
80
        <xsl:text>,</xsl:text>
81

    
82
        <!-- Access -->
83
        <xsl:value-of select="bestaccessright/@classname"/>
84
        <xsl:text>&#xd;</xsl:text>
85

    
86
    </xsl:template>
87

    
88
    <xsl:template name="escape-quot-string">
89
        <xsl:param name="s"/>
90
        <xsl:choose>
91
            <xsl:when test="contains($s,'&quot;')">
92
                <xsl:call-template name="encode-string">
93
                    <xsl:with-param name="s" select="concat(substring-before($s,'&quot;'),$apos)"/>
94
                </xsl:call-template>
95
                <xsl:call-template name="escape-quot-string">
96
                    <xsl:with-param name="s" select="substring-after($s,'&quot;')"/>
97
                </xsl:call-template>
98
            </xsl:when>
99
            <xsl:otherwise>
100
                <xsl:call-template name="encode-string">
101
                    <xsl:with-param name="s" select="$s"/>
102
                </xsl:call-template>
103
            </xsl:otherwise>
104
        </xsl:choose>
105
    </xsl:template>
106

    
107
    <xsl:template name="encode-string">
108
        <xsl:param name="s"/>
109
        <xsl:choose>
110
            <!-- tab -->
111
            <xsl:when test="contains($s,'&#x9;')">
112
                <xsl:call-template name="encode-string">
113
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#x9;'),'\t',substring-after($s,'&#x9;'))"/>
114
                </xsl:call-template>
115
            </xsl:when>
116
            <!-- line feed -->
117
            <xsl:when test="contains($s,'&#xA;')">
118
                <xsl:call-template name="encode-string">
119
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#xA;'),'\n',substring-after($s,'&#xA;'))"/>
120
                </xsl:call-template>
121
            </xsl:when>
122
            <!-- carriage return -->
123
            <xsl:when test="contains($s,'&#xD;')">
124
                <xsl:call-template name="encode-string">
125
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#xD;'),'\r',substring-after($s,'&#xD;'))"/>
126
                </xsl:call-template>
127
            </xsl:when>
128
            <xsl:otherwise><xsl:value-of select="$s"/></xsl:otherwise>
129
        </xsl:choose>
130
    </xsl:template>
131

    
132
</xsl:stylesheet>
(13-13/51)