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 45426 katerina.i
    <!-- 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
            <!-- Title -->
28
            <xsl:text>"</xsl:text>
29 45491 katerina.i
            <xsl:call-template name="escape-quot-string">
30
                <xsl:with-param name="s" select="../../../title"/>
31
            </xsl:call-template>
32 45379 katerina.i
            <xsl:text>",</xsl:text>
33
34
            <!-- Authors -->
35 55638 katerina.i
            <xsl:text>"</xsl:text>
36 50401 katerina.i
            <xsl:for-each select="../../../creator">
37
                <xsl:sort select="@rank"/>
38
                <xsl:value-of select="."/>
39 45379 katerina.i
                <xsl:if test="not(position()=last())">
40
                    <xsl:text>;</xsl:text>
41
                </xsl:if>
42
            </xsl:for-each>
43 55638 katerina.i
            <xsl:text>"</xsl:text>
44 45379 katerina.i
            <xsl:text>,</xsl:text>
45 50401 katerina.i
46 45379 katerina.i
            <!-- Publication Year -->
47
            <xsl:value-of select="../../../dateofacceptance"/>
48
            <xsl:text>,</xsl:text>
49
50
            <!-- DOI -->
51
            <xsl:apply-templates select="pid"/>
52
            <xsl:text>,</xsl:text>
53
54
            <!-- Download from -->
55
            <xsl:value-of select="../../../children/instance[1]/webresource[1]"/>
56
            <xsl:text>,</xsl:text>
57
58 46242 katerina.i
59 45379 katerina.i
            <!-- Publication Type -->
60
            <xsl:value-of select="../../../children/instance[1]/instancetype/@classname"/>
61
            <xsl:text>,</xsl:text>
62
63 45426 katerina.i
            <!-- Journal -->
64 45491 katerina.i
            <xsl:text>"</xsl:text>
65 46242 katerina.i
            <xsl:copy-of select="replace(../../../source, '&lt;/?\w+[^&lt;]*&gt;', '')"/>
66 45491 katerina.i
            <xsl:text>",</xsl:text>
67 45426 katerina.i
68 46361 katerina.i
69 45379 katerina.i
            <!-- Funder -->
70
            <xsl:value-of select="../funding/funder/@name"/>
71
            <xsl:text>(</xsl:text>
72
            <xsl:value-of select="../funding/funder/@shortname"/>
73
            <xsl:text>),</xsl:text>
74
75
            <!-- Project Name (GA Number) -->
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
90
            <!-- Access -->
91 50401 katerina.i
            <xsl:value-of select="../../../bestaccessright/@classname"/>
92 45379 katerina.i
            <xsl:text>&#xd;</xsl:text>
93
94
        </xsl:for-each>
95
96
    </xsl:template>
97
98
    <xsl:template match="pid[@classid='doi']">
99
        <xsl:value-of select="."/>
100
    </xsl:template>
101
102 45491 katerina.i
    <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 45379 katerina.i
</xsl:stylesheet>