Source

SCons / src / engine / SCons / Tool / docbook / docbook-xsl-1.76.1 / manpages / endnotes.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
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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:exsl="http://exslt.org/common"
                xmlns:ng="http://docbook.org/docbook-ng"
                xmlns:db="http://docbook.org/ns/docbook"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                exclude-result-prefixes="db ng exsl xlink"
                version='1.0'>

<!-- ********************************************************************
     $Id: endnotes.xsl 8703 2010-07-06 20:57:06Z nwalsh $
     ********************************************************************

     This file is part of the XSL DocBook Stylesheet distribution.
     See ../README or http://docbook.sf.net/release/xsl/current/ for
     copyright and other information.

     ******************************************************************** -->

<!-- ==================================================================== -->
<!-- * -->
<!-- * The templates in this file handle elements whose contents can't -->
<!-- * be displayed completely within the main text flow in output, but -->
<!-- * instead need to be displayed "out of line". Those elements are: -->
<!-- * -->
<!-- *   - elements providing annotative text (annotation|alt|footnote) -->
<!-- *   - elements pointing at external resources (ulink, link, and -->
<!-- *     any elements with xlink:href attributes; and imagedata, -->
<!-- *     audiodata, and videodata - which (using their fileref -->
<!-- *     attribute) reference external files -->
<!-- * -->
<!-- * Within this stylesheet, the above are collectively referred to as -->
<!-- * a "notesources". This stylesheet handles those notesources in -->
<!-- * this way: -->
<!-- * -->
<!-- * 1. Constructs a numbered in-memory index of all unique "earmarks“ -->
<!-- *    of all notesources in the document. For each link, the -->
<!-- *    earmark is the value of its url or xlink:href attribute; for -->
<!-- *    each imagedata|audiodata|videodata: the value of its fileref -->
<!-- *    attribute; for each annotative element: its content. -->
<!-- * -->
<!-- *    Notesources with the same earmark are assigned the same -->
<!-- *    number. -->
<!-- * -->
<!-- *    By design, that index excludes any element whose string value -->
<!-- *    is identical to the value of its url xlink:href attribute). -->
<!-- * -->
<!-- * 2. Puts a numbered marker inline to mark the place where the -->
<!-- *    notesource occurs in the main text flow. -->
<!-- * -->
<!-- * 3. Generates a numbered endnotes list (titled NOTES in English) -->
<!-- *    at the end of the man page, with the contents of each -->
<!-- *    notesource. -->
<!-- * -->
<!-- * Note that table footnotes are not listed in the endnotes list, -->
<!-- * and are not handled by this stylesheet (they are instead handled -->
<!-- * by the table.xsl stylesheet). -->
<!-- * -->
<!-- * Also, we don't get notesources in *info sections or Refmeta or -->
<!-- * Refnamediv or Indexterm, because, in manpages output, contents of -->
<!-- * those are either suppressed or are displayed out of document -->
<!-- * order - for example, the Info/Author content gets moved to the -->
<!-- * end of the page. So, if we were to number notesources in the -->
<!-- * Author content, it would "throw off" the numbering at the -->
<!-- * beginning of the main text flow. -->
<!-- * -->
<!-- * And for the record, one reason we don't use xsl:key to index the -->
<!-- * earmarks is that we need to get and check the sets of -->
<!-- * earmarks for uniqueness per-Refentry (not per-document). -->
<!-- * -->
<!-- * FIXME: -->
<!-- * as with "repeat" URLS, alt instances that have the same string value -->
<!-- * as preceding ones (likely to occur for repeat acroynyms and -->
<!-- * abbreviations) should be listed only once in the endnotes list, -->
<!-- * and numbered accordingly inline; split man.indent.width into -->
<!-- * man.indent.width.value (default 4) and man.indent.width.units -->
<!-- * (default n); also, if the first child of notesource is some block -->
<!-- * content other than a (non-formal) paragraph, the current code -->
<!-- * will probably end up generating a blank line after the -->
<!-- * corresponding number in the endnotes list... we should probably -->
<!-- * try to instead display the title of that block content there (if -->
<!-- * there is one: e.g., the list title, admonition title, etc.) -->

