Source

SCons / src / engine / SCons / Tool / docbook / docbook-xsl-1.76.1 / manpages / lists.xsl

Full commit
dirkbaechle 5ba470f 


























































































































































































































































































































































































































































































































































































































  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
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version='1.0'>

<!-- ********************************************************************
     $Id: lists.xsl 8530 2009-11-02 02:38:47Z dleidert $
     ********************************************************************

     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.

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

<xsl:variable name="list-indent">
  <xsl:choose>
    <xsl:when test="not($man.indent.lists = 0)">
      <xsl:value-of select="$man.indent.width"/>
    </xsl:when>
    <xsl:when test="not($man.indent.refsect = 0)">
      <!-- * "zq" is the name of a register we set for -->
      <!-- * preserving the original default indent value -->
      <!-- * when $man.indent.refsect is non-zero; -->
      <!-- * "u" is a roff unit specifier -->
      <xsl:text>\n(zqu</xsl:text>
    </xsl:when>
    <xsl:otherwise/> <!-- * otherwise, just leave it empty -->
  </xsl:choose>
</xsl:variable>

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

<xsl:template match="para[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  simpara[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  remark[ancestor::listitem or ancestor::step or ancestor::glossdef]">
  <xsl:call-template name="mixed-block"/>
  <xsl:text>&#10;</xsl:text>
  <xsl:if test="following-sibling::*[1][
    self::para or
    self::simpara or
    self::remark
    ]">
    <!-- * Make sure multiple paragraphs within a list item don't -->
    <!-- * merge together.                                        -->
    <xsl:text>.sp&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="bibliolist">
  <xsl:apply-templates/>
  <xsl:text>&#10;</xsl:text>
</xsl:template>

<xsl:template match="variablelist|glosslist">
  <xsl:if test="title">
    <xsl:text>.PP&#10;</xsl:text>
    <xsl:call-template name="bold">
      <xsl:with-param name="node" select="title"/>
      <xsl:with-param name="context" select="."/>
    </xsl:call-template>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="varlistentry|glossentry">
  <xsl:text>.PP&#10;</xsl:text> 
  <xsl:for-each select="term|glossterm">
    <xsl:variable name="content">
      <xsl:apply-templates/>
    </xsl:variable>
    <xsl:value-of select="normalize-space($content)"/>
    <xsl:choose>
      <xsl:when test="position() = last()"/> <!-- do nothing -->
      <xsl:otherwise>
        <!-- * if we have multiple terms in the same varlistentry, generate -->
        <!-- * a separator (", " by default) and/or an additional line -->
        <!-- * break after each one except the last -->
        <!-- * -->
        <!-- * note that it is not valid to have multiple glossterms -->
        <!-- * within a glossentry, so this logic never gets exercised -->
        <!-- * for glossterms (every glossterm is always the last in -->
        <!-- * its parent glossentry) -->
        <xsl:value-of select="$variablelist.term.separator"/>
        <xsl:if test="not($variablelist.term.break.after = '0')">
          <xsl:text>&#10;</xsl:text>
          <xsl:text>.br&#10;</xsl:text>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
  <xsl:text>&#10;</xsl:text>
  <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>
  <xsl:apply-templates/>
  <xsl:text>.RE&#10;</xsl:text>
</xsl:template>

<xsl:template match="varlistentry/term"/>
<xsl:template match="glossentry/glossterm"/>

