forked from eprintsug/crosswalks_sgul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymplectic_xwalks_toolkit_labels.xsl
311 lines (297 loc) · 18.8 KB
/
symplectic_xwalks_toolkit_labels.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
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dim="http://www.dspace.org/xmlns/dspace/dim"
xmlns:pubs="http://www.symplectic.co.uk/publications/atom-api"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:crosswalks="info:symplectic/crosswalks"
exclude-result-prefixes="pubs crosswalks dim"
version="1.0">
<xsl:import href="symplectic_xwalks_toolkit_config.xsl" />
<xsl:import href="symplectic_xwalks_toolkit_list.xsl" />
<xsl:import href="symplectic_xwalks_toolkit_mapping.xsl" />
<xsl:template name="_process_label_mappings">
<xsl:param name="nodes" select="/.." />
<xsl:param name="mappings" select="$crosswalk-label-mappings/*" />
<xsl:call-template name="_process_label_mapping">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="mapping" select="$mappings[1]" />
</xsl:call-template>
</xsl:template>
<xsl:template name="_process_label_mapping">
<xsl:param name="nodes" select="/.." />
<xsl:param name="mapping" />
<xsl:choose>
<xsl:when test="$mapping/*">
<xsl:call-template name="_process_label_mapping_includes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="mapping" select="$mapping/*[1]" />
<xsl:with-param name="repo-field">
<xsl:choose>
<xsl:when test="$repository-type='eprints'"><xsl:value-of select="string($mapping/@eprints)" /></xsl:when>
<xsl:when test="$repository-type='dspace'"><xsl:value-of select="string($mapping/@dspace)" /></xsl:when>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="list-separator" select="string($mapping/@list-separator)" />
<xsl:with-param name="use-siblings">true</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="_process_label_mapping_includes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field">
<xsl:choose>
<xsl:when test="$repository-type='eprints'"><xsl:value-of select="string($mapping/@eprints)" /></xsl:when>
<xsl:when test="$repository-type='dspace'"><xsl:value-of select="string($mapping/@dspace)" /></xsl:when>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="list-separator" select="string($mapping/@list-separator)" />
<xsl:with-param name="use-siblings" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$mapping/following-sibling::*">
<xsl:call-template name="_process_label_mapping">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="mapping" select="$mapping/following-sibling::*" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="_process_label_mapping_includes">
<xsl:param name="nodes" />
<xsl:param name="mapping" />
<xsl:param name="repo-field" />
<xsl:param name="list-separator" />
<xsl:param name="use-siblings" />
<xsl:variable name="nodes_to_add" select="*" />
<xsl:choose>
<xsl:when test="$mapping/@scheme and $mapping/@origin and $mapping/@source">
<xsl:call-template name="_process_label_mapping_excludes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="nodes_to_add" select="$nodes_to_add[@scheme=$mapping/@scheme and @origin=$mapping/@origin and @source=$mapping/@source]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@origin and $mapping/@source">
<xsl:call-template name="_process_label_mapping_excludes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="nodes_to_add" select="$nodes_to_add[@origin=$mapping/@origin and @source=$mapping/@source]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@scheme and $mapping/@origin">
<xsl:call-template name="_process_label_mapping_excludes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="nodes_to_add" select="$nodes_to_add[@scheme=$mapping/@scheme and @origin=$mapping/@origin]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@scheme and $mapping/@source">
<xsl:call-template name="_process_label_mapping_excludes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="nodes_to_add" select="$nodes_to_add[@scheme=$mapping/@scheme and @source=$mapping/@source]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@scheme">
<xsl:call-template name="_process_label_mapping_excludes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="nodes_to_add" select="$nodes_to_add[@scheme=$mapping/@scheme]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@origin">
<xsl:call-template name="_process_label_mapping_excludes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="nodes_to_add" select="$nodes_to_add[@origin=$mapping/@origin]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@source">
<xsl:call-template name="_process_label_mapping_excludes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="nodes_to_add" select="$nodes_to_add[@source=$mapping/@source]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="_process_label_mapping_excludes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="nodes_to_add" select="$nodes_to_add" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="_process_label_mapping_excludes">
<xsl:param name="nodes" />
<xsl:param name="nodes_to_add" />
<xsl:param name="mapping" />
<xsl:param name="repo-field" />
<xsl:param name="list-separator" />
<xsl:param name="use-siblings" />
<xsl:choose>
<xsl:when test="$mapping/@exclude-scheme and $mapping/@exclude-origin and $mapping/@exclude-source">
<xsl:call-template name="_process_label_mapping_output">
<xsl:with-param name="nodes" select="$nodes|$nodes_to_add[not(@scheme=$mapping/@exclude-scheme and @origin=$mapping/@exclude-origin and @source=$mapping/@exclude-source)]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@exclude-origin and $mapping/@exclude-source">
<xsl:call-template name="_process_label_mapping_output">
<xsl:with-param name="nodes" select="$nodes|$nodes_to_add[not(@origin=$mapping/@exclude-origin and @source=$mapping/@exclude-source)]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@exclude-scheme and $mapping/@exclude-origin">
<xsl:call-template name="_process_label_mapping_output">
<xsl:with-param name="nodes" select="$nodes|$nodes_to_add[not(@scheme=$mapping/@exclude-scheme and @origin=$mapping/@exclude-origin)]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@exclude-scheme and $mapping/@exclude-source">
<xsl:call-template name="_process_label_mapping_output">
<xsl:with-param name="nodes" select="$nodes|$nodes_to_add[not(@scheme=$mapping/@exclude-scheme and @source=$mapping/@exclude-source)]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@exclude-scheme">
<xsl:call-template name="_process_label_mapping_output">
<xsl:with-param name="nodes" select="$nodes|$nodes_to_add[not(@scheme=$mapping/@exclude-scheme)]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@exclude-origin">
<xsl:call-template name="_process_label_mapping_output">
<xsl:with-param name="nodes" select="$nodes|$nodes_to_add[not(@origin=$mapping/@exclude-origin)]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$mapping/@exclude-source">
<xsl:call-template name="_process_label_mapping_output">
<xsl:with-param name="nodes" select="$nodes|$nodes_to_add[not(@source=$mapping/@exclude-source)]" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="_process_label_mapping_output">
<xsl:with-param name="nodes" select="$nodes|$nodes_to_add" />
<xsl:with-param name="mapping" select="$mapping" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="_process_label_mapping_output">
<xsl:param name="nodes" />
<xsl:param name="mapping" />
<xsl:param name="repo-field" />
<xsl:param name="list-separator" />
<xsl:param name="use-siblings" />
<xsl:choose>
<xsl:when test="$use-siblings and $mapping/following-sibling::*">
<xsl:call-template name="_process_label_mapping_includes">
<xsl:with-param name="nodes" select="$nodes" />
<xsl:with-param name="mapping" select="$mapping/following-sibling::*[1]" />
<xsl:with-param name="repo-field" select="$repo-field" />
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="use-siblings" select="$use-siblings" />
</xsl:call-template>
</xsl:when>
<xsl:when test="$list-separator">
<!--
Render as a string list
- note this duplicates some code from elsewhere. Should try to consolidate later.
-->
<xsl:call-template name="_render_field_mapping">
<xsl:with-param name="field" select="$repo-field" />
<xsl:with-param name="value">
<xsl:call-template name="_render_field_occurrence">
<xsl:with-param name="field" select="$repo-field" />
<xsl:with-param name="value">
<xsl:apply-templates select="$nodes" mode="_render_to_list">
<!-- xsl:with-param name="max" / --><!-- max restriction not implemented -->
<xsl:with-param name="list-separator" select="$list-separator" />
<xsl:with-param name="repo_field" select="$repo-field" />
</xsl:apply-templates>
</xsl:with-param>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!--
Render as separate instances
- note this duplicates some code from elsewhere. Should try to consolidate later.
-->
<xsl:call-template name="_render_field_mapping">
<xsl:with-param name="field" select="$repo-field" />
<xsl:with-param name="value">
<!-- Render multiple occurrences -->
<xsl:for-each select="$nodes">
<!-- Max restriction not implemented for now -->
<!-- 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">labels</xsl:with-param>
<xsl:with-param name="repo_field" select="$repo-field" />
</xsl:apply-templates>
</xsl:with-param>
</xsl:call-template>
<!-- /xsl:if -->
</xsl:for-each>
</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>