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
        <!-- Download from -->
60
        <xsl:value-of select="children/instance[1]/webresource[1]"/>
61
        <xsl:text>,</xsl:text>
62

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

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

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

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

    
99
    </xsl:template>
100

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

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

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