forked from eprintsug/crosswalks_sgul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
symplectic_xwalks_eprints_sgul.xsl
400 lines (353 loc) · 18.6 KB
/
symplectic_xwalks_eprints_sgul.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<?xml version="1.0" encoding="utf-8"?>
<!--
Developed for St George's, University of London by Tim Miles-Board timothy.miles-board@london.ac.uk
Requires Symplectic Repository Tools 1.7.1+
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:crosswalks="info:symplectic/crosswalks" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:pubs="http://www.symplectic.co.uk/publications/atom-api" version="1.0">
<xsl:import href="symplectic_xwalks_toolkit.xsl" />
<xsl:variable name="crosswalk-mappings" select="document('')//crosswalks:mappings" />
<xsl:variable name="crosswalk-dictionaries" select="document('')//crosswalks:dictionaries" />
<xsl:variable name="crosswalk-datasource-precedences" select="document('')//crosswalks:datasource-precedences" />
<!--
The feed from Symplectic Elements may contain publication data from multiple sources (eg. pubmed, wos) - the toolkit will select
one of these sources by looking at the crosswalks:datasource-precedences setting:
-->
<crosswalks:datasource-precedences>
<crosswalks:datasource-precedence>pubmed</crosswalks:datasource-precedence>
<crosswalks:datasource-precedence>web-of-science</crosswalks:datasource-precedence>
<crosswalks:datasource-precedence>wos-lite</crosswalks:datasource-precedence>
<crosswalks:datasource-precedence>isi-precedings</crosswalks:datasource-precedence>
<crosswalks:datasource-precedence>manual-entry</crosswalks:datasource-precedence>
<crosswalks:datasource-precedence>arxiv</crosswalks:datasource-precedence>
<crosswalks:datasource-precedence>dblp</crosswalks:datasource-precedence>
<crosswalks:datasource-precedence>scopus</crosswalks:datasource-precedence>
</crosswalks:datasource-precedences>
<!--
Once a source has been selected the following mappings will be applied:
-->
<crosswalks:mappings for="eprints">
<crosswalks:mapping eprints="abstract" elements="abstract" />
<crosswalks:mapping eprints="article_number" elements="pagination" />
<crosswalks:mapping eprints="book_title" elements="parent-title" />
<crosswalks:mapping eprints="contributors" elements="associated-authors" />
<crosswalks:mapping eprints="creators" elements="authors" />
<crosswalks:mapping eprints="editors" elements="editors" />
<crosswalks:mapping eprints="event_dates" list-elements="start-date,finish-date" list-separator=" - " date-format="dd.mon.yyyy"/>
<crosswalks:mapping eprints="event_location" elements="location" />
<crosswalks:mapping eprints="event_title" elements="name-of-conference" />
<crosswalks:mapping eprints="id_number" elements="doi,patent-number" />
<crosswalks:mapping eprints="isbn" elements="isbn-10,isbn-13" />
<crosswalks:mapping eprints="ispublished" elements="c-publication-status-local,publication-status" />
<crosswalks:mapping eprints="issn" elements="issn,eissn" />
<crosswalks:mapping eprints="language" elements="language" />
<crosswalks:mapping eprints="staff_note" elements="notes" />
<crosswalks:mapping eprints="number" elements="issue" />
<crosswalks:mapping eprints="official_url" elements="publisher-url" />
<crosswalks:mapping eprints="output_media" elements="medium" />
<crosswalks:mapping eprints="pagerange" elements="pagination" />
<crosswalks:mapping eprints="pages" elements="pagination" />
<crosswalks:mapping eprints="place_of_pub" elements="place-of-publication" />
<crosswalks:mapping eprints="rioxx2_project_input" elements="funding-acknowledgements" />
<crosswalks:mapping eprints="publication" elements="journal" />
<crosswalks:mapping eprints="publisher" elements="publisher" />
<crosswalks:mapping eprints="references" elements="references" />
<crosswalks:mapping eprints="related_url" elements="author-url,arxiv-pdf-url"/>
<crosswalks:mapping eprints="series" elements="series" />
<crosswalks:mapping eprints="thesis_type" elements="thesis-type" />
<crosswalks:mapping eprints="title" elements="title" />
<crosswalks:mapping eprints="volume" elements="volume" />
<crosswalks:mapping eprints="dates" elements="publication-date,acceptance-date,filed-date" date-format="yyyy-mm-dd"/>
<crosswalks:mapping eprints="pub_license" elements="publisher-licence"/>
</crosswalks:mappings>
<!--
Custom mappings for specific fields can be defined.
For example, to override the mapping for the pubs:foo field first create a template that matches pubs:foo in "mapping" mode:
<xsl:template match="pubs:foo" mode="mapping">
<xsl:param name="name" />
<xsl:param name="repo_field" />
<xsl:apply-templates select=".">
<xsl:with-param name="name" select="$name" />
<xsl:with-param name="repo_field" select="$repo_field" />
</xsl:apply-templates>
</xsl:template>
Then create a template that matches pubs:foo:
<xsl:template match="pubs:funding-acknowledgements">
<xsl:param name="name" />
<xsl:param name="repo_field" />
... do something funky ...
</xsl:template>
-->
<!-- <xsl:template match="pubs:pagination" mode="mapping"> already defined in symplectic_xwalks_toolkit_mapping_fieldtypes.xsl -->
<xsl:template match="pubs:pagination">
<xsl:param name="name" />
<xsl:param name="repo_field" />
<xsl:choose>
<xsl:when test="$repo_field='pages'">
<xsl:apply-templates select="." mode="pagecount" />
</xsl:when>
<xsl:when test="$repo_field='pagerange'">
<xsl:apply-templates select="." mode="pagerange" />
</xsl:when>
<xsl:when test="$repo_field='article_number'">
<xsl:apply-templates select="." mode="artnum" />
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="pubs:pagination" mode="pagerange">
<xsl:choose>
<xsl:when test="pubs:begin-page and not(pubs:end-page) and starts-with(pubs:begin-page, 'e')"/>
<xsl:when test="pubs:begin-page or pubs:end-page">
<xsl:if test="pubs:begin-page">
<xsl:value-of select="normalize-space(pubs:begin-page)"/>
</xsl:if>
<xsl:text>-</xsl:text>
<xsl:if test="pubs:end-page">
<xsl:value-of select="normalize-space(pubs:end-page)"/>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="pubs:pagination" mode="artnum">
<xsl:if test="pubs:begin-page and not(pubs:end-page) and starts-with(pubs:begin-page, 'e')">
<!-- eg. e1001258 -->
<xsl:value-of select="normalize-space(pubs:begin-page)"/>
</xsl:if>
</xsl:template>
<xsl:template match="pubs:grant" mode="mapping">
<xsl:param name="name" />
<xsl:param name="repo_field" />
<xsl:apply-templates select="."/>
</xsl:template>
<xsl:template match="pubs:grant">
<xsl:element name="project">
<xsl:value-of select="pubs:grant-id"/>
</xsl:element>
<xsl:element name="funder_name">
<xsl:value-of select="pubs:organisation"/>
</xsl:element>
</xsl:template>
<xsl:template match="pubs:date" mode="mapping">
<xsl:param name="name" />
<xsl:param name="repo_field" />
<xsl:param name="date-format" />
<xsl:element name="date">
<xsl:apply-templates select="."/>
</xsl:element>
<xsl:element name="date_type">
<xsl:choose>
<xsl:when test="$name='publication-date'">published</xsl:when>
<xsl:when test="$name='acceptance-date'">accepted</xsl:when>
<xsl:when test="$name='filed-date'">filed</xsl:when>
</xsl:choose>
</xsl:element>
</xsl:template>
<!--
The crosswalks toolkit uses dictionaries to map Symplectic Elements values to EPrints sets/namedsets
-->
<crosswalks:dictionaries>
<crosswalks:dictionary elements="publisher-licence">
<crosswalks:entry elements="CC BY" eprints="cc_by" />
<crosswalks:entry elements="CC BY-ND" eprints="cc_by_nd" />
<crosswalks:entry elements="CC BY-NC" eprints="cc_by_nc" />
<crosswalks:entry elements="CC BY-NC-ND" eprints="cc_by_nc_nd" />
<crosswalks:entry elements="CC BY-NC-SA" eprints="cc_by_nc_sa" />
<crosswalks:entry elements="CC BY-SA" eprints="cc_by_sa" />
<crosswalks:entry elements="Publisher's own licence" eprints="publisher" />
<crosswalks:entry elements="Unknown" eprints="unknown" />
</crosswalks:dictionary>
<crosswalks:dictionary elements="c-publication-status-local">
<crosswalks:entry elements="Published" eprints="pub" />
<crosswalks:entry elements="Submitted" eprints="submitted" />
<crosswalks:entry elements="Accepted" eprints="inpress" />
<crosswalks:entry elements="Unpublished" eprints="unpub" />
</crosswalks:dictionary>
<crosswalks:dictionary elements="publication-status">
<crosswalks:entry elements="Published" eprints="pub" />
<crosswalks:entry elements="Submitted" eprints="submitted" />
<crosswalks:entry elements="Accepted" eprints="inpress" />
<crosswalks:entry elements="Unpublished" eprints="unpub" />
</crosswalks:dictionary>
<crosswalks:dictionary elements="thesis-type">
<crosswalks:entry elements="Master's Thesis" eprints="masters" />
<crosswalks:entry elements="PhD Thesis" eprints="phd" />
<crosswalks:entry elements="Undergraduate Dissertation" eprints="other" />
</crosswalks:dictionary>
</crosswalks:dictionaries>
<!--
It is possible to crosswalk data from ANY part of the feed (not just the selected source as in the crosswalks:mappings section)
by defining "feed" mode templates
-->
<xsl:template match="atom:feed/pubs:id" mode="feed">
<xsl:element name="symplectic_id">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="atom:feed/atom:entry/pubs:data-source" mode="feed">
<xsl:choose>
<xsl:when test="pubs:source-name = 'pubmed'">
<xsl:element name="pmid">
<xsl:value-of select="pubs:id-at-source"/>
</xsl:element>
</xsl:when>
<xsl:when test="pubs:source-name = 'wos'">
<xsl:element name="wosid">
<xsl:value-of select="pubs:id-at-source"/>
</xsl:element>
</xsl:when>
<xsl:when test="pubs:source-name = 'web-of-science'">
<xsl:element name="wosid">
<xsl:value-of select="pubs:id-at-source"/>
</xsl:element>
</xsl:when>
<xsl:when test="pubs:source-name = 'wos-lite'">
<xsl:element name="wosid">
<xsl:value-of select="pubs:id-at-source"/>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="atom:feed/pubs:organisational-details" mode="feed">
<xsl:element name="divisions">
<xsl:for-each select="pubs:group">
<item><xsl:value-of name="org-id" select="@org-id"/></item>
</xsl:for-each>
</xsl:element>
</xsl:template>
<!-- Note that SGUL's keywords field is multiple which is not the EPrints default -->
<xsl:template match="atom:feed/pubs:all-labels/pubs:keywords" mode="feed">
<xsl:element name="keywords">
<xsl:for-each select="pubs:keyword">
<xsl:element name="item">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="atom:feed/atom:category[2]" mode="feed">
<xsl:variable name="element_type" select="@term"/>
<xsl:element name="type">
<xsl:value-of select="document('')//crosswalks:type-map/entry[@elements=$element_type]"/>
</xsl:element>
</xsl:template>
<xsl:template match="atom:feed/pubs:users" mode="feed">
<xsl:element name="users">
<xsl:apply-templates select="pubs:user"/>
</xsl:element>
</xsl:template>
<xsl:template match="atom:feed/pubs:actors" mode="feed">
<xsl:element name="actors">
<xsl:apply-templates select="pubs:user"/>
</xsl:element>
</xsl:template>
<xsl:template match="pubs:user">
<xsl:element name="item">
<xsl:element name="name">
<xsl:element name="family"><xsl:value-of select="pubs:last-name"/></xsl:element>
<xsl:element name="given"><xsl:value-of select="pubs:first-name"/></xsl:element>
</xsl:element>
<xsl:element name="email"><xsl:value-of select="pubs:email-address"/></xsl:element>
<xsl:element name="role"><xsl:value-of select="@type"/></xsl:element>
<xsl:element name="id"><xsl:value-of select="pubs:proprietary-id"/></xsl:element>
</xsl:element>
</xsl:template>
<!--
Map Elements item type to EPrints item type
-->
<crosswalks:type-map>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/journal-article">article</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/chapter">book_section</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/conference-proceeding">conference_item</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/book">book</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/patent">patent</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/artefact">artefact</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/exhibition">exhibition</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/composition">composition</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/performance">performance</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/other">other</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/design">design</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/internet-publication">internet_publication</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/report">report</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/scholarly-edition">scholarly_edition</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/software">software</entry>
<entry elements="http://www.symplectic.co.uk/publications/atom-terms/1.0/thesis-or-dissertation">thesis</entry>
</crosswalks:type-map>
<!-- override template from symplectic_xwalks_toolkit_fieldtypes.xsl -->
<xsl:variable name="pubs_users" select="atom:feed/pubs:users/pubs:user"/>
<xsl:template match="pubs:people/pubs:person">
<xsl:param name="name" />
<xsl:param name="repo_field" />
<xsl:choose>
<xsl:when test="$repository-type='eprints'">
<name>
<xsl:if test="normalize-space(pubs:last-name)!=''"><family><xsl:value-of select="normalize-space(pubs:last-name)"/></family></xsl:if>
<xsl:if test="normalize-space(pubs:initials)!=''"><given><xsl:value-of select="normalize-space(pubs:initials)"/></given></xsl:if>
</name>
<!-- BEGIN CHANGE match author to institutional person -->
<xsl:variable name="family" select="pubs:last-name"/>
<xsl:variable name="given" select="pubs:initials"/>
<xsl:for-each select="$pubs_users">
<xsl:if test="(pubs:last-name = $family) and substring(pubs:first-name,1,1) = substring($given,1,1)">
<sgulid><xsl:value-of select="pubs:proprietary-id" /></sgulid>
<id><xsl:value-of select="pubs:email-address" /></id>
</xsl:if>
</xsl:for-each>
<!-- END CHANGE -->
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(pubs:last-name)"/>
<xsl:if test="(normalize-space(pubs:last-name)!='') and (normalize-space(pubs:initials)!='')">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="normalize-space(pubs:initials)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- override template from symplectic_xwalks_toolkit_mapping.xsl -->
<xsl:template name="_render_mapping_occurrences">
<xsl:param name="elements" />
<xsl:param name="repo_field" />
<xsl:param name="date-format" />
<xsl:param name="max" />
<xsl:param name="_elements_to_iterate" />
<xsl:choose>
<xsl:when test="contains($elements, ',')">
<xsl:call-template name="_render_mapping_occurrences">
<xsl:with-param name="elements" select="normalize-space(substring-before($elements, ','))" />
<xsl:with-param name="repo_field" select="$repo_field" />
<xsl:with-param name="date-format" select="$date-format" />
<xsl:with-param name="max" select="$max" />
<xsl:with-param name="_elements_to_iterate" select="normalize-space(substring-after($elements, ','))" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="fields" select="pubs:field[@name=normalize-space($elements)]" />
<!-- BEGIN CHANGE split pubs:funding-acknowledgements into separate grants -->
<xsl:variable name="field_values" select="$fields/pubs:funding-acknowledgements/pubs:grants/*|$fields/pubs:people/*|$fields/pubs:keywords/*|$fields/pubs:items/*|$fields/*[local-name()!='items' and local-name()!='keywords' and local-name()!='people' and local-name()!='funding-acknowledgements']" />
<!-- END CHANGE -->
<xsl:for-each select="$field_values">
<xsl:if test="$max='' or position() <= $max">
<xsl:call-template name="_render_field_occurrence">
<xsl:with-param name="field" select="$repo_field" />
<xsl:with-param name="value">
<xsl:apply-templates select="." mode="mapping">
<xsl:with-param name="name"><xsl:value-of select="ancestor::pubs:field/@name" /></xsl:with-param>
<xsl:with-param name="repo_field" select="$repo_field" />
<xsl:with-param name="date-format" select="$date-format" />
</xsl:apply-templates>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
<xsl:if test="$_elements_to_iterate and ($max='' or count($field_values) < $max)">
<xsl:call-template name="_render_mapping_occurrences">
<xsl:with-param name="elements" select="$_elements_to_iterate" />
<xsl:with-param name="repo_field" select="$repo_field" />
<xsl:with-param name="date-format" select="$date-format" />
<xsl:with-param name="max"><xsl:if test="$max > 0"><xsl:value-of select="$max - count($field_values)"/></xsl:if></xsl:with-param>
<xsl:with-param name="_elements_to_iterate" />
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>