-
Notifications
You must be signed in to change notification settings - Fork 0
/
front.xsl
392 lines (342 loc) · 15.9 KB
/
front.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- front matter -->
<xsl:template match="front/article-meta">
<header class="{local-name()} front">
<xsl:apply-templates select="$title"/>
<div class="article-authors">
<xsl:apply-templates select="$authors" mode="front"/>
<xsl:apply-templates select="$meta/contrib-group[@content-type='authors']/on-behalf-of"/>
</div>
<div id="article-information">
<div class="article-notes">
<xsl:apply-templates select="contrib-group/aff" mode="front"/>
<xsl:apply-templates select="author-notes/fn" mode="front"/>
</div>
<dl class="article-identifiers">
<dt>
<xsl:text> DOI</xsl:text>
</dt>
<dd>
<a href="https://doi.org/{$doi}" itemprop="sameAs">
<xsl:value-of select="concat('', $doi)"/>
</a>
<meta itemprop="sameAs" content="info:doi/{$doi}"/>
</dd>
</dl>
<dl class="article-dates">
<!-- TODO: handle multiple "corrected" dates -->
<xsl:if test="history/date[@date-type='corrected']/@iso-8601-date">
<dt>Corrected</dt>
<dd>
<!-- note: dateCorrected is not a real property -->
<time data-itemprop="dateCorrected">
<xsl:value-of select="history/date[@date-type='corrected']/@iso-8601-date"/>
</time>
</dd>
</xsl:if>
<dt>Published</dt>
<dd>
<time itemprop="datePublished">
<xsl:value-of select="$pub-date/@iso-8601-date"/>
</time>
</dd>
<xsl:if test="history/date[@date-type='accepted']/@iso-8601-date">
<dt>Accepted</dt>
<dd>
<!-- note: dateAccepted is not a real property -->
<time data-itemprop="dateAccepted">
<xsl:value-of select="history/date[@date-type='accepted']/@iso-8601-date"/>
</time>
</dd>
</xsl:if>
<xsl:if test="history/date[@date-type='received']/@iso-8601-date">
<dt>Received</dt>
<dd>
<time itemprop="dateCreated">
<xsl:value-of select="history/date[@date-type='received']/@iso-8601-date"/>
</time>
</dd>
</xsl:if>
</dl>
<xsl:if test="count($editors) > 0">
<dl class="article-editors">
<dt>Academic Editor</dt>
<xsl:for-each select="$editors">
<dd itemprop="editor" itemscope="itemscope" itemtype="http://schema.org/Person">
<a itemprop="url" href="editor-{ position() }" class="{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</a>
</dd>
</xsl:for-each>
</dl>
</xsl:if>
<dl class="article-subjects">
<dt>Subject Areas</dt>
<dd><xsl:apply-templates select="article-categories/subj-group[@subj-group-type='categories']/subject" mode="front"/></dd>
<dt>Keywords</dt>
<dd><xsl:apply-templates select="kwd-group[@kwd-group-type='author']/kwd" mode="front"/></dd>
</dl>
<dl class="article-license">
<xsl:apply-templates select="permissions/copyright-statement" mode="front"/>
<xsl:apply-templates select="permissions/license" mode="front"/>
</dl>
<xsl:call-template name="self-citation">
<xsl:with-param name="meta" select="."/>
</xsl:call-template>
<xsl:if test="$public-reviews">
<xsl:variable name="prefix">
<xsl:choose>
<xsl:when test="count($authors) = 1">The author has</xsl:when>
<xsl:otherwise>The authors have</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="alert alert-success view-public-reviews"><xsl:value-of select="$prefix"/> chosen to make <a href="{$public-reviews}">the review history of this article</a> public.</div>
</xsl:if>
<!-- the "version" custom-meta might not be present -->
<xsl:if test="$itemVersion">
<meta itemprop="version" content="{$itemVersion}"/>
</xsl:if>
</div>
<xsl:apply-templates select="abstract"/>
<xsl:apply-templates select="../notes[@notes-type='author-note']"/>
</header>
</xsl:template>
<!-- abstract -->
<xsl:template match="abstract">
<div>
<h2>Abstract</h2>
<div class="{local-name()}" itemprop="description">
<xsl:apply-templates select="node()|@*"/>
</div>
</div>
</xsl:template>
<!-- author note -->
<xsl:template match="notes[@notes-type='author-note']">
<div>
<h2>Author Comment</h2>
<div class="{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</div>
</div>
</xsl:template>
<!-- aff -->
<xsl:template match="aff" mode="front">
<div itemscope="itemscope" itemtype="http://schema.org/Organization">
<xsl:apply-templates select="@*"/>
<span class="article-label-container">
<xsl:apply-templates select="label"/>
<xsl:if test="not(label)"> </xsl:if><!-- non-breaking space, to prevent collapsing elements -->
</span>
<xsl:call-template name="affiliation-address"/>
</div>
</xsl:template>
<!-- affiliation address -->
<xsl:template name="affiliation-address">
<xsl:variable name="address-parts" select="node()[not(local-name() = 'label')][not(self::text())]"/>
<xsl:if test="count($address-parts) > 0">
<span itemprop="address">
<xsl:for-each select="$address-parts">
<xsl:apply-templates select="."/>
<xsl:call-template name="comma-separator"/>
</xsl:for-each>
</span>
</xsl:if>
</xsl:template>
<!-- affiliation address as text string -->
<xsl:template name="affiliation-address-text">
<xsl:variable name="address">
<xsl:call-template name="affiliation-address"/>
</xsl:variable>
<xsl:value-of select="$address"/>
</xsl:template>
<!-- fn -->
<xsl:template match="fn" mode="front">
<div>
<xsl:apply-templates select="@*"/>
<span class="article-label-container">
<xsl:apply-templates select="label"/>
<xsl:if test="not(label)"> </xsl:if>
<!-- non-breaking space, to prevent collapsing elements -->
</span>
<span>
<xsl:apply-templates select="node()[not(local-name() = 'label')]"/>
</span>
</div>
</xsl:template>
<!-- subject area -->
<xsl:template match="subject" mode="front">
<xsl:variable name="encoded-subject">
<xsl:call-template name="urlencode">
<xsl:with-param name="value" select="."/>
</xsl:call-template>
</xsl:variable>
<a class="{local-name()}" itemprop="about" href="{$search-root}?filter={$encoded-subject}">
<xsl:apply-templates select="node()|@*"/>
</a>
<xsl:call-template name="comma-separator"/>
</xsl:template>
<!-- keyword -->
<xsl:template match="kwd" mode="front">
<span class="{local-name()}" itemprop="keywords">
<xsl:apply-templates select="node()|@*"/>
</span>
<xsl:call-template name="comma-separator"/>
</xsl:template>
<!-- copyright statement -->
<xsl:template match="copyright-statement" mode="front">
<dt>Copyright</dt>
<dd>
<xsl:text>© </xsl:text>
<span itemprop="copyrightYear">
<xsl:value-of select="../copyright-year"/>
</span>
<xsl:text> </xsl:text>
<span itemprop="copyrightHolder">
<xsl:value-of select="../copyright-holder"/>
</span>
<!--<xsl:apply-templates select="node()"/>-->
</dd>
</xsl:template>
<!-- license -->
<xsl:template match="license" mode="front">
<dt>Licence</dt>
<dd>
<xsl:apply-templates select="node()"/>
</dd>
</xsl:template>
<!-- license paragraph -->
<xsl:template match="license-p">
<span class="{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</span>
</xsl:template>
<!-- contrib in front matter -->
<xsl:template match="contrib" mode="front">
<span class="{local-name()}" itemscope="itemscope" itemtype="http://schema.org/Person">
<xsl:apply-templates select="@*"/>
<xsl:if test="@contrib-type = 'author'">
<xsl:attribute name="itemprop">author</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="@contrib-type = 'author'">
<xsl:variable name="author-url">
<xsl:choose>
<xsl:when test="@xlink:href">
<xsl:value-of select="@xlink:href"/>
</xsl:when>
<xsl:when test="@deceased or collab">
<xsl:value-of select="''"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="author-index" select="count(preceding::contrib[@contrib-type='author'][not(@deceased)][not(collab)]) + 1"/>
<xsl:value-of select="concat('author-', $author-index)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$author-url != ''">
<a href="{$author-url}" rel="author" itemprop="url"><xsl:apply-templates select="name | collab"/></a>
</xsl:when>
<xsl:otherwise>
<span><xsl:apply-templates select="name | collab"/></span>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="name | collab"/>
<!--<xsl:apply-templates select="on-behalf-of"/>--><!-- TODO: display as footnote/xref? -->
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@corresp = 'yes' and email">
<xsl:call-template name="corresponding-email">
<xsl:with-param name="email" select="email"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="xref[@ref-type='corresp']" mode="author"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="@equal-contrib = 'yes'">
<xsl:call-template name="equal-contribution"/>
</xsl:if>
<xsl:if test="@deceased = 'yes'">
<xsl:call-template name="deceased"/>
</xsl:if>
<xsl:if test="xref">
<xsl:variable name="xrefs">
<xsl:for-each select="xref[not(@ref-type='corresp')]">
<xsl:variable name="rid" select="@rid"/>
<xsl:variable name="ref" select="//*[@id=$rid]"/>
<xsl:if test="$ref/label">
<!--<xsl:variable name="ref-type" select="@ref-type"/>-->
<xsl:apply-templates select="$ref" mode="contrib-xref"/>
<xsl:call-template name="comma-separator">
<xsl:with-param name="separator" select="','"/>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test="string-length($xrefs) > 0">
<sup class="contrib-xref-group">
<xsl:copy-of select="$xrefs"/>
</sup>
</xsl:if>
</xsl:if>
</span>
<xsl:call-template name="comma-separator"/>
<!--
<xsl:variable name="contributorId" select="@id"/>
<xsl:variable name="contribution" select="//fn-group[@content-type='author-contributions']//fn[@fn-type='con']//xref[@ref-type='contrib'][@rid=$contributorId]"/>
<xsl:if test="$contribution">
<xsl:apply-templates select="$contribution/ancestor::fn"/>
</xsl:if>
-->
</xsl:template>
<!-- affiliation/corresponding author/footnote link -->
<xsl:template match="*" mode="contrib-xref">
<a class="{local-name()} xref" href="#{@id}">
<xsl:if test="local-name() = 'aff'">
<xsl:attribute name="itemprop">affiliation</xsl:attribute>
<xsl:attribute name="itemscope">itemscope</xsl:attribute>
<xsl:attribute name="itemtype">http://schema.org/Organization</xsl:attribute>
<xsl:attribute name="itemref"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="label"/>
</a>
</xsl:template>
<!-- corresponding author (old-style; remove when converted) -->
<xsl:template match="xref[@ref-type='corresp']" mode="author">
<xsl:variable name="ref" select="key('corresp', @rid)"/>
<xsl:call-template name="corresponding-email">
<xsl:with-param name="email" select="$ref/email"/>
</xsl:call-template>
</xsl:template>
<!-- email the corresponding author -->
<xsl:template name="corresponding-email">
<xsl:param name="email"/>
<a class="corresp" href="mailto:{$email}" target="_blank" title="email the corresponding author" data-toggle="tooltip" itemprop="email"><i class="icon-envelope">​</i></a>
</xsl:template>
<!-- authors with equal contributions -->
<xsl:template name="equal-contribution">
<span class="equal-contribution" title="These authors contributed equally to this work." data-toggle="tooltip"><i class="icon-asterisk">​</i></span>
</xsl:template>
<!-- deceased authors -->
<xsl:template name="deceased">
<span class="deceased" title="Deceased" data-toggle="tooltip"><i class="icon-star-empty">​</i></span>
</xsl:template>
<xsl:template match="label" mode="front">
<span class="article-label">
<xsl:apply-templates select="node()|@*"/>
</span>
</xsl:template>
<xsl:template match="on-behalf-of">
<xsl:text>, </xsl:text>
<span class="{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</span>
</xsl:template>
</xsl:stylesheet>