<!-- ==================================================================== -->

<xsl:template name="get.all.earmark.indexes.in.current.document">
  <!-- * Here we create a tree to hold indexes of all earmarks in -->
  <!-- * the current document. If the current document contains -->
  <!-- * multiple refentry instances, then this tree will contain -->
  <!-- * multiple indexes. -->
  <xsl:if test="$man.endnotes.are.numbered != 0">
    <!-- * Only create earmark indexes if user wants numbered endnotes -->
    <xsl:for-each select="//refentry">
      <earmark.index>
        <xsl:attribute name="idref">
          <xsl:value-of select="generate-id()"/>
        </xsl:attribute>
        <xsl:for-each
            select=".//*[self::*[@xlink:href]
                    or self::ulink
                    or self::imagedata
                    or self::audiodata
                    or self::videodata
                    or self::footnote[not(ancestor::table)]
                    or self::annotation
                    or self::alt]
                    [(node()
                      or self::imagedata
                      or self::audiodata
                      or self::videodata
                      )
                    and not(ancestor::refentryinfo)
                    and not(ancestor::info)
                    and not(ancestor::docinfo)
                    and not(ancestor::refmeta)
                    and not(ancestor::refnamediv)
                    and not(ancestor::indexterm)
                    and not(. = @url)
                    and not(. = @xlink:href)
                    and not(@url =
                    preceding::ulink[node()
                    and not(ancestor::refentryinfo)
                    and not(ancestor::info)
                    and not(ancestor::docinfo)
                    and not(ancestor::refmeta)
                    and not(ancestor::refnamediv)
                    and not(ancestor::indexterm)
                    and (generate-id(ancestor::refentry)
                    = generate-id(current()))]/@url)
                    and not(@xlink:href =
                    preceding::*[@xlink:href][node()
                    and not(ancestor::refentryinfo)
                    and not(ancestor::info)
                    and not(ancestor::docinfo)
                    and not(ancestor::refmeta)
                    and not(ancestor::refnamediv)
                    and not(ancestor::indexterm)
                    and (generate-id(ancestor::refentry)
                    = generate-id(current()))]/@xlink:href)
                    and not(@fileref =
                    preceding::*[@fileref][
                    not(ancestor::refentryinfo)
                    and not(ancestor::info)
                    and not(ancestor::docinfo)
                    and not(ancestor::refmeta)
                    and not(ancestor::refnamediv)
                    and not(ancestor::indexterm)
                    and (generate-id(ancestor::refentry)
                    = generate-id(current()))]/@fileref)]">
          <earmark>
            <xsl:attribute name="id">
              <xsl:value-of select="generate-id()"/>
            </xsl:attribute>
            <xsl:attribute name="number">
              <xsl:value-of select="position()"/>
            </xsl:attribute>
            <xsl:if test="@url|@xlink:href|@fileref">
              <!-- * Only add a uri attribute if the notesource is -->
              <!-- * a link or an element that references an external -->
              <!-- * (an imagedata, audiodata, or videodata element) -->
              <xsl:attribute name="uri">
                <xsl:value-of select="@url|@xlink:href|@fileref"/>
              </xsl:attribute>
            </xsl:if>
            <xsl:copy>
              <xsl:copy-of select="node()"/>
            </xsl:copy>
          </earmark>
        </xsl:for-each>
      </earmark.index>
    </xsl:for-each>
  </xsl:if>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template match="*[@xlink:href]|ulink
  |imagedata|audiodata|videodata
  |footnote[not(ancestor::table)]
  |annotation|alt">
  <xsl:variable name="refname" select="ancestor::refentry/refnamediv[1]/refname[1]"/>
  <xsl:variable name="all.earmark.indexes.in.current.document.rtf">
    <xsl:call-template name="get.all.earmark.indexes.in.current.document"/>
  </xsl:variable>
  <xsl:variable name="all.earmark.indexes.in.current.document"
                select="exsl:node-set($all.earmark.indexes.in.current.document.rtf)"/>
  <xsl:variable name="all.earmarks.in.current.refentry.rtf">
    <!-- * get the set of all earmarks for the ancestor Refentry of -->
    <!-- * this notesource -->
    <xsl:copy-of
        select="$all.earmark.indexes.in.current.document/earmark.index
                [@idref =
                generate-id(current()/ancestor::refentry)]/earmark"/>
  </xsl:variable>
  <xsl:variable name="all.earmarks.in.current.refentry"
                select="exsl:node-set($all.earmarks.in.current.refentry.rtf)"/>

  <!-- * identify the earmark for the current element -->
  <xsl:variable name="earmark">
    <xsl:choose>
      <xsl:when test="@url|@xlink:href">
        <xsl:value-of select="@url|@xlink:href"/>
      </xsl:when>
      <xsl:when test="@fileref">
        <xsl:value-of select="@fileref"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="generate-id()"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="notesource.number">
    <!-- * Get the number for this notesource -->
    <!-- * -->
    <!-- * If this is an imagedata, audiodata, or videodata element -->
    <!-- * OR if it's a non-empty element AND its string value is not -->
    <!-- * equal to the value of its url or xlink:href attribute (if -->
    <!-- * it has one) AND user wants endnotes numbered, only then -->
    <!-- * do we output a number for it -->
    <xsl:if test="(self::imagedata or
      self::audiodata or
      self::videodata or
      (node()
      and not(. = @url)
      and not(. = @xlink:href))
      )
      and $man.endnotes.are.numbered != 0">
      <!-- * To select the number for this notesource, we -->
      <!-- * check the index of all earmarks for the current refentry -->
      <!-- * and find the number of the indexed earmark which matches -->
      <!-- * this notesource's earmark. -->
      <!-- * Note that multiple notesources may share the same -->
      <!-- * numbered earmark; in that case, they get the same number. -->
      <!-- * -->
      <xsl:choose>
        <xsl:when test="self::ulink or
          self::*[@xlink:href] or
          self::imagedata or
          self::audiodata or
          self::videodata">
          <xsl:value-of select="$all.earmarks.in.current.refentry/earmark[@uri = $earmark]/@number"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$all.earmarks.in.current.refentry/earmark[@id  = $earmark]/@number"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:variable>

  <xsl:variable name="notesource.contents">
    <xsl:choose>
      <!-- * check to see if the element is empty or not -->
      <xsl:when test="node()">
        <!-- * this is a non-empty node, so process its contents -->
        <xsl:apply-templates/>
        <xsl:if test="../footnote or ../annotation">
          <!-- * if this element is a footnote or annotation, we need to -->
          <!-- * do some further checking on it, so we can emit warnings -->
          <!-- * about potential problems -->
        <xsl:for-each select="node()">
          <xsl:if test="local-name() != 'para' and
                        local-name() != 'simpara' and
                        local-name() !=''">
            <!-- * for each node we find as a child of a footnote or -->
            <!-- * annotation, if it's not a para or a text node, emit a -->
            <!-- * warning... because in manpages output, we can't render -->
            <!-- * block-level child content of an endnote properly unless -->
            <!-- * it's wrapped in a para that has some "prefatory" text -->
            <xsl:variable name="parent-name" select="local-name(..)"/>
            <xsl:variable name="endnote-number">
              <xsl:call-template name="pad-string">
                <!-- * endnote number may be 2 digits, so pad it with a space -->
                <!-- * if we have only 1 digit -->
                <xsl:with-param name="padVar" select="concat('#',$notesource.number)"/>
                <xsl:with-param name="length" select="3"/>
              </xsl:call-template>
            </xsl:variable>
            <xsl:call-template name="log.message">
              <xsl:with-param name="level">Warn</xsl:with-param>
              <xsl:with-param name="source" select="$refname"/>
              <xsl:with-param name="context-desc">
                <xsl:text>endnote </xsl:text>
                <xsl:value-of select="$endnote-number"/>
              </xsl:with-param>
              <xsl:with-param name="message">
                <xsl:text>Bad: </xsl:text>
                <xsl:value-of select="$parent-name"/> 
                <!-- * figure out which occurance of this element type this -->
                <!-- * instance is and output a number in square brackets so -->
                <!-- * that end-user can know which element to fix -->
                <xsl:text>[</xsl:text>
                <xsl:value-of select="count(preceding::*[local-name() = $parent-name]) + 1"/>
                <xsl:text>]</xsl:text>
                <xsl:text> in source</xsl:text>
              </xsl:with-param>
            </xsl:call-template>
            <xsl:call-template name="log.message">
              <xsl:with-param name="level">Note</xsl:with-param>
              <xsl:with-param name="source" select="$refname"/>
              <xsl:with-param name="context-desc">
                <xsl:text>endnote </xsl:text>
                <xsl:value-of select="$endnote-number"/>
              </xsl:with-param>
              <xsl:with-param name="message">
                <xsl:text>Has: </xsl:text>
                <xsl:value-of select="$parent-name"/> 
                <xsl:text>/</xsl:text>
                <xsl:value-of select="local-name(.)"/>
              </xsl:with-param>
            </xsl:call-template>
            <xsl:call-template name="log.message">
              <xsl:with-param name="level">Note</xsl:with-param>
              <xsl:with-param name="source" select="$refname"/>
              <xsl:with-param name="context-desc">
                <xsl:text>endnote </xsl:text>
                <xsl:value-of select="$endnote-number"/>
              </xsl:with-param>
              <xsl:with-param name="message">
                <xsl:text>Fix: </xsl:text>
                <xsl:value-of select="$parent-name"/> 
                <xsl:text>/</xsl:text>
                <xsl:text>para/</xsl:text>
                <xsl:value-of select="local-name(.)"/>
              </xsl:with-param>
            </xsl:call-template>
          </xsl:if>
        </xsl:for-each>
      </xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <!-- * Otherwise this is an empty link or an empty imagedata, -->
        <!-- * audiodata, or videodata element, so we just get the -->
        <!-- * value of its url, xlink:href, or fileref attribute. -->
        <xsl:if test="$man.hyphenate.urls = 0
          and $man.break.after.slash = 0">
          <!-- * Add hyphenation suppression in URL output only if -->
          <!-- * break.after.slash is also non-zero -->
          <xsl:call-template name="suppress.hyphenation"/>
          <xsl:text>\%</xsl:text>
        </xsl:if>
        <xsl:value-of select="$earmark"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:if test="self::ulink or self::*[@xlink:href]">
    <xsl:variable name="link.wrapper">
      <xsl:value-of select="normalize-space($notesource.contents)"/>
    </xsl:variable>
    <xsl:text>\m[blue]</xsl:text>
    <!-- * This is a hyperlink, so we need to determine if the user wants -->
    <!-- * font formatting applied to it, and if so, what font -->
    <xsl:choose>
      <xsl:when test="$man.font.links = 'B'">
        <xsl:call-template name="bold">
          <xsl:with-param name="node" select="exsl:node-set($link.wrapper)"/>
          <xsl:with-param name="context" select="."/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$man.font.links = 'I'">
        <xsl:call-template name="italic">
          <xsl:with-param name="node" select="exsl:node-set($link.wrapper)"/>
          <xsl:with-param name="context" select="."/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="$man.font.links = ''">
        <!-- * if man.font.links is empty, user doesn't want links -->
        <!-- * underlined, so just display content -->
        <xsl:value-of select="$notesource.contents"/>
      </xsl:when>
      <xsl:otherwise>
        <!-- * otherwise the user has specified an unsupported value for -->
        <!-- * man.font.links, so emit a warning and don't apply any font -->
        <!-- * formatting -->
        <xsl:message>
          <xsl:call-template name="log.message">
            <xsl:with-param name="level">Warn</xsl:with-param>
            <xsl:with-param name="source" select="$refname"/>
            <xsl:with-param name="context-desc">
              <xsl:text>link font</xsl:text>
            </xsl:with-param>
            <xsl:with-param name="message">
              <xsl:text>invalid $man.font.links value: </xsl:text>
              <xsl:text>'</xsl:text>
              <xsl:value-of select="$man.font.links"/>
              <xsl:text>'</xsl:text>
            </xsl:with-param>
          </xsl:call-template>
        </xsl:message>
        <xsl:value-of select="$notesource.contents"/>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text>\m[]</xsl:text>
  </xsl:if>

  <xsl:if test="$notesource.number != ''">
    <!-- * Format the number by placing it in square brackets. -->
    <!-- * Also, set the number in font-size -2, and superscripted (\u -->
    <!-- * means to move up half a line vertically) -->
    <xsl:text>\&amp;\s-2\u[</xsl:text>
    <xsl:value-of select="$notesource.number"/>
    <xsl:text>]\d\s+2</xsl:text>
    <!-- * Revert superscripting (\d means to move down half a line), and -->
    <!-- * move the font-size back to what it was before. -->
    <!-- * Note that the reason for the \& before the opening bracket -->
    <!-- * is to prevent any possible linebreak from being introduced -->
    <!-- * between the opening bracket and the following text. -->
  </xsl:if>
