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
|
<xsl:template match="text()">
|
20
|
<xsl:value-of select="replace(., '[-Ÿ]', ' ')"/>
|
21
|
</xsl:template>
|
22
|
|
23
|
<!-- Type, Title, Authors, Publication Year, DOI, Download from, Publication Type, Journal, Funder, Project Name (GA Number), Access -->
|
24
|
|
25
|
<xsl:template match="oaf:result">
|
26
|
<xsl:for-each select="rels/rel/to[@class='isProducedBy']">
|
27
|
<!-- Type -->
|
28
|
<xsl:value-of select="../../../resulttype/@classname"/>
|
29
|
<xsl:text>,</xsl:text>
|
30
|
|
31
|
<!-- Title -->
|
32
|
<xsl:text>"</xsl:text>
|
33
|
<xsl:call-template name="escape-quot-string">
|
34
|
<xsl:with-param name="s" select="../../../title"/>
|
35
|
</xsl:call-template>
|
36
|
<xsl:text>",</xsl:text>
|
37
|
|
38
|
<!-- Authors -->
|
39
|
<xsl:text>"</xsl:text>
|
40
|
<xsl:for-each select="../../../creator">
|
41
|
<xsl:sort select="@rank"/>
|
42
|
<xsl:value-of select="."/>
|
43
|
<xsl:if test="not(position()=last())">
|
44
|
<xsl:text>;</xsl:text>
|
45
|
</xsl:if>
|
46
|
</xsl:for-each>
|
47
|
<xsl:text>"</xsl:text>
|
48
|
<xsl:text>,</xsl:text>
|
49
|
|
50
|
<!-- 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
|
|
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, '</?\w+[^<]*>', '')"/>
|
70
|
<xsl:text>",</xsl:text>
|
71
|
|
72
|
|
73
|
<!-- 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
|
<xsl:value-of select="../../../bestaccessright/@classname"/>
|
96
|
<xsl:text>
</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
|
<xsl:template name="escape-quot-string">
|
107
|
<xsl:param name="s"/>
|
108
|
<xsl:choose>
|
109
|
<xsl:when test="contains($s,'"')">
|
110
|
<xsl:call-template name="encode-string">
|
111
|
<xsl:with-param name="s" select="concat(substring-before($s,'"'),$apos)"/>
|
112
|
</xsl:call-template>
|
113
|
<xsl:call-template name="escape-quot-string">
|
114
|
<xsl:with-param name="s" select="substring-after($s,'"')"/>
|
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,'	')">
|
130
|
<xsl:call-template name="encode-string">
|
131
|
<xsl:with-param name="s" select="concat(substring-before($s,'	'),'\t',substring-after($s,'	'))"/>
|
132
|
</xsl:call-template>
|
133
|
</xsl:when>
|
134
|
<!-- line feed -->
|
135
|
<xsl:when test="contains($s,'
')">
|
136
|
<xsl:call-template name="encode-string">
|
137
|
<xsl:with-param name="s" select="concat(substring-before($s,'
'),'\n',substring-after($s,'
'))"/>
|
138
|
</xsl:call-template>
|
139
|
</xsl:when>
|
140
|
<!-- carriage return -->
|
141
|
<xsl:when test="contains($s,'
')">
|
142
|
<xsl:call-template name="encode-string">
|
143
|
<xsl:with-param name="s" select="concat(substring-before($s,'
'),'\r',substring-after($s,'
'))"/>
|
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
|
</xsl:stylesheet>
|