1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
3
|
|
4
|
<!-- Turn off auto-insertion of <?xml> tag and set indenting on -->
|
5
|
<xsl:output method="text" encoding="utf-8" omit-xml-declaration="yes" media-type="text/csv" />
|
6
|
|
7
|
<!-- strip whitespace from whitespace-only nodes -->
|
8
|
<xsl:strip-space elements="*"/>
|
9
|
|
10
|
<xsl:variable name="apos">'</xsl:variable>
|
11
|
|
12
|
<xsl:template match = "/">
|
13
|
<!--
|
14
|
<xsl:text disable-output-escaping="yes">Title	Authors	Publication Year	DOI	Permanent identifier	Publication type	Journal	Funder	Project Name (GA Number)	Access
</xsl:text>
|
15
|
-->
|
16
|
<xsl:apply-templates select="//result"/>
|
17
|
</xsl:template>
|
18
|
|
19
|
<!-- Title	 Authors	 Description	 Year	 DOI	 Permanent identifier	 Publication type	 Journal	 Project Name	 GA number	 Access -->
|
20
|
<xsl:template match="result">
|
21
|
<xsl:choose>
|
22
|
<xsl:when test="field[@name='project']">
|
23
|
<xsl:for-each select="field[@name='project']">
|
24
|
<!-- title -->
|
25
|
<xsl:text>"</xsl:text>
|
26
|
<xsl:value-of select="../field[@name='title']/@value"/>
|
27
|
<xsl:text>"</xsl:text>
|
28
|
<xsl:text>	</xsl:text>
|
29
|
|
30
|
<!-- authors -->
|
31
|
<xsl:text>"</xsl:text>
|
32
|
<xsl:for-each select="../field[@name='hasAuthor']">
|
33
|
<xsl:sort select="./field[@name='ranking']/@value" data-type="number"/>
|
34
|
<xsl:value-of select="field[@name='fullname']/@value"/>
|
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
|
<!-- description
|
43
|
<xsl:text>"</xsl:text>
|
44
|
<xsl:value-of select="field[@name='description']/@value"/>
|
45
|
<xsl:if test="position() != last()"><xsl:text> </xsl:text></xsl:if>
|
46
|
<xsl:text>"</xsl:text>
|
47
|
<xsl:text>	</xsl:text>
|
48
|
-->
|
49
|
<!-- year -->
|
50
|
<xsl:text>"</xsl:text>
|
51
|
<xsl:value-of select="../field[@name='dateofacceptance']/@value"/>
|
52
|
<xsl:text>"</xsl:text>
|
53
|
<xsl:text>	</xsl:text>
|
54
|
|
55
|
<!-- DOI -->
|
56
|
<xsl:for-each select="../field[@name='pid']">
|
57
|
<xsl:if test="field[@name='classid' and @value='doi']/@value = 'doi'">
|
58
|
<xsl:text>"</xsl:text>
|
59
|
<xsl:value-of select="field[@name='value']/@value"/>
|
60
|
<xsl:text>"</xsl:text>
|
61
|
</xsl:if>
|
62
|
</xsl:for-each>
|
63
|
<xsl:text>	</xsl:text>
|
64
|
|
65
|
<!-- Permanent Identifier -->
|
66
|
<xsl:text>"</xsl:text>
|
67
|
<xsl:value-of select="../field[@name='datasource'][1]/field[@name='url']/@value"/>
|
68
|
<xsl:text>"</xsl:text>
|
69
|
<xsl:text>	</xsl:text>
|
70
|
|
71
|
<!-- Publication type -->
|
72
|
<xsl:text>"</xsl:text>
|
73
|
<xsl:value-of select="../field[@name='datasource'][1]/field[@name='typename']/@value"/>
|
74
|
<xsl:text>"</xsl:text>
|
75
|
<xsl:text>	</xsl:text>
|
76
|
|
77
|
<!-- journal -->
|
78
|
<xsl:text>"</xsl:text>
|
79
|
<xsl:for-each select="../field[@name='source']">
|
80
|
<xsl:value-of select="replace(@value, '</?\w+[^<]*>', '')"/>
|
81
|
</xsl:for-each>
|
82
|
<xsl:text>"</xsl:text>
|
83
|
<xsl:text>	</xsl:text>
|
84
|
|
85
|
<!-- Funder -->
|
86
|
<xsl:text>"</xsl:text>
|
87
|
<xsl:for-each select="field[@name='funding']/field[@name='funder']">
|
88
|
<xsl:value-of select="@value"/>
|
89
|
</xsl:for-each>
|
90
|
<xsl:text>"</xsl:text>
|
91
|
<xsl:text>	</xsl:text>
|
92
|
|
93
|
<!-- project name -->
|
94
|
<xsl:text>"</xsl:text>
|
95
|
<!-- project name -->
|
96
|
<xsl:choose>
|
97
|
<xsl:when test="field[@name='projectacronym']/@value != ''" >
|
98
|
<xsl:value-of select="field[@name='projectacronym']/@value"/>
|
99
|
</xsl:when>
|
100
|
<xsl:otherwise>
|
101
|
<xsl:value-of select="field[@name='projecttitle']/@value"/>
|
102
|
</xsl:otherwise>
|
103
|
</xsl:choose>
|
104
|
<xsl:if test="field[@name='projectcode']/@value!= ''">
|
105
|
<xsl:value-of select="concat('(',field[@name='projectcode']/@value,')')"/>
|
106
|
</xsl:if>
|
107
|
|
108
|
<xsl:text>"</xsl:text>
|
109
|
<xsl:text>	</xsl:text>
|
110
|
|
111
|
<!--access -->
|
112
|
<xsl:text>"</xsl:text>
|
113
|
<xsl:value-of select="../field[@name='bestaccessright']/@value"/>
|
114
|
<xsl:text>"</xsl:text>
|
115
|
<xsl:text>
</xsl:text>
|
116
|
<xsl:text>
</xsl:text>
|
117
|
|
118
|
</xsl:for-each>
|
119
|
</xsl:when>
|
120
|
<xsl:otherwise>
|
121
|
<!-- title -->
|
122
|
<xsl:text>"</xsl:text>
|
123
|
<xsl:value-of select="field[@name='title']/@value"/>
|
124
|
<xsl:text>"</xsl:text>
|
125
|
<xsl:text>	</xsl:text>
|
126
|
|
127
|
<!-- authors -->
|
128
|
<xsl:text>"</xsl:text>
|
129
|
<xsl:for-each select="field[@name='hasAuthor']">
|
130
|
<xsl:value-of select="field[@name='fullname']/@value"/>
|
131
|
<xsl:if test="not(position()=last())">
|
132
|
<xsl:text>;</xsl:text>
|
133
|
</xsl:if>
|
134
|
</xsl:for-each>
|
135
|
<xsl:text>"</xsl:text>
|
136
|
<xsl:text>	</xsl:text>
|
137
|
|
138
|
<!-- year -->
|
139
|
<xsl:text>"</xsl:text>
|
140
|
<xsl:value-of select="field[@name='dateofacceptance']/@value"/>
|
141
|
<xsl:text>"</xsl:text>
|
142
|
<xsl:text>	</xsl:text>
|
143
|
|
144
|
<!-- DOI -->
|
145
|
<xsl:for-each select="field[@name='pid']">
|
146
|
<xsl:if test="field[@name='classid' and @value='doi']/@value = 'doi'">
|
147
|
<xsl:text>"</xsl:text>
|
148
|
<xsl:value-of select="field[@name='value']/@value"/>
|
149
|
<xsl:text>"</xsl:text>
|
150
|
</xsl:if>
|
151
|
</xsl:for-each>
|
152
|
<xsl:text>	</xsl:text>
|
153
|
|
154
|
<!-- Permanent Identifier -->
|
155
|
<xsl:text>"</xsl:text>
|
156
|
<xsl:value-of select="field[@name='datasource'][1]/field[@name='url']/@value"/>
|
157
|
<xsl:text>"</xsl:text>
|
158
|
<xsl:text>	</xsl:text>
|
159
|
|
160
|
<!-- Publication type -->
|
161
|
<xsl:text>"</xsl:text>
|
162
|
<xsl:value-of select="field[@name='datasource'][1]/field[@name='typename']/@value"/>
|
163
|
<xsl:text>"</xsl:text>
|
164
|
<xsl:text>	</xsl:text>
|
165
|
|
166
|
<!-- journal -->
|
167
|
<xsl:text>"</xsl:text>
|
168
|
<xsl:for-each select="field[@name='source']">
|
169
|
<xsl:call-template name="escape-quot-string">
|
170
|
<xsl:with-param name="s" select="replace(@value, '</?\w+[^<]*>', '')"/>
|
171
|
</xsl:call-template>
|
172
|
</xsl:for-each>
|
173
|
<xsl:text>"</xsl:text>
|
174
|
<xsl:text>	</xsl:text>
|
175
|
|
176
|
<!-- Funder -->
|
177
|
<xsl:text>"</xsl:text>
|
178
|
<xsl:text>"</xsl:text>
|
179
|
<xsl:text>	</xsl:text>
|
180
|
|
181
|
<!-- project name -->
|
182
|
<xsl:text>"</xsl:text>
|
183
|
<!-- project name -->
|
184
|
<xsl:text>"</xsl:text>
|
185
|
<xsl:text>	</xsl:text>
|
186
|
|
187
|
<!--access -->
|
188
|
<xsl:text>"</xsl:text>
|
189
|
<xsl:value-of select="../field[@name='bestaccessright']/@value"/>
|
190
|
<xsl:text>"</xsl:text>
|
191
|
<xsl:text>
</xsl:text>
|
192
|
<xsl:text>
</xsl:text>
|
193
|
</xsl:otherwise>
|
194
|
</xsl:choose>
|
195
|
|
196
|
</xsl:template>
|
197
|
|
198
|
<xsl:template name="escape-quot-string">
|
199
|
<xsl:param name="s"/>
|
200
|
<xsl:choose>
|
201
|
<xsl:when test="contains($s,'"')">
|
202
|
<xsl:call-template name="encode-string">
|
203
|
<xsl:with-param name="s" select="concat(substring-before($s,'"'),$apos)"/>
|
204
|
</xsl:call-template>
|
205
|
<xsl:call-template name="escape-quot-string">
|
206
|
<xsl:with-param name="s" select="substring-after($s,'"')"/>
|
207
|
</xsl:call-template>
|
208
|
</xsl:when>
|
209
|
<xsl:otherwise>
|
210
|
<xsl:call-template name="encode-string">
|
211
|
<xsl:with-param name="s" select="$s"/>
|
212
|
</xsl:call-template>
|
213
|
</xsl:otherwise>
|
214
|
</xsl:choose>
|
215
|
</xsl:template>
|
216
|
|
217
|
<xsl:template name="encode-string">
|
218
|
<xsl:param name="s"/>
|
219
|
<xsl:choose>
|
220
|
<!-- tab -->
|
221
|
<xsl:when test="contains($s,'	')">
|
222
|
<xsl:call-template name="encode-string">
|
223
|
<xsl:with-param name="s" select="concat(substring-before($s,'	'),'\t',substring-after($s,'	'))"/>
|
224
|
</xsl:call-template>
|
225
|
</xsl:when>
|
226
|
<!-- line feed -->
|
227
|
<xsl:when test="contains($s,'
')">
|
228
|
<xsl:call-template name="encode-string">
|
229
|
<xsl:with-param name="s" select="concat(substring-before($s,'
'),'\n',substring-after($s,'
'))"/>
|
230
|
</xsl:call-template>
|
231
|
</xsl:when>
|
232
|
<!-- carriage return -->
|
233
|
<xsl:when test="contains($s,'
')">
|
234
|
<xsl:call-template name="encode-string">
|
235
|
<xsl:with-param name="s" select="concat(substring-before($s,'
'),'\r',substring-after($s,'
'))"/>
|
236
|
</xsl:call-template>
|
237
|
</xsl:when>
|
238
|
<xsl:otherwise><xsl:value-of select="$s"/></xsl:otherwise>
|
239
|
</xsl:choose>
|
240
|
</xsl:template>
|
241
|
|
242
|
</xsl:stylesheet>
|