</xsl:template>

<!-- ==================================================================== -->

<xsl:template name="endnotes.list">
  <!-- We have stored earmark indexes for all refentry instances in the -->
  <!-- current document, with the ID for each index being the same ID as -->
  <!-- its corresponding refentry; so we now need to get the ID for the -->
  <!-- current refentry so we can grab its corresponding earmark index -->
  <xsl:variable name="current.refentry.id">
    <xsl:value-of select="generate-id(.)"/>
  </xsl:variable>

  <xsl:variable name="endnotes.rtf">
    <xsl:variable name="all.earmark.indexes.in.current.document.rtf">
      <xsl:call-template  name="get.all.earmark.indexes.in.current.document"/>
    </xsl:variable>
    <xsl:variable name="all.earmark.indexes.in.current.document"
                  select="exsl:node-set($all.earmark.indexes.in.current.document.rtf)"/>
      <xsl:copy-of
          select="$all.earmark.indexes.in.current.document/earmark.index
                  [@idref = $current.refentry.id]/earmark"/>
  </xsl:variable>

  <xsl:variable name="endnotes" select="exsl:node-set($endnotes.rtf)"/>

  <!-- * check to see if we have actually found any content to use as -->
  <!-- * endnotes; if we have, we generate the endnotes list, if not, -->
  <!-- * we do nothing -->
  <xsl:if test="$endnotes/node()">
    <xsl:call-template name="format.endnotes.list">
      <xsl:with-param name="endnotes" select="$endnotes"/>
    </xsl:call-template>
  </xsl:if>

