]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/manpages/endnotes.xsl
Capitalized the start of a sentence in the bucket section of cataloging.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / manpages / endnotes.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:exsl="http://exslt.org/common"
4                 xmlns:ng="http://docbook.org/docbook-ng"
5                 xmlns:db="http://docbook.org/ns/docbook"
6                 xmlns:xlink="http://www.w3.org/1999/xlink"
7                 exclude-result-prefixes="db ng exsl xlink"
8                 version='1.0'>
9
10 <!-- ********************************************************************
11      $Id: endnotes.xsl 8490 2009-07-18 17:48:06Z mzjn $
12      ********************************************************************
13
14      This file is part of the XSL DocBook Stylesheet distribution.
15      See ../README or http://docbook.sf.net/release/xsl/current/ for
16      copyright and other information.
17
18      ******************************************************************** -->
19
20 <!-- ==================================================================== -->
21 <!-- * -->
22 <!-- * The templates in this file handle elements whose contents can't -->
23 <!-- * be displayed completely within the main text flow in output, but -->
24 <!-- * instead need to be displayed "out of line". Those elements are: -->
25 <!-- * -->
26 <!-- *   - elements providing annotative text (annotation|alt|footnote) -->
27 <!-- *   - elements pointing at external resources (ulink, link, and -->
28 <!-- *     any elements with xlink:href attributes; and imagedata, -->
29 <!-- *     audiodata, and videodata - which (using their fileref -->
30 <!-- *     attribute) reference external files -->
31 <!-- * -->
32 <!-- * Within this stylesheet, the above are collectively referred to as -->
33 <!-- * a "notesources". This stylesheet handles those notesources in -->
34 <!-- * this way: -->
35 <!-- * -->
36 <!-- * 1. Constructs a numbered in-memory index of all unique "earmarks“ -->
37 <!-- *    of all notesources in the document. For each link, the -->
38 <!-- *    earmark is the value of its url or xlink:href attribute; for -->
39 <!-- *    each imagedata|audiodata|videodata: the value of its fileref -->
40 <!-- *    attribute; for each annotative element: its content. -->
41 <!-- * -->
42 <!-- *    Notesources with the same earmark are assigned the same -->
43 <!-- *    number. -->
44 <!-- * -->
45 <!-- *    By design, that index excludes any element whose string value -->
46 <!-- *    is identical to the value of its url xlink:href attribute). -->
47 <!-- * -->
48 <!-- * 2. Puts a numbered marker inline to mark the place where the -->
49 <!-- *    notesource occurs in the main text flow. -->
50 <!-- * -->
51 <!-- * 3. Generates a numbered endnotes list (titled NOTES in English) -->
52 <!-- *    at the end of the man page, with the contents of each -->
53 <!-- *    notesource. -->
54 <!-- * -->
55 <!-- * Note that table footnotes are not listed in the endnotes list, -->
56 <!-- * and are not handled by this stylesheet (they are instead handled -->
57 <!-- * by the table.xsl stylesheet). -->
58 <!-- * -->
59 <!-- * Also, we don't get notesources in *info sections or Refmeta or -->
60 <!-- * Refnamediv or Indexterm, because, in manpages output, contents of -->
61 <!-- * those are either suppressed or are displayed out of document -->
62 <!-- * order - for example, the Info/Author content gets moved to the -->
63 <!-- * end of the page. So, if we were to number notesources in the -->
64 <!-- * Author content, it would "throw off" the numbering at the -->
65 <!-- * beginning of the main text flow. -->
66 <!-- * -->
67 <!-- * And for the record, one reason we don't use xsl:key to index the -->
68 <!-- * earmarks is that we need to get and check the sets of -->
69 <!-- * earmarks for uniqueness per-Refentry (not per-document). -->
70 <!-- * -->
71 <!-- * FIXME: -->
72 <!-- * as with "repeat" URLS, alt instances that have the same string value -->
73 <!-- * as preceding ones (likely to occur for repeat acroynyms and -->
74 <!-- * abbreviations) should be listed only once in the endnotes list, -->
75 <!-- * and numbered accordingly inline; split man.indent.width into -->
76 <!-- * man.indent.width.value (default 4) and man.indent.width.units -->
77 <!-- * (default n); also, if the first child of notesource is some block -->
78 <!-- * content other than a (non-formal) paragraph, the current code -->
79 <!-- * will probably end up generating a blank line after the -->
80 <!-- * corresponding number in the endnotes list... we should probably -->
81 <!-- * try to instead display the title of that block content there (if -->
82 <!-- * there is one: e.g., the list title, admonition title, etc.) -->
83
84 <!-- ==================================================================== -->
85
86 <xsl:template name="get.all.earmark.indexes.in.current.document">
87   <!-- * Here we create a tree to hold indexes of all earmarks in -->
88   <!-- * the current document. If the current document contains -->
89   <!-- * multiple refentry instances, then this tree will contain -->
90   <!-- * multiple indexes. -->
91   <xsl:if test="$man.endnotes.are.numbered != 0">
92     <!-- * Only create earmark indexes if user wants numbered endnotes -->
93     <xsl:for-each select="//refentry">
94       <earmark.index>
95         <xsl:attribute name="idref">
96           <xsl:value-of select="generate-id()"/>
97         </xsl:attribute>
98         <xsl:for-each
99             select=".//*[self::*[@xlink:href]
100                     or self::ulink
101                     or self::imagedata
102                     or self::audiodata
103                     or self::videodata
104                     or self::footnote[not(ancestor::table)]
105                     or self::annotation
106                     or self::alt]
107                     [(node()
108                       or self::imagedata
109                       or self::audiodata
110                       or self::videodata
111                       )
112                     and not(ancestor::refentryinfo)
113                     and not(ancestor::info)
114                     and not(ancestor::docinfo)
115                     and not(ancestor::refmeta)
116                     and not(ancestor::refnamediv)
117                     and not(ancestor::indexterm)
118                     and not(. = @url)
119                     and not(. = @xlink:href)
120                     and not(@url =
121                     preceding::ulink[node()
122                     and not(ancestor::refentryinfo)
123                     and not(ancestor::info)
124                     and not(ancestor::docinfo)
125                     and not(ancestor::refmeta)
126                     and not(ancestor::refnamediv)
127                     and not(ancestor::indexterm)
128                     and (generate-id(ancestor::refentry)
129                     = generate-id(current()))]/@url)
130                     and not(@xlink:href =
131                     preceding::*[@xlink:href][node()
132                     and not(ancestor::refentryinfo)
133                     and not(ancestor::info)
134                     and not(ancestor::docinfo)
135                     and not(ancestor::refmeta)
136                     and not(ancestor::refnamediv)
137                     and not(ancestor::indexterm)
138                     and (generate-id(ancestor::refentry)
139                     = generate-id(current()))]/@xlink:href)
140                     and not(@fileref =
141                     preceding::*[@fileref][
142                     not(ancestor::refentryinfo)
143                     and not(ancestor::info)
144                     and not(ancestor::docinfo)
145                     and not(ancestor::refmeta)
146                     and not(ancestor::refnamediv)
147                     and not(ancestor::indexterm)
148                     and (generate-id(ancestor::refentry)
149                     = generate-id(current()))]/@fileref)]">
150           <earmark>
151             <xsl:attribute name="id">
152               <xsl:value-of select="generate-id()"/>
153             </xsl:attribute>
154             <xsl:attribute name="number">
155               <xsl:value-of select="position()"/>
156             </xsl:attribute>
157             <xsl:if test="@url|@xlink:href|@fileref">
158               <!-- * Only add a uri attribute if the notesource is -->
159               <!-- * a link or an element that references an external -->
160               <!-- * (an imagedata, audiodata, or videodata element) -->
161               <xsl:attribute name="uri">
162                 <xsl:value-of select="@url|@xlink:href|@fileref"/>
163               </xsl:attribute>
164             </xsl:if>
165             <xsl:copy>
166               <xsl:copy-of select="node()"/>
167             </xsl:copy>
168           </earmark>
169         </xsl:for-each>
170       </earmark.index>
171     </xsl:for-each>
172   </xsl:if>
173 </xsl:template>
174
175 <!-- ==================================================================== -->
176
177 <xsl:template match="*[@xlink:href]|ulink
178   |imagedata|audiodata|videodata
179   |footnote[not(ancestor::table)]
180   |annotation|alt">
181   <xsl:variable name="refname" select="ancestor::refentry/refnamediv[1]/refname[1]"/>
182   <xsl:variable name="all.earmark.indexes.in.current.document.rtf">
183     <xsl:call-template name="get.all.earmark.indexes.in.current.document"/>
184   </xsl:variable>
185   <xsl:variable name="all.earmark.indexes.in.current.document"
186                 select="exsl:node-set($all.earmark.indexes.in.current.document.rtf)"/>
187   <xsl:variable name="all.earmarks.in.current.refentry.rtf">
188     <!-- * get the set of all earmarks for the ancestor Refentry of -->
189     <!-- * this notesource -->
190     <xsl:copy-of
191         select="$all.earmark.indexes.in.current.document/earmark.index
192                 [@idref =
193                 generate-id(current()/ancestor::refentry)]/earmark"/>
194   </xsl:variable>
195   <xsl:variable name="all.earmarks.in.current.refentry"
196                 select="exsl:node-set($all.earmarks.in.current.refentry.rtf)"/>
197
198   <!-- * identify the earmark for the current element -->
199   <xsl:variable name="earmark">
200     <xsl:choose>
201       <xsl:when test="@url|@xlink:href">
202         <xsl:value-of select="@url|@xlink:href"/>
203       </xsl:when>
204       <xsl:when test="@fileref">
205         <xsl:value-of select="@fileref"/>
206       </xsl:when>
207       <xsl:otherwise>
208         <xsl:value-of select="generate-id()"/>
209       </xsl:otherwise>
210     </xsl:choose>
211   </xsl:variable>
212
213   <xsl:variable name="notesource.number">
214     <!-- * Get the number for this notesource -->
215     <!-- * -->
216     <!-- * If this is an imagedata, audiodata, or videodata element -->
217     <!-- * OR if it's a non-empty element AND its string value is not -->
218     <!-- * equal to the value of its url or xlink:href attribute (if -->
219     <!-- * it has one) AND user wants endnotes numbered, only then -->
220     <!-- * do we output a number for it -->
221     <xsl:if test="(self::imagedata or
222       self::audiodata or
223       self::videodata or
224       (node()
225       and not(. = @url)
226       and not(. = @xlink:href))
227       )
228       and $man.endnotes.are.numbered != 0">
229       <!-- * To select the number for this notesource, we -->
230       <!-- * check the index of all earmarks for the current refentry -->
231       <!-- * and find the number of the indexed earmark which matches -->
232       <!-- * this notesource's earmark. -->
233       <!-- * Note that multiple notesources may share the same -->
234       <!-- * numbered earmark; in that case, they get the same number. -->
235       <!-- * -->
236       <xsl:choose>
237         <xsl:when test="self::ulink or
238           self::*[@xlink:href] or
239           self::imagedata or
240           self::audiodata or
241           self::videodata">
242           <xsl:value-of select="$all.earmarks.in.current.refentry/earmark[@uri = $earmark]/@number"/>
243         </xsl:when>
244         <xsl:otherwise>
245           <xsl:value-of select="$all.earmarks.in.current.refentry/earmark[@id  = $earmark]/@number"/>
246         </xsl:otherwise>
247       </xsl:choose>
248     </xsl:if>
249   </xsl:variable>
250
251   <xsl:variable name="notesource.contents">
252     <xsl:choose>
253       <!-- * check to see if the element is empty or not -->
254       <xsl:when test="node()">
255         <!-- * this is a non-empty node, so process its contents -->
256         <xsl:apply-templates/>
257         <xsl:if test="../footnote or ../annotation">
258           <!-- * if this element is a footnote or annotation, we need to -->
259           <!-- * do some further checking on it, so we can emit warnings -->
260           <!-- * about potential problems -->
261         <xsl:for-each select="node()">
262           <xsl:if test="local-name() != 'para' and local-name() !=''">
263             <!-- * for each node we find as a child of a footnote or -->
264             <!-- * annotation, if it's not a para or a text node, emit a -->
265             <!-- * warning... because in manpages output, we can't render -->
266             <!-- * block-level child content of an endnote properly unless -->
267             <!-- * it's wrapped in a para that has some "prefatory" text -->
268             <xsl:variable name="parent-name" select="local-name(..)"/>
269             <xsl:variable name="endnote-number">
270               <xsl:call-template name="pad-string">
271                 <!-- * endnote number may be 2 digits, so pad it with a space -->
272                 <!-- * if we have only 1 digit -->
273                 <xsl:with-param name="padVar" select="concat('#',$notesource.number)"/>
274                 <xsl:with-param name="length" select="3"/>
275               </xsl:call-template>
276             </xsl:variable>
277             <xsl:call-template name="log.message">
278               <xsl:with-param name="level">Warn</xsl:with-param>
279               <xsl:with-param name="source" select="$refname"/>
280               <xsl:with-param name="context-desc">
281                 <xsl:text>endnote </xsl:text>
282                 <xsl:value-of select="$endnote-number"/>
283               </xsl:with-param>
284               <xsl:with-param name="message">
285                 <xsl:text>Bad: </xsl:text>
286                 <xsl:value-of select="$parent-name"/> 
287                 <!-- * figure out which occurance of this element type this -->
288                 <!-- * instance is and output a number in square brackets so -->
289                 <!-- * that end-user can know which element to fix -->
290                 <xsl:text>[</xsl:text>
291                 <xsl:value-of select="count(preceding::*[local-name() = $parent-name]) + 1"/>
292                 <xsl:text>]</xsl:text>
293                 <xsl:text> in source</xsl:text>
294               </xsl:with-param>
295             </xsl:call-template>
296             <xsl:call-template name="log.message">
297               <xsl:with-param name="level">Note</xsl:with-param>
298               <xsl:with-param name="source" select="$refname"/>
299               <xsl:with-param name="context-desc">
300                 <xsl:text>endnote </xsl:text>
301                 <xsl:value-of select="$endnote-number"/>
302               </xsl:with-param>
303               <xsl:with-param name="message">
304                 <xsl:text>Has: </xsl:text>
305                 <xsl:value-of select="$parent-name"/> 
306                 <xsl:text>/</xsl:text>
307                 <xsl:value-of select="local-name(.)"/>
308               </xsl:with-param>
309             </xsl:call-template>
310             <xsl:call-template name="log.message">
311               <xsl:with-param name="level">Note</xsl:with-param>
312               <xsl:with-param name="source" select="$refname"/>
313               <xsl:with-param name="context-desc">
314                 <xsl:text>endnote </xsl:text>
315                 <xsl:value-of select="$endnote-number"/>
316               </xsl:with-param>
317               <xsl:with-param name="message">
318                 <xsl:text>Fix: </xsl:text>
319                 <xsl:value-of select="$parent-name"/> 
320                 <xsl:text>/</xsl:text>
321                 <xsl:text>para/</xsl:text>
322                 <xsl:value-of select="local-name(.)"/>
323               </xsl:with-param>
324             </xsl:call-template>
325           </xsl:if>
326         </xsl:for-each>
327       </xsl:if>
328       </xsl:when>
329       <xsl:otherwise>
330         <!-- * Otherwise this is an empty link or an empty imagedata, -->
331         <!-- * audiodata, or videodata element, so we just get the -->
332         <!-- * value of its url, xlink:href, or fileref attribute. -->
333         <xsl:if test="$man.hyphenate.urls = 0
334           and $man.break.after.slash = 0">
335           <!-- * Add hyphenation suppression in URL output only if -->
336           <!-- * break.after.slash is also non-zero -->
337           <xsl:call-template name="suppress.hyphenation"/>
338           <xsl:text>\%</xsl:text>
339         </xsl:if>
340         <xsl:value-of select="$earmark"/>
341       </xsl:otherwise>
342     </xsl:choose>
343   </xsl:variable>
344
345   <xsl:if test="self::ulink or self::*[@xlink:href]">
346     <xsl:variable name="link.wrapper">
347       <xsl:value-of select="normalize-space($notesource.contents)"/>
348     </xsl:variable>
349     <xsl:text>\m[blue]</xsl:text>
350     <!-- * This is a hyperlink, so we need to determine if the user wants -->
351     <!-- * font formatting applied to it, and if so, what font -->
352     <xsl:choose>
353       <xsl:when test="$man.font.links = 'B'">
354         <xsl:call-template name="bold">
355           <xsl:with-param name="node" select="exsl:node-set($link.wrapper)"/>
356           <xsl:with-param name="context" select="."/>
357         </xsl:call-template>
358       </xsl:when>
359       <xsl:when test="$man.font.links = 'I'">
360         <xsl:call-template name="italic">
361           <xsl:with-param name="node" select="exsl:node-set($link.wrapper)"/>
362           <xsl:with-param name="context" select="."/>
363         </xsl:call-template>
364       </xsl:when>
365       <xsl:when test="$man.font.links = ''">
366         <!-- * if man.font.links is empty, user doesn't want links -->
367         <!-- * underlined, so just display content -->
368         <xsl:value-of select="$notesource.contents"/>
369       </xsl:when>
370       <xsl:otherwise>
371         <!-- * otherwise the user has specified an unsupported value for -->
372         <!-- * man.font.links, so emit a warning and don't apply any font -->
373         <!-- * formatting -->
374         <xsl:message>
375           <xsl:call-template name="log.message">
376             <xsl:with-param name="level">Warn</xsl:with-param>
377             <xsl:with-param name="source" select="$refname"/>
378             <xsl:with-param name="context-desc">
379               <xsl:text>link font</xsl:text>
380             </xsl:with-param>
381             <xsl:with-param name="message">
382               <xsl:text>invalid $man.font.links value: </xsl:text>
383               <xsl:text>'</xsl:text>
384               <xsl:value-of select="$man.font.links"/>
385               <xsl:text>'</xsl:text>
386             </xsl:with-param>
387           </xsl:call-template>
388         </xsl:message>
389         <xsl:value-of select="$notesource.contents"/>
390       </xsl:otherwise>
391     </xsl:choose>
392     <xsl:text>\m[]</xsl:text>
393   </xsl:if>
394
395   <xsl:if test="$notesource.number != ''">
396     <!-- * Format the number by placing it in square brackets. -->
397     <!-- * Also, set the number in font-size -2, and superscripted (\u -->
398     <!-- * means to move up half a line vertically) -->
399     <xsl:text>\&amp;\s-2\u[</xsl:text>
400     <xsl:value-of select="$notesource.number"/>
401     <xsl:text>]\d\s+2</xsl:text>
402     <!-- * Revert superscripting (\d means to move down half a line), and -->
403     <!-- * move the font-size back to what it was before. -->
404     <!-- * Note that the reason for the \& before the opening bracket -->
405     <!-- * is to prevent any possible linebreak from being introduced -->
406     <!-- * between the opening bracket and the following text. -->
407   </xsl:if>
408 </xsl:template>
409
410 <!-- ==================================================================== -->
411
412 <xsl:template name="endnotes.list">
413   <!-- We have stored earmark indexes for all refentry instances in the -->
414   <!-- current document, with the ID for each index being the same ID as -->
415   <!-- its corresponding refentry; so we now need to get the ID for the -->
416   <!-- current refentry so we can grab its corresponding earmark index -->
417   <xsl:variable name="current.refentry.id">
418     <xsl:value-of select="generate-id(.)"/>
419   </xsl:variable>
420
421   <xsl:variable name="endnotes.rtf">
422     <xsl:variable name="all.earmark.indexes.in.current.document.rtf">
423       <xsl:call-template  name="get.all.earmark.indexes.in.current.document"/>
424     </xsl:variable>
425     <xsl:variable name="all.earmark.indexes.in.current.document"
426                   select="exsl:node-set($all.earmark.indexes.in.current.document.rtf)"/>
427       <xsl:copy-of
428           select="$all.earmark.indexes.in.current.document/earmark.index
429                   [@idref = $current.refentry.id]/earmark"/>
430   </xsl:variable>
431
432   <xsl:variable name="endnotes" select="exsl:node-set($endnotes.rtf)"/>
433
434   <!-- * check to see if we have actually found any content to use as -->
435   <!-- * endnotes; if we have, we generate the endnotes list, if not, -->
436   <!-- * we do nothing -->
437   <xsl:if test="$endnotes/node()">
438     <xsl:call-template name="format.endnotes.list">
439       <xsl:with-param name="endnotes" select="$endnotes"/>
440     </xsl:call-template>
441   </xsl:if>
442
443 </xsl:template>
444
445 <!-- ==================================================================== -->
446
447 <xsl:template name="format.endnotes.list">
448   <xsl:param name="endnotes"/>
449
450   <!-- * ======= make the endnotes-list section heading ============= -->
451   <xsl:call-template name="make.subheading">
452     <xsl:with-param name="title">
453       <xsl:choose>
454         <!-- * if user has specified a heading, use that -->
455         <xsl:when test="$man.endnotes.list.heading != ''">
456           <xsl:value-of select="$man.endnotes.list.heading"/>
457         </xsl:when>
458         <xsl:otherwise>
459           <!-- * otherwise, get localized heading from gentext -->
460           <!-- * (in English, NOTES) -->
461           <xsl:call-template name="gentext">
462             <xsl:with-param name="key" select="'Notes'"/>
463           </xsl:call-template>
464         </xsl:otherwise>
465       </xsl:choose>
466     </xsl:with-param>
467   </xsl:call-template>
468
469   <!-- * ================ process each earmark ====================== -->
470   <xsl:for-each select="$endnotes/earmark">
471     <!-- * make paragraph with hanging indent, and starting with a -->
472     <!-- * number in the form " 1." (padded to $man.indent.width - 1) -->
473     <xsl:text>.IP</xsl:text>
474     <xsl:text> "</xsl:text>
475     <xsl:variable name="endnote.number">
476       <xsl:value-of select="@number"/>
477       <xsl:text>.</xsl:text>
478     </xsl:variable>
479     <xsl:call-template name="pad-string">
480       <xsl:with-param name="padVar" select="$endnote.number"/>
481       <!-- FIXME: the following assumes that $man.indent.width is in -->
482       <!-- en's; also, this should probably use $list.indent instead -->
483       <xsl:with-param name="length" select="$man.indent.width - 1"/>
484     </xsl:call-template>
485     <xsl:text>"</xsl:text>
486     <xsl:if test="not($list-indent = '')">
487       <xsl:text> </xsl:text>
488       <xsl:value-of select="$list-indent"/>
489     </xsl:if>
490     <xsl:text>&#10;</xsl:text>
491
492     <!-- * ========================================================= -->
493     <!-- *           print the notesource/endnote contents -->
494     <!-- * ========================================================= -->
495     <xsl:choose>
496       <xsl:when test="*/node()">
497         <!-- * if the earmark has non-empty child content, then -->
498         <!-- * its corresponding notesource is either a link or -->
499         <!-- * an instance of annotative text, so we want to -->
500         <!-- * display that content -->
501         <xsl:choose>
502           <xsl:when test="*/node()[name(.)!='']">
503             <!-- * if node is not text only, then process it as-is -->
504             <xsl:apply-templates select="*/node()"/>
505           </xsl:when>
506           <xsl:otherwise>
507             <!-- * otherwise node is text-only, so normalize it -->
508             <xsl:value-of select="normalize-space(*/node())"/>
509           </xsl:otherwise>
510         </xsl:choose>
511       </xsl:when>
512       <xsl:otherwise>
513         <!-- * otherwise, this earmark has empty content, -->
514         <!-- * which means its corresponding notesource is an -->
515         <!-- * imagedata, audiodata, or videodata instance; in -->
516         <!-- * that case, we use the value of the notesource's -->
517         <!-- * @fileref attribute (which is stored in the -->
518         <!-- * earmark uri attribute) as the "contents" for -->
519         <!-- * this endnote/notesource -->
520         <xsl:call-template name="display.uri">
521           <xsl:with-param name="uri" select="@uri"/>
522         </xsl:call-template>
523       </xsl:otherwise>
524     </xsl:choose>
525     <xsl:text>&#10;</xsl:text>
526
527     <!-- * ========================================================= -->
528     <!-- *           print the URL for links -->
529     <!-- * ========================================================= -->
530     <!-- * In addition to the notesource contents, if the -->
531     <!-- * notesource is a link, we display the URL for the link. -->
532     <!-- * But for notesources that are imagedata, audiodata, or -->
533     <!-- * videodata instances, we don't want to (re)display the -->
534     <!-- * URL for those here, because for those elements, the -->
535     <!-- * notesource contents are the URL (the value of the -->
536     <!-- * @fileref attribute), and we have already rendered them. -->
537     <!-- * -->
538     <!-- * We know an earmark is a link if it has non-empty child -->
539     <!-- * content and a uri attribute; so we check for that -->
540     <!-- * condition here. -->
541     <xsl:if test="*/node() and @uri">
542       <xsl:text>.RS</xsl:text>
543       <xsl:if test="not($list-indent = '')">
544         <xsl:text> </xsl:text>
545         <xsl:value-of select="$list-indent"/>
546       </xsl:if>
547       <xsl:text>&#10;</xsl:text>
548       <!-- * Add hyphenation suppression in URL output only if -->
549       <!-- * $break.after.slash is also non-zero -->
550       <xsl:if test="$man.hyphenate.urls = 0
551                     and $man.break.after.slash = 0">
552         <xsl:call-template name="suppress.hyphenation"/>
553         <xsl:text>\%</xsl:text>
554       </xsl:if>
555       <xsl:call-template name="display.uri">
556         <xsl:with-param name="uri" select="@uri"/>
557       </xsl:call-template>
558       <xsl:text>&#10;</xsl:text>
559       <xsl:text>.RE</xsl:text>
560       <xsl:text>&#10;</xsl:text>
561     </xsl:if>
562
563   </xsl:for-each>
564 </xsl:template>
565
566 <xsl:template name="display.uri">
567   <xsl:param name="uri"/>
568   <xsl:choose>
569     <xsl:when test="contains($uri, ':')">
570       <!-- * if this URI contains a colon character, it’s probably -->
571       <!-- * an absolute URI with a scheme, so we output it as-is -->
572       <xsl:value-of select="$uri"/>
573     </xsl:when>
574     <xsl:otherwise>
575       <!-- * otherwise this is probably not an absolute URI, so we -->
576       <!-- * need to prepend $man.base.url.for.relative.links to -->
577       <!-- * give the URI some "context" in man-page output -->
578       <xsl:value-of
579         select="concat($man.base.url.for.relative.links, $uri)"/>
580     </xsl:otherwise>
581   </xsl:choose>
582 </xsl:template>
583
584 </xsl:stylesheet>