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
|
<!-- Title, Authors, Publication Year, DOI, Funder, Project Name (GA Number), Access -->
|
20
|
|
21
|
<xsl:template match="oaf:result">
|
22
|
|
23
|
<!-- Title -->
|
24
|
<xsl:text>"</xsl:text>
|
25
|
<xsl:call-template name="escape-quot-string">
|
26
|
<xsl:with-param name="s" select="title"/>
|
27
|
</xsl:call-template>
|
28
|
<xsl:text>",</xsl:text>
|
29
|
|
30
|
<!-- Authors -->
|
31
|
<xsl:for-each select="rels/rel/to[@class='hasAuthor']">
|
32
|
<xsl:sort select="ranking"/>
|
33
|
<xsl:text>"</xsl:text>
|
34
|
<xsl:value-of select="../fullname"/>
|
35
|
<xsl:text>"</xsl:text>
|
36
|
<xsl:if test="not(position()=last())">
|
37
|
<xsl:text>;</xsl:text>
|
38
|
</xsl:if>
|
39
|
</xsl:for-each>
|
40
|
<xsl:text>,</xsl:text>
|
41
|
|
42
|
<!-- Publication Year -->
|
43
|
<xsl:value-of select="dateofacceptance"/>
|
44
|
<xsl:text>,</xsl:text>
|
45
|
|
46
|
<!-- DOI -->
|
47
|
<xsl:apply-templates select="pid"/>
|
48
|
<xsl:text>,</xsl:text>
|
49
|
|
50
|
<!-- Funder|Project Name (GA Number) -->
|
51
|
<xsl:for-each select="rels/rel/to[@class='isProducedBy']">
|
52
|
<xsl:value-of select="../funding/funder/@shortname"/>
|
53
|
<xsl:text>|</xsl:text>
|
54
|
<xsl:choose>
|
55
|
<xsl:when test="../acronym">
|
56
|
<xsl:value-of select="../acronym"/>
|
57
|
</xsl:when>
|
58
|
<xsl:otherwise>
|
59
|
<xsl:text>"</xsl:text>
|
60
|
<xsl:value-of select="../title"/>
|
61
|
<xsl:text>"</xsl:text>
|
62
|
</xsl:otherwise>
|
63
|
</xsl:choose>
|
64
|
<xsl:text>(</xsl:text>
|
65
|
<xsl:value-of select="../code"/>
|
66
|
<xsl:text>)</xsl:text>
|
67
|
<xsl:if test="not(position()=last())">
|
68
|
<xsl:text>;</xsl:text>
|
69
|
</xsl:if>
|
70
|
</xsl:for-each>
|
71
|
<xsl:text>,</xsl:text>
|
72
|
|
73
|
<!-- Access -->
|
74
|
<xsl:value-of select="bestlicense/@classname"/>
|
75
|
<xsl:text>
</xsl:text>
|
76
|
|
77
|
</xsl:template>
|
78
|
|
79
|
<xsl:template match="pid[@classid='doi']">
|
80
|
<xsl:value-of select="."/>
|
81
|
</xsl:template>
|
82
|
|
83
|
<xsl:template name="escape-quot-string">
|
84
|
<xsl:param name="s"/>
|
85
|
<xsl:choose>
|
86
|
<xsl:when test="contains($s,'"')">
|
87
|
<xsl:call-template name="encode-string">
|
88
|
<xsl:with-param name="s" select="concat(substring-before($s,'"'),$apos)"/>
|
89
|
</xsl:call-template>
|
90
|
<xsl:call-template name="escape-quot-string">
|
91
|
<xsl:with-param name="s" select="substring-after($s,'"')"/>
|
92
|
</xsl:call-template>
|
93
|
</xsl:when>
|
94
|
<xsl:otherwise>
|
95
|
<xsl:call-template name="encode-string">
|
96
|
<xsl:with-param name="s" select="$s"/>
|
97
|
</xsl:call-template>
|
98
|
</xsl:otherwise>
|
99
|
</xsl:choose>
|
100
|
</xsl:template>
|
101
|
|
102
|
<xsl:template name="encode-string">
|
103
|
<xsl:param name="s"/>
|
104
|
<xsl:choose>
|
105
|
<!-- tab -->
|
106
|
<xsl:when test="contains($s,'	')">
|
107
|
<xsl:call-template name="encode-string">
|
108
|
<xsl:with-param name="s" select="concat(substring-before($s,'	'),'\t',substring-after($s,'	'))"/>
|
109
|
</xsl:call-template>
|
110
|
</xsl:when>
|
111
|
<!-- line feed -->
|
112
|
<xsl:when test="contains($s,'
')">
|
113
|
<xsl:call-template name="encode-string">
|
114
|
<xsl:with-param name="s" select="concat(substring-before($s,'
'),'\n',substring-after($s,'
'))"/>
|
115
|
</xsl:call-template>
|
116
|
</xsl:when>
|
117
|
<!-- carriage return -->
|
118
|
<xsl:when test="contains($s,'
')">
|
119
|
<xsl:call-template name="encode-string">
|
120
|
<xsl:with-param name="s" select="concat(substring-before($s,'
'),'\r',substring-after($s,'
'))"/>
|
121
|
</xsl:call-template>
|
122
|
</xsl:when>
|
123
|
<xsl:otherwise><xsl:value-of select="$s"/></xsl:otherwise>
|
124
|
</xsl:choose>
|
125
|
</xsl:template>
|
126
|
|
127
|
</xsl:stylesheet>
|