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

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

    
23
        <!-- Title -->
24
        <xsl:text>"</xsl:text>
25
        <xsl:call-template name="escape-quot-string">
26
            <xsl:with-param name="s" select="title"/>
27
        </xsl:call-template>
28
        <xsl:text>",</xsl:text>
29

    
30
        <!-- Authors -->
31
        <xsl:text>"</xsl:text>
32
        <xsl:for-each select="creator">
33
            <xsl:sort select="@rank"/>
34
            <xsl:value-of select="."/>
35
            <xsl:if test="not(position()=last())">
36
                <xsl:text>;</xsl:text>
37
            </xsl:if>
38
        </xsl:for-each>
39
        <xsl:text>"</xsl:text>
40
        <xsl:text>,</xsl:text>
41

    
42
        <!-- Publication Year -->
43
        <xsl:value-of select="dateofacceptance"/>
44
        <xsl:text>,</xsl:text>
45

    
46
        <!-- DOI -->
47
        <xsl:apply-templates select="pid"/>
48
        <xsl:text>,</xsl:text>
49

    
50
        <!-- Funder|Project Name (GA Number) -->
51
        <xsl:for-each select="rels/rel/to[@class='isProducedBy']">
52
            <xsl:value-of select="../funding/funder/@shortname"/>
53
            <xsl:text>|</xsl:text>
54
            <xsl:choose>
55
                <xsl:when test="../acronym">
56
                    <xsl:value-of select="../acronym"/>
57
                </xsl:when>
58
                <xsl:otherwise>
59
                    <xsl:text>"</xsl:text>
60
                    <xsl:value-of select="../title"/>
61
                    <xsl:text>"</xsl:text>
62
                </xsl:otherwise>
63
            </xsl:choose>
64
            <xsl:text>(</xsl:text>
65
            <xsl:value-of select="../code"/>
66
            <xsl:text>)</xsl:text>
67
            <xsl:if test="not(position()=last())">
68
                <xsl:text>;</xsl:text>
69
            </xsl:if>
70
        </xsl:for-each>
71
        <xsl:text>,</xsl:text>
72

    
73
        <!-- Access -->
74
        <xsl:value-of select="bestaccessright/@classname"/>
75
        <xsl:text>&#xd;</xsl:text>
76

    
77
    </xsl:template>
78

    
79
    <xsl:template match="pid[@classid='doi']">
80
        <xsl:value-of select="."/>
81
    </xsl:template>
82

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

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

    
127
</xsl:stylesheet>
(11-11/46)