<xsl:template match="variablelist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  glosslist[ancestor::listitem or ancestor::step or ancestor::glossdef]">
  <xsl:apply-templates/>
  <xsl:if test="following-sibling::node() or
    parent::para[following-sibling::node()] or
    parent::simpara[following-sibling::node()] or
    parent::remark[following-sibling::node()]">
    <xsl:text>.sp</xsl:text> 
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="varlistentry/listitem|glossentry/glossdef">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="itemizedlist/listitem">
  <!-- * We output a real bullet here (rather than, "\(bu", -->
  <!-- * the roff bullet) because, when we do character-map -->
  <!-- * processing before final output, the character-map will -->
  <!-- * handle conversion of the &#x2022; to "\(bu" for us -->
  <xsl:text>&#10;</xsl:text>
  <xsl:text>.sp</xsl:text>
  <xsl:text>&#10;</xsl:text>
  <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>
  <!-- * if "n" then we are using "nroff", which means the output is for -->
  <!-- * TTY; so we do some fixed-width-font hackery with \h to make a -->
  <!-- * hanging indent (instead of using .IP, which has some -->
  <!-- * undesirable side effects under certain circumstances) -->
  <xsl:call-template name="roff-if-else-start"/>
  <xsl:text>\h'-</xsl:text>
  <xsl:choose>
    <xsl:when test="not($list-indent = '')">
      <xsl:text>0</xsl:text>
      <xsl:value-of select="$list-indent"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>\n(INu</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>'</xsl:text>
  <xsl:text>&#x2022;</xsl:text>
  <xsl:text>\h'+</xsl:text>
  <xsl:choose>
    <xsl:when test="not($list-indent = '')">
      <xsl:text>0</xsl:text>
      <xsl:value-of select="$list-indent - 1"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>\n(INu-1</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>'\c&#10;</xsl:text>
  <!-- * else, we are not using for "nroff", but instead "troff" - which -->
  <!-- * means not for TTY, but for PS or whatever; so we’re not using a -->
  <!-- * fixed-width font, so use a real .IP instead -->
  <xsl:call-template name="roff-else"/>
  <!-- * .IP generates a blank like of space, so let’s go backwards one -->
  <!-- * line up to compensate for that -->
  <xsl:text>.sp -1&#10;</xsl:text>
  <xsl:text>.IP \(bu 2.3&#10;</xsl:text>
  <!-- * The value 2.3 is the amount of indentation; we use 2.3 instead -->
  <!-- * of 2 because when the font family is New Century Schoolbook it -->
  <!-- * seems to require the extra space. -->
  <xsl:call-template name="roff-if-end"/>
  <xsl:apply-templates/>
  <xsl:text>.RE&#10;</xsl:text>
</xsl:template>

<xsl:template match="orderedlist/listitem|procedure/step">
  <xsl:text>&#10;</xsl:text>
  <xsl:text>.sp</xsl:text>
  <xsl:text>&#10;</xsl:text>
  <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>
  <!-- * if "n" then we are using "nroff", which means the output is for -->
  <!-- * TTY; so we do some fixed-width-font hackery with \h to make a -->
  <!-- * hanging indents (instead of using .IP, which has some -->
  <!-- * undesirable side effects under certain circumstances) -->
  <xsl:call-template name="roff-if-else-start"/>
  <xsl:text>\h'-</xsl:text>
  <xsl:choose>
    <xsl:when test="not($list-indent = '')">
      <xsl:text>0</xsl:text>
      <xsl:value-of select="$list-indent"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>\n(INu+3n</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>'</xsl:text>
  <xsl:if test="count(preceding-sibling::listitem) &lt; 9">
    <xsl:text> </xsl:text>
  </xsl:if>
  <xsl:number format="1."/>
  <xsl:text>\h'+</xsl:text>
  <xsl:choose>
    <xsl:when test="not($list-indent = '')">
      <xsl:text>0</xsl:text>
      <xsl:value-of select="$list-indent - 3"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>1n</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>'\c&#10;</xsl:text>
  <!-- * else, we are not using for "nroff", but instead "troff" - which -->
  <!-- * means not for TTY, but for PS or whatever; so we’re not using a -->
  <!-- * fixed-width font, so use a real .IP instead -->
  <xsl:call-template name="roff-else"/>
  <!-- * .IP generates a blank line of space, so let’s go backwards one -->
  <!-- * line up to compensate for that -->
  <xsl:text>.sp -1&#10;</xsl:text>
  <xsl:text>.IP "</xsl:text>
  <xsl:if test="count(preceding-sibling::listitem) &lt; 9">
    <xsl:text>  </xsl:text>
  </xsl:if>
  <xsl:number format="1."/>
  <xsl:text>" 4.2&#10;</xsl:text>
  <!-- * The value 4.2 is the amount of indentation; we use 4.2 instead -->
  <!-- * of 4 because when the font family is Bookman it seems to require -->
  <!-- * the extra space. -->
  <xsl:call-template name="roff-if-end"/>
  <xsl:apply-templates/>
  <xsl:text>.RE&#10;</xsl:text>
  <xsl:text>&#10;</xsl:text>
</xsl:template>

<xsl:template match="itemizedlist|orderedlist|procedure">
  <xsl:if test="title">
    <xsl:text>.PP&#10;</xsl:text>
    <xsl:call-template name="bold">
      <xsl:with-param name="node" select="title"/>
      <xsl:with-param name="context" select="."/>
    </xsl:call-template>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
  <!-- * DocBook allows just about any block content to appear in -->
  <!-- * lists before the actual list items, so we need to get that -->
  <!-- * content (if any) before getting the list items -->
  <xsl:apply-templates
    select="*[not(self::listitem) and not(self::title)]"/>
  <xsl:apply-templates select="listitem"/>
  <!-- * If this list is a child of para and has content following -->
  <!-- * it, within the same para, then add a blank line and move -->
  <!-- * the left margin back to where it was -->
  <xsl:if test="parent::para and following-sibling::node()">
    <xsl:text>.sp</xsl:text>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="itemizedlist[ancestor::listitem or ancestor::step  or ancestor::glossdef]|
  orderedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
  procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]">
  <xsl:if test="title">
    <xsl:text>.PP&#10;</xsl:text>
    <xsl:call-template name="bold">
      <xsl:with-param name="node" select="title"/>
      <xsl:with-param name="context" select="."/>
    </xsl:call-template>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
  <xsl:apply-templates/>
  <xsl:if test="following-sibling::node() or
    parent::para[following-sibling::node()] or
    parent::simpara[following-sibling::node()] or
    parent::remark[following-sibling::node()]">
    <xsl:text>.sp</xsl:text> 
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<!-- ================================================================== -->
  
<!-- * for simplelist type="inline", render it as a comma-separated list -->
<xsl:template match="simplelist[@type='inline']">
  <!-- * if dbchoice PI exists, use that to determine the choice separator -->
  <!-- * (that is, equivalent of "and" or "or" in current locale), or literal -->
  <!-- * value of "choice" otherwise -->
  <xsl:variable name="localized-choice-separator">
    <xsl:choose>
      <xsl:when test="processing-instruction('dbchoice')">
        <xsl:call-template name="select.choice.separator"/>
      </xsl:when>
      <xsl:otherwise>
        <!-- * empty -->
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:for-each select="member">
    <xsl:apply-templates/>
    <xsl:choose>
      <xsl:when test="position() = last()"/> <!-- do nothing -->
      <xsl:otherwise>
        <xsl:text>, </xsl:text>
        <xsl:if test="position() = last() - 1">
          <xsl:if test="$localized-choice-separator != ''">
            <xsl:value-of select="$localized-choice-separator"/>
            <xsl:text> </xsl:text>
          </xsl:if>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
  <xsl:text>&#10;</xsl:text>
</xsl:template>

<!-- * if simplelist type is not inline, render it as a one-column vertical -->
<!-- * list (ignoring the values of the type and columns attributes) -->
<xsl:template match="simplelist">
  <xsl:for-each select="member">
    <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>
    <xsl:apply-templates/>
    <xsl:text>&#10;</xsl:text>
    <xsl:text>.RE&#10;</xsl:text>
  </xsl:for-each>
</xsl:template>

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

<!-- * We output Segmentedlist as a table, using tbl(1) markup. There -->
<!-- * is no option for outputting it in manpages in "list" form. -->
<xsl:template match="segmentedlist">
  <xsl:if test="title">
    <xsl:text>.PP&#10;</xsl:text>
    <xsl:call-template name="bold">
      <xsl:with-param name="node" select="title"/>
      <xsl:with-param name="context" select="."/>
    </xsl:call-template>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
  <xsl:text>.\" line length increase to cope w/ tbl weirdness&#10;</xsl:text>
  <xsl:text>.ll +(\n(LLu * 62u / 100u)&#10;</xsl:text>
  <!-- * .TS = "Table Start" -->
  <xsl:text>.TS&#10;</xsl:text>
  <!-- * first output the table "format" spec, which tells tbl(1) how -->
  <!-- * how to format each row and column. -->
  <xsl:for-each select=".//segtitle">
    <!-- * l = "left", which hard-codes left-alignment for tabular -->
    <!-- * output of all segmentedlist content -->
    <xsl:text>l</xsl:text>
  </xsl:for-each>
  <!-- * last line of table format section must end with a dot -->
  <xsl:text>.&#10;</xsl:text>
  <!-- * optionally suppress output of segtitle -->
  <xsl:choose>
    <xsl:when test="$man.segtitle.suppress != 0">
      <!-- * non-zero = "suppress", so do nothing -->
    </xsl:when>
    <xsl:otherwise>
      <!-- * "0" = "do not suppress", so output the segtitle(s) -->
      <xsl:apply-templates select=".//segtitle" mode="table-title"/>
      <xsl:text>&#10;</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:apply-templates/>
  <!-- * .TE = "Table End" -->
  <xsl:text>.TE&#10;</xsl:text>
  <xsl:text>.\" line length decrease back to previous value&#10;</xsl:text>
  <xsl:text>.ll -(\n(LLu * 62u / 100u)&#10;</xsl:text>
  <!-- * put a blank line of space below the table -->
  <xsl:text>.sp&#10;</xsl:text>
</xsl:template>

<xsl:template match="segmentedlist/segtitle" mode="table-title">
  <xsl:call-template name="italic">
    <xsl:with-param name="node" select="."/>
    <xsl:with-param name="context" select="."/>
  </xsl:call-template>
  <xsl:choose>
    <xsl:when test="position() = last()"/> <!-- do nothing -->
    <xsl:otherwise>
      <!-- * tbl(1) treats tab characters as delimiters between -->
      <!-- * cells; so we need to output a tab after each -->
      <!-- * segtitle except the last one -->
      <xsl:text>&#09;</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="segmentedlist/seglistitem">
  <xsl:apply-templates/>
  <xsl:text>&#10;</xsl:text>
</xsl:template>

<xsl:template match="segmentedlist/seglistitem/seg">
  <!-- * the T{ and T} stuff are delimiters to tell tbl(1) that -->
  <!-- * the delimited contents are "text blocks" that groff(1) -->
  <!-- * needs to process -->
  <xsl:text>T{&#10;</xsl:text>
  <xsl:variable name="contents">
    <xsl:apply-templates/>
  </xsl:variable>
  <xsl:value-of select="normalize-space($contents)"/>
  <xsl:text>&#10;T}</xsl:text>
  <xsl:choose>
    <xsl:when test="position() = last()"/> <!-- do nothing -->
    <xsl:otherwise>
      <!-- * tbl(1) treats tab characters as delimiters between -->
      <!-- * cells; so we need to output a tab after each -->
      <!-- * segtitle except the last one -->
      <xsl:text>&#09;</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

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

<xsl:template match="calloutlist">
  <xsl:if test="title|info/title">
    <xsl:call-template name="formal.object.heading"/>
  </xsl:if>
  <!-- * This template was originally copied over from the HTML -->
  <!-- * calloutlist template, which precedes the following -->
  <!-- * apply-templates with the comment "Preserve order of PIs and -->
  <!-- * comments"; I'm not certain that it will actually have that -->
  <!-- * effect for all cases, and it seems like there is probably a -->
  <!-- * better way to do it, but anyway, I’m preserving it here for -->
  <!-- * consistency. -->
  <xsl:apply-templates 
    select="*[not(self::callout or self::title or self::titleabbrev)]
    |comment()[not(preceding-sibling::callout)]
    |processing-instruction()[not(preceding-sibling::callout)]"/>
  <!-- * put callout list into a table -->
  <xsl:text>.TS&#10;</xsl:text>
  <xsl:text>tab(:);&#10;</xsl:text>
  <!-- * the following defines the row layout for the table: two columns, -->
  <!-- * with the first cell in each row right-aligned, and the second -->
  <!-- * cell left aligned with a width of 75% of the line length -->
  <xsl:text>r lw(\n(.lu*75u/100u).&#10;</xsl:text>
  <xsl:apply-templates select="callout
    |comment()[preceding-sibling::callout]
    |processing-instruction()[preceding-sibling::callout]"/>
  <xsl:text>.TE&#10;</xsl:text>
</xsl:template>

<xsl:template match="calloutlist/title"/>

<xsl:template match="callout">
  <!-- * first cell of each row is the set of callout numbers for this -->
  <!-- * particular callout -->
  <xsl:call-template name="callout.arearefs">
    <xsl:with-param name="arearefs" select="@arearefs"/>
  </xsl:call-template>
  <!-- * end of the first cell in the row; the \h hackery is to correct -->
  <!-- * for the excessive horizontal whitespace that tbl(1) adds between -->
  <!-- * cells in the same row -->
  <xsl:text>\h'-2n':</xsl:text>
  <!-- * start the next cell in the row, which has the prose contents -->
  <!-- * (description/explanation) for the callout -->
  <xsl:text>T{&#10;</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>T}&#10;</xsl:text>
  <!-- * end of the last cell and end of the row -->
</xsl:template>

<xsl:template name="callout.arearefs">
  <xsl:param name="arearefs"></xsl:param>
  <!-- * callout can have multiple values in its arearefs attribute, so -->
  <!-- * we use the position param to track the postion of each value -->
  <xsl:param name="position">1</xsl:param>
  <xsl:if test="$arearefs!=''">
    <xsl:choose>
      <xsl:when test="substring-before($arearefs,' ')=''">
        <xsl:call-template name="callout.arearef">
          <xsl:with-param name="arearef" select="$arearefs"/>
          <xsl:with-param name="position" select="$position"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="callout.arearef">
          <xsl:with-param name="arearef"
            select="substring-before($arearefs,' ')"/>
          <xsl:with-param name="position" select="$position"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:call-template name="callout.arearefs">
      <xsl:with-param name="arearefs"
        select="substring-after($arearefs,' ')"/>
      <xsl:with-param name="position" select="$position + 1"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

<xsl:template name="callout.arearef">
  <xsl:param name="arearef"></xsl:param>
  <!-- * callout can have multiple values in its arearefs attribute, so -->
  <!-- * we use the position param to track the postion of each value -->
  <xsl:param name="position"></xsl:param>
  <xsl:variable name="targets" select="key('id',$arearef)"/>
  <xsl:variable name="target" select="$targets[1]"/>

  <xsl:call-template name="check.id.unique">
    <xsl:with-param name="linkend" select="$arearef"/>
  </xsl:call-template>

  <xsl:choose>
    <xsl:when test="count($target)=0">
      <xsl:text>???</xsl:text>
    </xsl:when>
    <xsl:when test="local-name($target)='co'">
      <!-- * if this is not the first value in the set of values in the -->
      <!-- * arearef attribute for this callout, then we prepend a groff -->
      <!-- * non-breaking space to it, to prevent groff from injecting -->
      <!-- * linebreaks into the output. For callout instances with -->
      <!-- * multiple values in their arearefs attributes, that results -->
      <!-- * in all of callout numbers beings listed on the same line. -->
      <xsl:if test="not($position = 1)">
        <xsl:text>\ </xsl:text>
      </xsl:if>
      <xsl:apply-templates select="$target"
        mode="calloutlist-callout-number"/>
    </xsl:when>
    <!-- * the manpages stylesheet does not really support areaset and -->
    <!-- * area (because we can't/don't actually render the callout bugs -->
    <!-- * at the specified coordinates); however, the following (for -->
    <!-- * what it's worth) might cause the callout numbers in the -->
    <!-- * calloutlist to be render at least (then again, maybe it won't; -->
    <!-- * it's not actually been tested... -->
    <xsl:when test="local-name($target)='areaset'">
      <xsl:call-template name="callout-bug">
        <xsl:with-param name="conum">
          <xsl:apply-templates select="$target" mode="conumber"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:when>
    <xsl:when test="local-name($target)='area'">
      <xsl:choose>
        <xsl:when test="$target/parent::areaset">
          <xsl:call-template name="callout-bug">
            <xsl:with-param name="conum">
              <xsl:apply-templates
                select="$target/parent::areaset" mode="conumber"/>
            </xsl:with-param>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="callout-bug">
            <xsl:with-param name="conum">
              <xsl:apply-templates select="$target"
                mode="conumber"/>
            </xsl:with-param>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>???</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- * we bold the actual callout bugs and put -->
<!-- * parenthesis around them -->
<xsl:template name="callout-bug">
  <xsl:param name="conum" select='1'/>
  <xsl:text>\fB(</xsl:text>
  <xsl:value-of select="$conum"/>
  <xsl:text>)\fR</xsl:text>
</xsl:template>

<!-- * we bold the callout numbers and follow each -->
<!-- * with a period -->
<xsl:template name="calloutlist-callout-number">
  <xsl:param name="conum" select='1'/>
  <xsl:text>\fB</xsl:text>
  <xsl:value-of select="$conum"/>
  <xsl:text>.\fR</xsl:text>
</xsl:template>

<xsl:template match="co" mode="calloutlist-callout-number">
  <xsl:call-template name="calloutlist-callout-number">
    <xsl:with-param name="conum">
      <xsl:number count="co"
        level="any"
        from="programlisting|screen|literallayout|synopsis"
        format="1"/>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

</xsl:stylesheet>