</xsl:template>

<!-- ==================================================================== -->

<xsl:template name="format.endnotes.list">
  <xsl:param name="endnotes"/>

  <!-- * ======= make the endnotes-list section heading ============= -->
  <xsl:call-template name="make.subheading">
    <xsl:with-param name="title">
      <xsl:choose>
        <!-- * if user has specified a heading, use that -->
        <xsl:when test="$man.endnotes.list.heading != ''">
          <xsl:value-of select="$man.endnotes.list.heading"/>
        </xsl:when>
        <xsl:otherwise>
          <!-- * otherwise, get localized heading from gentext -->
          <!-- * (in English, NOTES) -->
          <xsl:call-template name="gentext">
            <xsl:with-param name="key" select="'Notes'"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:with-param>
  </xsl:call-template>

  <!-- * ================ process each earmark ====================== -->
  <xsl:for-each select="$endnotes/earmark">
    <!-- * make paragraph with hanging indent, and starting with a -->
    <!-- * number in the form " 1." (padded to $man.indent.width - 1) -->
    <xsl:text>.IP</xsl:text>
    <xsl:text> "</xsl:text>
    <xsl:variable name="endnote.number">
      <xsl:value-of select="@number"/>
      <xsl:text>.</xsl:text>
    </xsl:variable>
    <xsl:call-template name="pad-string">
      <xsl:with-param name="padVar" select="$endnote.number"/>
      <!-- FIXME: the following assumes that $man.indent.width is in -->
      <!-- en's; also, this should probably use $list.indent instead -->
      <xsl:with-param name="length" select="$man.indent.width - 1"/>
    </xsl:call-template>
    <xsl:text>"</xsl:text>
    <xsl:if test="not($list-indent = '')">
      <xsl:text> </xsl:text>
      <xsl:value-of select="$list-indent"/>
    </xsl:if>
    <xsl:text>&#10;</xsl:text>

    <!-- * ========================================================= -->
    <!-- *           print the notesource/endnote contents -->
    <!-- * ========================================================= -->
    <xsl:choose>
      <xsl:when test="*/node()">
        <!-- * if the earmark has non-empty child content, then -->
        <!-- * its corresponding notesource is either a link or -->
        <!-- * an instance of annotative text, so we want to -->
        <!-- * display that content -->
        <xsl:choose>
          <xsl:when test="*/node()[name(.)!='']">
            <!-- * if node is not text only, then process it as-is -->
            <xsl:apply-templates select="*/node()"/>
          </xsl:when>
          <xsl:otherwise>
            <!-- * otherwise node is text-only, so normalize it -->
            <xsl:value-of select="normalize-space(*/node())"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <!-- * otherwise, this earmark has empty content, -->
        <!-- * which means its corresponding notesource is an -->
        <!-- * imagedata, audiodata, or videodata instance; in -->
        <!-- * that case, we use the value of the notesource's -->
        <!-- * @fileref attribute (which is stored in the -->
        <!-- * earmark uri attribute) as the "contents" for -->
        <!-- * this endnote/notesource -->
        <xsl:call-template name="display.uri">
          <xsl:with-param name="uri" select="@uri"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text>&#10;</xsl:text>

    <!-- * ========================================================= -->
    <!-- *           print the URL for links -->
    <!-- * ========================================================= -->
    <!-- * In addition to the notesource contents, if the -->
    <!-- * notesource is a link, we display the URL for the link. -->
    <!-- * But for notesources that are imagedata, audiodata, or -->
    <!-- * videodata instances, we don't want to (re)display the -->
    <!-- * URL for those here, because for those elements, the -->
    <!-- * notesource contents are the URL (the value of the -->
    <!-- * @fileref attribute), and we have already rendered them. -->
    <!-- * -->
    <!-- * We know an earmark is a link if it has non-empty child -->
    <!-- * content and a uri attribute; so we check for that -->
    <!-- * condition here. -->
    <xsl:if test="*/node() and @uri">
      <xsl:text>.RS</xsl:text>
      <xsl:if test="not($list-indent = '')">
        <xsl:text> </xsl:text>
        <xsl:value-of select="$list-indent"/>
      </xsl:if>
      <xsl:text>&#10;</xsl:text>
      <!-- * Add hyphenation suppression in URL output only if -->
      <!-- * $break.after.slash is also non-zero -->
      <xsl:if test="$man.hyphenate.urls = 0
                    and $man.break.after.slash = 0">
        <xsl:call-template name="suppress.hyphenation"/>
        <xsl:text>\%</xsl:text>
      </xsl:if>
      <xsl:call-template name="display.uri">
        <xsl:with-param name="uri" select="@uri"/>
      </xsl:call-template>
      <xsl:text>&#10;</xsl:text>
      <xsl:text>.RE</xsl:text>
      <xsl:text>&#10;</xsl:text>
    </xsl:if>

  </xsl:for-each>
</xsl:template>

<xsl:template name="display.uri">
  <xsl:param name="uri"/>
  <xsl:choose>
    <xsl:when test="contains($uri, ':')">
      <!-- * if this URI contains a colon character, it’s probably -->
      <!-- * an absolute URI with a scheme, so we output it as-is -->
      <xsl:value-of select="$uri"/>
    </xsl:when>
    <xsl:otherwise>
      <!-- * otherwise this is probably not an absolute URI, so we -->
      <!-- * need to prepend $man.base.url.for.relative.links to -->
      <!-- * give the URI some "context" in man-page output -->
      <xsl:value-of
        select="concat($man.base.url.for.relative.links, $uri)"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>