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:for-each select="pid[@classid='doi']">
48
            <xsl:value-of select="."/>
49
            <xsl:if test="not(position()=last())">
50
                <xsl:text>;</xsl:text>
51
            </xsl:if>
52
        </xsl:for-each>
53
        <xsl:text>,</xsl:text>
54

    
55
        <!-- Download from -->
56
        <xsl:value-of select="children/instance[1]/webresource[1]"/>
57
        <xsl:text>,</xsl:text>
58

    
59
        <!-- Publication Type -->
60
        <xsl:value-of select="children/instance[1]/instancetype/@classname"/>
61
        <xsl:text>,</xsl:text>
62

    
63
        <!-- Journal -->
64
        <xsl:text>"</xsl:text>
65
        <xsl:copy-of select="replace(source, '&lt;/?\w+[^&lt;]*&gt;', '')"/>
66
        <xsl:text>",</xsl:text>
67

    
68

    
69
        <!-- Funder|Project Name (GA Number) -->
70
        <xsl:for-each select="rels/rel/to[@class='isProducedBy']">
71
            <xsl:value-of select="../funding/funder/@shortname"/>
72
            <xsl:text>|</xsl:text>
73
            <xsl:choose>
74
                <xsl:when test="../acronym">
75
                    <xsl:value-of select="../acronym"/>
76
                </xsl:when>
77
                <xsl:otherwise>
78
                    <xsl:text>"</xsl:text>
79
                    <xsl:value-of select="../title"/>
80
                    <xsl:text>"</xsl:text>
81
                </xsl:otherwise>
82
            </xsl:choose>
83
            <xsl:text>(</xsl:text>
84
            <xsl:value-of select="../code"/>
85
            <xsl:text>)</xsl:text>
86
            <xsl:if test="not(position()=last())">
87
                <xsl:text>;</xsl:text>
88
            </xsl:if>
89
        </xsl:for-each>
90
        <xsl:text>,</xsl:text>
91

    
92
        <!-- Access -->
93
        <xsl:value-of select="bestaccessright/@classname"/>
94
        <xsl:text>&#xd;</xsl:text>
95

    
96
    </xsl:template>
97

    
98
    <xsl:template match="pid[@classid='doi']">
99
        <xsl:value-of select="."/>
100
    </xsl:template>
101

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

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

    
146
</xsl:stylesheet>
(11-11/51)