Project

General

Profile

1 45379 katerina.i
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 45491 katerina.i
    <xsl:variable name="apos">'</xsl:variable>
14
15 45379 katerina.i
    <xsl:template match = "/">
16
        <xsl:apply-templates select="//oaf:result"/>
17
    </xsl:template>
18
19 46242 katerina.i
    <xsl:template match="text()">
20
        <xsl:value-of select="replace(., '[&#x007F;-&#x009F;]', ' ')"/>
21
    </xsl:template>
22
23 58175 katerina.i
    <!-- Type, Title, Authors, Publication Year, DOI, Download from, Publication Type, Journal, Funder, Project Name (GA Number), Access -->
24 45379 katerina.i
25
    <xsl:template match="oaf:result">
26
        <xsl:for-each select="rels/rel/to[@class='isProducedBy']">
27 58050 katerina.i
            <!-- Type -->
28
            <xsl:value-of select="../../../resulttype/@classname"/>
29
            <xsl:text>,</xsl:text>
30
31 45379 katerina.i
            <!-- Title -->
32
            <xsl:text>"</xsl:text>
33 45491 katerina.i
            <xsl:call-template name="escape-quot-string">
34
                <xsl:with-param name="s" select="../../../title"/>
35
            </xsl:call-template>
36 45379 katerina.i
            <xsl:text>",</xsl:text>
37
38
            <!-- Authors -->
39 55638 katerina.i
            <xsl:text>"</xsl:text>
40 50401 katerina.i
            <xsl:for-each select="../../../creator">
41
                <xsl:sort select="@rank"/>
42
                <xsl:value-of select="."/>
43 45379 katerina.i
                <xsl:if test="not(position()=last())">
44
                    <xsl:text>;</xsl:text>
45
                </xsl:if>
46
            </xsl:for-each>
47 55638 katerina.i
            <xsl:text>"</xsl:text>
48 45379 katerina.i
            <xsl:text>,</xsl:text>
49 50401 katerina.i
50 45379 katerina.i
            <!-- Publication Year -->
51
            <xsl:value-of select="../../../dateofacceptance"/>
52
            <xsl:text>,</xsl:text>
53
54
            <!-- DOI -->
55
            <xsl:apply-templates select="pid"/>
56
            <xsl:text>,</xsl:text>
57
58
            <!-- Download from -->
59
            <xsl:value-of select="../../../children/instance[1]/webresource[1]"/>
60
            <xsl:text>,</xsl:text>
61
62 46242 katerina.i
63 45379 katerina.i
            <!-- Publication Type -->
64
            <xsl:value-of select="../../../children/instance[1]/instancetype/@classname"/>
65
            <xsl:text>,</xsl:text>
66
67 45426 katerina.i
            <!-- Journal -->
68 45491 katerina.i
            <xsl:text>"</xsl:text>
69 46242 katerina.i
            <xsl:copy-of select="replace(../../../source, '&lt;/?\w+[^&lt;]*&gt;', '')"/>
70 45491 katerina.i
            <xsl:text>",</xsl:text>
71 45426 katerina.i
72 46361 katerina.i
73 45379 katerina.i
            <!-- Funder -->
74
            <xsl:value-of select="../funding/funder/@name"/>
75
            <xsl:text>(</xsl:text>
76
            <xsl:value-of select="../funding/funder/@shortname"/>
77
            <xsl:text>),</xsl:text>
78
79
            <!-- Project Name (GA Number) -->
80
            <xsl:choose>
81
                <xsl:when test="../acronym">
82
                    <xsl:value-of select="../acronym"/>
83
                </xsl:when>
84
                <xsl:otherwise>
85
                    <xsl:text>"</xsl:text>
86
                    <xsl:value-of select="../title"/>
87
                    <xsl:text>"</xsl:text>
88
                </xsl:otherwise>
89
            </xsl:choose>
90
            <xsl:text>(</xsl:text>
91
            <xsl:value-of select="../code"/>
92
            <xsl:text>),</xsl:text>
93
94
            <!-- Access -->
95 50401 katerina.i
            <xsl:value-of select="../../../bestaccessright/@classname"/>
96 45379 katerina.i
            <xsl:text>&#xd;</xsl:text>
97
98
        </xsl:for-each>
99
100
    </xsl:template>
101
102
    <xsl:template match="pid[@classid='doi']">
103
        <xsl:value-of select="."/>
104
    </xsl:template>
105
106 45491 katerina.i
    <xsl:template name="escape-quot-string">
107
        <xsl:param name="s"/>
108
        <xsl:choose>
109
            <xsl:when test="contains($s,'&quot;')">
110
                <xsl:call-template name="encode-string">
111
                    <xsl:with-param name="s" select="concat(substring-before($s,'&quot;'),$apos)"/>
112
                </xsl:call-template>
113
                <xsl:call-template name="escape-quot-string">
114
                    <xsl:with-param name="s" select="substring-after($s,'&quot;')"/>
115
                </xsl:call-template>
116
            </xsl:when>
117
            <xsl:otherwise>
118
                <xsl:call-template name="encode-string">
119
                    <xsl:with-param name="s" select="$s"/>
120
                </xsl:call-template>
121
            </xsl:otherwise>
122
        </xsl:choose>
123
    </xsl:template>
124
125
    <xsl:template name="encode-string">
126
        <xsl:param name="s"/>
127
        <xsl:choose>
128
            <!-- tab -->
129
            <xsl:when test="contains($s,'&#x9;')">
130
                <xsl:call-template name="encode-string">
131
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#x9;'),'\t',substring-after($s,'&#x9;'))"/>
132
                </xsl:call-template>
133
            </xsl:when>
134
            <!-- line feed -->
135
            <xsl:when test="contains($s,'&#xA;')">
136
                <xsl:call-template name="encode-string">
137
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#xA;'),'\n',substring-after($s,'&#xA;'))"/>
138
                </xsl:call-template>
139
            </xsl:when>
140
            <!-- carriage return -->
141
            <xsl:when test="contains($s,'&#xD;')">
142
                <xsl:call-template name="encode-string">
143
                    <xsl:with-param name="s" select="concat(substring-before($s,'&#xD;'),'\r',substring-after($s,'&#xD;'))"/>
144
                </xsl:call-template>
145
            </xsl:when>
146
            <xsl:otherwise><xsl:value-of select="$s"/></xsl:otherwise>
147
        </xsl:choose>
148
    </xsl:template>
149
150 45379 katerina.i
</xsl:stylesheet>