summaryrefslogtreecommitdiff
path: root/templates/du2html.xsl
blob: 86e0088c9d82abdcaacceb735e6ebde305e899a5 (plain)
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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
<?xml version="1.0" encoding="utf-8"?>
<x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform"
              xmlns="http://www.w3.org/1999/xhtml"
              xmlns:e="http://exslt.org/common"
              xmlns:s="http://exslt.org/strings"
              xmlns:wc="http://webcoso.thenautilus.net/"
              exclude-result-prefixes="wc e s"
              version="1.0"
              >
 
 <x:import href="reST.xsl"/>
 
 <x:param name="language" select="'en'"/>
 <x:param name="path"/>
 <x:param name="filename"/>
 
 <x:variable name="locale">
  <x:choose>
   <x:when test="$language = 'it'">it_IT</x:when>
   <x:when test="$language = 'en'">en_GB</x:when>
   <x:otherwise><!-- uh? --><x:value-of select="$language"/></x:otherwise>
  </x:choose>
 </x:variable>
 
 <x:variable name="langs-rtf">
  <x:choose>
   <x:when test="$language = 'it'">
    <lang>it</lang>
    <lang>en</lang>
   </x:when>
   <x:when test="$language = 'en'">
    <lang>en</lang>
    <lang>it</lang>
   </x:when>
   <x:otherwise> <!-- uh? -->
    <lang><x:value-of select="$language"/></lang>
   </x:otherwise>
  </x:choose>
 </x:variable>
 <x:variable name="langs" select="e:node-set($langs-rtf)/node()"/>
 
 <x:variable name="link-names-rtf">
  <link rel="prev" lang="it">Precendente</link> <link rel="prev" lang="en">Previous</link>
  <link rel="next" lang="it">Successivo</link> <link rel="next" lang="en">Next</link>
  <link rel="contents" lang="it">Indice</link> <link rel="contents" lang="en">Contents</link>
  <link rel="index" lang="it">Indice</link> <link rel="index" lang="en">Index</link>
  <link rel="glossary" lang="it">Glossario</link> <link rel="glossary" lang="en">Glossary</link>
  <link rel="copyright" lang="it">Copyright</link> <link rel="copyright" lang="en">Copyright</link>
  <link rel="start" lang="it">Inizio</link> <link rel="start" lang="en">Start</link>
  <link rel="chapter" lang="it">Capitolo</link> <link rel="chapter" lang="en">Chapter</link>
  <link rel="section" lang="it">Sezione</link> <link rel="section" lang="en">Section</link>
  <link rel="subsection" lang="it">Sotto-sezione</link> <link rel="subsection" lang="en">Subsection</link>
  <link rel="appendix" lang="it">Appendice</link> <link rel="appendix" lang="en">Appendix</link>
  <link rel="help" lang="it">Guida</link> <link rel="help" lang="en">Help</link>
 </x:variable>
 <x:variable name="link-names" select="e:node-set($link-names-rtf)/node()" />
 
 <x:variable name="const-tr-rtf">
  <t t="dates" l="it">Date</t> <t t="dates" l="en">Dates</t>
  <t t="created" l="it">Creato: </t> <t t="created" l="en">Created: </t>
  <t t="lastmod" l="it">Ultima modifica: </t> <t t="lastmod" l="en">Last modification: </t>
  <t t="alt-lang" l="it">Altre lingue</t> <t t="alt-lang" l="en">Other languages</t>
  <t t="en">English</t><t t="it">Italiano</t>
  <t t="tags" l="it">Tag</t> <t t="tags" l="en">Tags</t>
  <t t="navlinks" l="it">Documenti correlati</t> <t t="navlinks" l="en">Related documents</t>
  <t t="navtags" l="it">Alcuni tag</t> <t t="navtags" l="en">Some tags</t>
  <t t="alltags" l="it">Tutti i tag</t> <t t="alltags" l="en">All tags</t>
  <t t="by" l="it"> di </t><t t="by" l="en"> by </t>
  <t t="license" l="it"> è distribuito sotto una licenza </t><t t="license" l="en"> is distributed under the license </t>
  <t t="comments" l="it">Per commenti, </t><t t="comments" l="en">If you have comments, </t>
  <t t="mailsubj" l="it">Commenti su </t><t t="mailsubj" l="en">Comments on </t>
  <t t="writeme" l="it">scrivetemi</t><t t="writeme" l="en">write me</t>
  <t t="attention" l="it">Attenzione!</t> <t t="attention" l="en">Attention!</t>
  <t t="caution" l="it">Cautela!</t> <t t="caution" l="en">Caution!</t>
  <t t="danger" l="it">!PERICOLO!</t> <t t="danger" l="en">!DANGER!</t>
  <t t="error" l="it">Errore</t> <t t="error" l="en">Error</t>
  <t t="hint" l="it">Suggerimento</t> <t t="hint" l="en">Hint</t>
  <t t="important" l="it">Importante</t> <t t="important" l="en">Important</t>
  <t t="note" l="it">Nota</t> <t t="note" l="en">Note</t>
  <t t="tip" l="it">Trucco</t> <t t="tip" l="en">Tip</t>
  <t t="warning" l="it">Avvertenza</t> <t t="warning" l="en">Warning</t>
  <t t="wishlist" l="it">Volete farmi un regalo? Qualche suggerimento su Amazon</t>
  <t t="wishlist" l="en">Want to get me a present? Some suggestions on Amazon</t>
  <t t="cgit" l="it">Progetti Software</t>
  <t t="cgit" l="en">My Software Projects</t>
 </x:variable>
 <x:variable name="const-tr" select="e:node-set($const-tr-rtf)/node()" />
 
 <x:output method="xml" encoding="utf-8"
           doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
           doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
           indent="yes"/>
 
 <x:template match="system_message" />
 <x:template match="*[@classes='system-messages']" />
 
 <!--
     i casini con quel ancestor::document sono dovuti a:
 
     1) il fatto che $filename non è il nome del documento che stiamo
        toccando, quando espandiamo i documenti dentro al feed
 
     2) un bug di LibXML o LibXSLT, per cui /document/@source non va
 -->
 
 <x:template match="reference">
  <x:element name="a">
   <x:attribute name="href">
    <x:choose>
     <x:when test="@refid">
      <x:value-of select="concat('#', @refid)" />
     </x:when>
     <x:when test="@refuri">
      <x:value-of select="@refuri"/>
     </x:when>
    </x:choose>
   </x:attribute>
 
   <x:choose>
    <x:when test="@refuri and string(.)=string(@refuri)">
     <x:apply-templates select="wc:title-for($langs,ancestor::document/@source,@refuri)/node()"/>
    </x:when>
    <x:otherwise>
     <x:apply-templates />
    </x:otherwise>
   </x:choose>
  </x:element>
 </x:template>
 
 <x:template match="target[@refid and not(@refuri)]">
  <a name="{@refid}">
   <x:apply-templates/>
  </a>
 </x:template>
 
 <x:template match="target[@ids and not(@refuri)]">
  <x:variable name="this" select="."/>
  <x:for-each select="s:split(@ids,' ')/token">
   <a name="{.}">
    <x:apply-templates select="$this/node()"/>
   </a>
  </x:for-each>
 </x:template>
 
 <x:template match="wc:title/title">
  <x:copy-of select="parent::node()"/>
  <x:apply-templates/>
 </x:template>
 
 <x:template match="*" mode="admonition-title">
  <x:variable name="n" select="local-name()"/>
  <x:value-of select="$const-tr[@t=$n and @l=$language]"/>
 </x:template>
 
 <x:template match="list_item/paragraph">
  <p><x:apply-templates/></p>
 </x:template>
 
 <x:template match="list_item[count(paragraph)=1]/paragraph">
  <x:apply-templates/>
 </x:template>
 
 <x:template match="field[field_name='feed']">
  <x:variable name="url" select="normalize-space(string(field_body))"/>
  <link rel="alternate" type="application/atom+xml" href="{$url}feed.{$language}.xml"/>
 </x:template>
 
 <x:template match="image[contains(concat(' ',normalize-space(string(@classes)),' '),' preview ')]" mode="og-meta">
  <x:variable name="uri-with-slash" select="wc:dst-uri-for(@uri,/document/@source)" />
  <!-- dst-uri-for appends a / at the end :( -->
  <x:variable name="uri" select="substring($uri-with-slash,1,string-length($uri-with-slash) - 1)" />
  <meta name="twitter:image" content="https://www.thenautilus.net{$uri}" />
  <x:if test="@alt">
   <meta name="twitter:image:alt" content="{@alt}" />
  </x:if>
  <meta property="og:image" content="https://www.thenautilus.net{$uri}" />
  <x:if test="@alt">
   <meta property="og:image:alt" content="{@alt}" />
  </x:if>
 </x:template>
 <x:template match="image" mode="og-meta" priority="-1" />
 
 <x:template match="/document" mode="og-description">
  <x:choose>
   <x:when test="subtitle">
    <x:value-of select="normalize-space(subtitle)" />
   </x:when>
   <x:otherwise>
    <x:variable name="content">
     <x:apply-templates select="paragraph[1]"/>
    </x:variable>
    <x:value-of select="substring(normalize-space($content),0,200)"/>
    <x:if test="string-length(normalize-space($content)) &gt; 200">
     <x:text></x:text>
    </x:if>
   </x:otherwise>
  </x:choose>
 </x:template>
 
 <x:template match="video">
  <video controls="true" playsinline="true">
   <x:if test="@loop"><x:attribute name="loop">true</x:attribute></x:if>
   <x:attribute name="width">
    <x:value-of select="@width" />
   </x:attribute>
   <x:attribute name="height">
    <x:value-of select="@height" />
   </x:attribute>
   <source src="{@uri}">
    <x:if test="@type">
     <x:attribute name="type"><x:value-of select="@type"/></x:attribute>
    </x:if>
   </source>
   <x:if test="@alt"><x:value-of select="@alt"/></x:if>
  </video>
 </x:template>
 
 <!-- qui ce ne freghiamo del @source, tanto viene usata solo per i
      documenti stand-alone -->
 
 <x:template match="/document">
  <html xml:lang="{$language}" lang="{$language}">
   <head prefix="og: https://ogp.me/ns#">
    <title><x:value-of select="normalize-space(title)"/></title>
    <x:apply-templates select="." mode="stylesheet" />
    <link rel="icon" type="image/png" href="/favicon.png" />
    <x:apply-templates select="docinfo/field[field_name='feed']"/>
    <x:apply-templates select="docinfo" mode="nav-links" />
    <x:if test="$path = ''"> <!-- root / index document -->
     <meta name="google-site-verification" content="NStibYPYcJWPVXEJMnjEOvQazfKubbaz3TrEi64my-Y" />
    </x:if>
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:site" content="@dakkar" />
    <meta name="twitter:title" content="{normalize-space(title)}" />
    <meta property="og:site_name" content="the Nautilus" />
    <meta property="og:title" content="{normalize-space(title)}" />
    <x:apply-templates select="//image" mode="og-meta" />
    <meta name="twitter:description">
     <x:attribute name="content">
      <x:apply-templates select="." mode="og-description" />
     </x:attribute>
    </meta>
    <meta property="og:description">
     <x:attribute name="content">
      <x:apply-templates select="." mode="og-description" />
     </x:attribute>
    </meta>
    <meta property="og:locale" content="{$locale}" />
   </head>
   <body>
    <div id="wrapper">
     <div id="toplink">
      <x:apply-templates select="." mode="top"/>
     </div>
     <div id="title">
      <x:apply-templates select="." mode="title"/>
     </div>
     <div id="main-col">
      <x:apply-templates select="." mode="topnav"/>
      <div id="content">
       <x:apply-templates select="." mode="content"/>
      </div>
      <x:apply-templates select="." mode="bottomnav"/>
     </div>
     <div id="sidebar">
      <x:apply-templates select="." mode="sidebar"/>
     </div>
     <div id="push"></div>
    </div>
    <div id="footer">
     <x:apply-templates select="." mode="footer"/>
    </div>
   </body>
  </html>
 </x:template>
 
 <x:template match="/document/subtitle" />
 
 <x:template match="/document" mode="top">
  <a href="/"><img src="/logo.png" alt="thenautilus.net"/></a>
 </x:template>
 
 <x:template match="/document" mode="title">
  <h1 class="title">
   <x:apply-templates select="title/node()"/>
  </h1>
  <x:if test="subtitle">
   <h2 class="subtitle">
    <x:apply-templates select="subtitle/node()"/>
   </h2>
  </x:if>
 </x:template>
 
 <x:template match="/document" mode="stylesheet">
  <x:apply-templates select="." mode="stylesheet-global"/>
  <x:apply-templates select="." mode="stylesheet-local"/>
 </x:template>
 
 <x:template match="/document" mode="stylesheet-global">
  <link rel="stylesheet" type="text/css" href="/layout.css" media="screen" />
  <link rel="stylesheet" type="text/css" href="/print.css" media="print" />
  <link rel="stylesheet" type="text/css" href="/html4css1.css" />
  <link rel="stylesheet" type="text/css" href="/content.css" />
 </x:template>
 
 <x:template match="/document" mode="stylesheet-local">
  <x:for-each select="docinfo/field[field_name='css']/field_body/*/list_item|docinfo/field[field_name='css']/field_body/paragraph">
   <link rel="stylesheet" type="text/css" href="{normalize-space(.)}" />
  </x:for-each>
  <x:for-each select="docinfo/field[field_name='inline-css']/field_body">
   <style type="text/css">
    <x:value-of select="." disable-output-escaping="yes" />
   </style>
  </x:for-each>
 </x:template>
 
 <x:template match="/document" mode="topnav">
  <x:apply-templates select="docinfo" mode="tags" />
  <x:apply-templates select="." mode="alternate-langs" />
 </x:template>
 
 <x:template match="/document" mode="content">
  <x:apply-templates/>
 </x:template>
 
 <x:template match="/document" mode="bottomnav">
  <x:apply-templates select="." mode="dates" />
 </x:template>
 
 <x:template match="/document" mode="sidebar">
  <x:apply-templates select="." mode="navblock"/>
  <x:apply-templates select="." mode="navtags"/>
  <x:apply-templates select="." mode="amazon"/>
 </x:template>
 
 <x:template match="/document" mode="navblock">
  <x:apply-templates select="docinfo" mode="nav-block" />
 </x:template>
 
 <x:template match="/document" mode="navtags">
  <div class="nav" id="nav-tags">
   <span class="title"><x:value-of select="$const-tr[@t='navtags' and @l=$language]" /></span>
   <ul>
    <li><x:call-template name="taglink"><x:with-param name="tag">hardware</x:with-param></x:call-template></li>
    <li><x:call-template name="taglink"><x:with-param name="tag">software</x:with-param></x:call-template></li>
    <li><x:call-template name="taglink"><x:with-param name="tag">review</x:with-param></x:call-template></li>
    <x:if test="$language = 'it'"> <!-- non ci sono racconti in inglese, per ora -->
     <li><x:call-template name="taglink"><x:with-param name="tag">racconti</x:with-param></x:call-template></li>
    </x:if>
    <li><x:call-template name="taglink"><x:with-param name="tag">viaggi</x:with-param></x:call-template></li>
    <li><a href="/cgit/"><x:value-of select="$const-tr[@t='cgit' and @l=$language]"/></a></li>
   </ul>
   <a href="{wc:dst-uri-for('/tags/')}"><x:value-of select="$const-tr[@t='alltags' and @l=$language]"/></a>
   <hr />
   <p>
    <a href="{wc:dst-uri-for('/contacts/')}"><x:apply-templates select="wc:title-for($language,$filename,'/contacts/')/node()" /></a>
   </p>
   <p>
    <a href="https://s.thenautilus.net/@dakkar" rel="me" class="icon-link"><img src="/fedi.svg" /></a>
    <a href="https://twitter.com/dakkar" rel="me" class="icon-link"><img src="/twitter.svg" /></a>
    <a href="https://instagram.com/dakkarinsta" rel="me" class="icon-link"><img src="/instagram.svg" /></a>
   </p>
  </div>
 </x:template>
 
 <x:template match="/document" mode="amazon">
  <div id="amazon-wishlist">
   <a href="//www.amazon.co.uk/registry/wishlist/INP247PNKQSZ">
    <x:value-of select="$const-tr[@t='wishlist' and @l=$language]"/>
   </a>
  </div>
 </x:template>
 
 <x:template match="/document" mode="footer">
  <x:apply-templates select="." mode="license"/>
  <x:apply-templates select="." mode="contacts"/>
 </x:template>
 
 <x:template match="/document" mode="license">
  <p class="license">
   <a rel="license" href="//creativecommons.org/licenses/by-sa/2.5/it/">
    <img alt="Creative Commons License" style="border-width:0" src="//i.creativecommons.org/l/by-sa/2.5/it/88x31.png" />
   </a>
   “<span xmlns:dc="http://purl.org/dc/elements/1.1/" href="//purl.org/dc/dcmitype/Text" property="dc:title" rel="dc:type">
   <x:value-of select="normalize-space(/document/title)"/>
   </span>
   <x:value-of select="$const-tr[@t='by' and @l=$language]"/>
   <a xmlns:cc="http://creativecommons.org/ns#" href="mailto:dakkar@thenautilus.net" property="cc:attributionName" rel="cc:attributionURL">Gianni Ceccarelli</a>
   <x:value-of select="$const-tr[@t='license' and @l=$language]"/>
   <a rel="license" href="//creativecommons.org/licenses/by-sa/2.5/it/">Creative Commons By-SA 2.5 It</a>.
  </p>
 </x:template>
 
 <x:template match="/document" mode="contacts">
  <p class="contacts">
   <x:value-of select="$const-tr[@t='comments' and @l=$language]"/>
   <a href="mailto:dakkar@thenautilus.net?subject={s:encode-uri(concat($const-tr[@t='mailsubj' and @l=$language],normalize-space(string(/document/title))),false)}">
    <x:value-of select="$const-tr[@t='writeme' and @l=$language]"/>
    </a>.
  </p>
 </x:template>
 
 <x:template name="taglink">
  <x:param name="tag"/>
  <a href="{wc:dst-uri-for(concat('/tags/',$tag,'/'))}">
   <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',$tag,'/'))/node()"/>
  </a>
 </x:template>
 
 <x:template match="/document" mode="dates">
  <x:variable name="d" select="wc:dates-for($language,$filename,'./')/wc:dates"/>
  <div id="dates">
   <span class="title"><x:value-of select="$const-tr[@t='dates' and @l=$language]" /></span>
   <span id="created">
    <x:value-of select="$const-tr[@t='created' and @l=$language]" />
    <span class="date created"><x:value-of select="$d/wc:creation-date"/></span>
   </span>
   <x:text> </x:text>
   <span id="lastmod">
    <x:value-of select="$const-tr[@t='lastmod' and @l=$language]" />
    <span class="date lastmod"><x:value-of select="$d/wc:last-change"/></span>
   </span>
  </div>
 </x:template>
 
 <x:template match="/document" mode="alternate-langs">
  <x:variable name="me" select="wc:dst-uri-for('.',/document/@source,1)" />
  <x:variable name="alts">
   <x:for-each select="wc:changes()/wc:changes/wc:document[@uri=$me]">
    <x:variable name="l" select="@lang" />
    <x:if test="$l != $language">
     <li><a href="{$l}"><x:value-of select="$const-tr[@t=$l]"/></a></li>
    </x:if>
   </x:for-each>
  </x:variable>
  <x:if test="normalize-space($alts) != ''">
   <div id="alt-langs">
    <span class="title"><x:value-of select="$const-tr[@t='alt-lang' and @l=$language]" /></span>
    <ul>
     <x:copy-of select="$alts"/>
    </ul>
   </div>
  </x:if>
 </x:template>
 
 <x:template match="/wc:tags">
  <dl>
   <x:apply-templates/>
  </dl>
 </x:template>
 
 <x:template match="wc:tag">
  <dt>
   <span class="tag title">
    <a href="{concat('/tags/',@name,'/')}">
     <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',@name,'/'))/node()"/>
    </a>
   </span>
  </dt>
  <dd>
   <ul>
    <x:apply-templates/>
   </ul>
  </dd>
 </x:template>
 
 <x:template match="wc:doc">
  <li>
   <a class="tag doc" href="{@uri}"><x:apply-templates select="wc:title-for($language,$filename,@uri)/node()"/></a>
   (<span class="tag doc langs"><x:apply-templates/></span>)
  </li>
 </x:template>
 
 <x:template match="wc:lang">
  <x:choose>
   <x:when test=".!=$language">
    <a href="{../@uri}{.}" class="lang"><x:value-of select="."/></a>
   </x:when>
   <x:otherwise>
    <span class="lang"><x:value-of select="."/></span>
   </x:otherwise>
  </x:choose>
  <x:if test="following-sibling::wc:lang"> | </x:if>
 </x:template>
 
 <x:template match="docinfo" mode="tags">
  <x:variable name="tags">
   <x:apply-templates select="field" mode="tags"/>
  </x:variable>
  <x:if test="normalize-space($tags) != ''">
   <div id="tags">
    <span class="title"><x:value-of select="$const-tr[@t='tags' and @l=$language]" /></span>
    <ul>
     <x:copy-of select="$tags" />
    </ul>
   </div>
  </x:if>
 </x:template>
 
 <x:template match="field[field_name='tags']/field_body/*/list_item|field[field_name='tags']/field_body/paragraph" mode="tags">
  <x:variable name="tag-name"><x:value-of select="normalize-space(.)"/></x:variable>
  <li>
   <span class="tag">
    <a href="{concat('/tags/',$tag-name,'/')}">
     <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',$tag-name,'/'))/node()"/>
    </a>
   </span>
  </li>
 </x:template>
 
 <x:template match="field[field_name != 'tags']" mode="tags" priority="-1" />
 <x:template match="field_name" mode="tags" priority="-1" />
 
 <x:template match="docinfo" mode="nav-block">
  <x:variable name="links">
   <x:apply-templates select="field" mode="nav-block"/>
  </x:variable>
  <x:if test="normalize-space($links) != ''">
   <div class="nav" id="nav-links">
    <span class="title"><x:value-of select="$const-tr[@t='navlinks' and @l=$language]" /></span>
    <dl>
     <x:copy-of select="$links" />
    </dl>
   </div>
  </x:if>
 </x:template>
 
 <x:template match="field[field_name='prev' or field_name='next' or field_name='contents' or field_name='index' or field_name='glossary' or field_name='copyright' or field_name='start' or field_name='chapter' or field_name='section' or field_name='subsection' or field_name='appendix' or field_name='help']/field_body" mode="nav-block">
  <x:variable name="rel"><x:value-of select="normalize-space(parent::field/field_name)" /></x:variable>
  <x:variable name="label">
   <x:copy-of select="$link-names[@rel=$rel and @lang=$language]/node()" />
  </x:variable>
  <dt class="nav-link-{$rel}">
   <x:copy-of select="$label"/><x:text></x:text>
  </dt>
  <dd class="nav-link-{$rel}">
   <a class="nav-link-{$rel}" href="{normalize-space(.)}">
    <x:apply-templates select="wc:title-for($langs,ancestor::document/@source,normalize-space(.))/node()"/>
   </a>
  </dd>
 </x:template>
 
 <x:template match="field/field_name|field/field_body" mode="nav-block" priority="-1" />
 
 <x:template match="field[field_name='prev' or field_name='next' or field_name='contents' or field_name='index' or field_name='glossary' or field_name='copyright' or field_name='start' or field_name='chapter' or field_name='section' or field_name='subsection' or field_name='appendix' or field_name='help']/field_body" mode="nav-links">
  <link rel="{normalize-space(parent::field/field_name)}"
        href="{normalize-space(.)}"
        title="{normalize-space(wc:title-for($langs,ancestor::document/@source,normalize-space(.)))}"
        />
 </x:template>
 
 <x:template match="field/field_name|field/field_body" mode="nav-links" priority="-1" />
 
</x:stylesheet>