1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                version='1.0'>
4
5<!-- ********************************************************************
6     $Id: lists.xsl,v 1.50 2006/05/04 12:28:02 nwalsh Exp $
7     ********************************************************************
8
9     This file is part of the XSL DocBook Stylesheet distribution.
10     See /README or http://nwalsh.com/docbook/xsl/ for copyright
11     and other information.
12
13     ******************************************************************** -->
14
15<!-- ==================================================================== -->
16
17<xsl:template match="itemizedlist">
18  <div class="{name(.)}">
19    <xsl:call-template name="anchor"/>
20    <xsl:if test="title">
21      <xsl:call-template name="formal.object.heading"/>
22    </xsl:if>
23
24    <!-- Preserve order of PIs and comments -->
25    <xsl:apply-templates 
26        select="*[not(self::listitem
27                  or self::title
28                  or self::titleabbrev)]
29                |comment()[not(preceding-sibling::listitem)]
30                |processing-instruction()[not(preceding-sibling::listitem)]"/>
31
32    <ul>
33      <xsl:if test="$css.decoration != 0">
34        <xsl:attribute name="type">
35          <xsl:call-template name="list.itemsymbol"/>
36        </xsl:attribute>
37      </xsl:if>
38
39      <xsl:if test="@spacing='compact'">
40        <xsl:attribute name="compact">
41          <xsl:value-of select="@spacing"/>
42        </xsl:attribute>
43      </xsl:if>
44      <xsl:apply-templates 
45            select="listitem
46                    |comment()[preceding-sibling::listitem]
47                    |processing-instruction()[preceding-sibling::listitem]"/>
48    </ul>
49  </div>
50</xsl:template>
51
52<xsl:template match="itemizedlist/title">
53  <!-- nop -->
54</xsl:template>
55
56<xsl:template match="itemizedlist/listitem">
57  <xsl:variable name="mark" select="../@mark"/>
58  <xsl:variable name="override" select="@override"/>
59
60  <xsl:variable name="usemark">
61    <xsl:choose>
62      <xsl:when test="$override != ''">
63        <xsl:value-of select="$override"/>
64      </xsl:when>
65      <xsl:otherwise>
66        <xsl:value-of select="$mark"/>
67      </xsl:otherwise>
68    </xsl:choose>
69  </xsl:variable>
70
71  <xsl:variable name="cssmark">
72    <xsl:choose>
73      <xsl:when test="$usemark = 'opencircle'">circle</xsl:when>
74      <xsl:when test="$usemark = 'bullet'">disc</xsl:when>
75      <xsl:when test="$usemark = 'box'">square</xsl:when>
76      <xsl:otherwise>
77        <xsl:value-of select="$usemark"/>
78      </xsl:otherwise>
79    </xsl:choose>
80  </xsl:variable>
81
82  <li>
83    <xsl:if test="$css.decoration = '1' and $cssmark != ''">
84      <xsl:attribute name="style">
85        <xsl:text>list-style-type: </xsl:text>
86        <xsl:value-of select="$cssmark"/>
87      </xsl:attribute>
88    </xsl:if>
89
90    <!-- we can't just drop the anchor in since some browsers (Opera)
91         get confused about line breaks if we do. So if the first child
92         is a para, assume the para will put in the anchor. Otherwise,
93         put the anchor in anyway. -->
94    <xsl:if test="local-name(child::*[1]) != 'para'">
95      <xsl:call-template name="anchor"/>
96    </xsl:if>
97
98    <xsl:choose>
99      <xsl:when test="$show.revisionflag != 0 and @revisionflag">
100        <div class="{@revisionflag}">
101          <xsl:apply-templates/>
102        </div>
103      </xsl:when>
104      <xsl:otherwise>
105        <xsl:apply-templates/>
106      </xsl:otherwise>
107    </xsl:choose>
108  </li>
109</xsl:template>
110
111<xsl:template match="orderedlist">
112  <xsl:variable name="start">
113    <xsl:call-template name="orderedlist-starting-number"/>
114  </xsl:variable>
115
116  <xsl:variable name="numeration">
117    <xsl:call-template name="list.numeration"/>
118  </xsl:variable>
119
120  <xsl:variable name="type">
121    <xsl:choose>
122      <xsl:when test="$numeration='arabic'">1</xsl:when>
123      <xsl:when test="$numeration='loweralpha'">a</xsl:when>
124      <xsl:when test="$numeration='lowerroman'">i</xsl:when>
125      <xsl:when test="$numeration='upperalpha'">A</xsl:when>
126      <xsl:when test="$numeration='upperroman'">I</xsl:when>
127      <!-- What!? This should never happen -->
128      <xsl:otherwise>
129        <xsl:message>
130          <xsl:text>Unexpected numeration: </xsl:text>
131          <xsl:value-of select="$numeration"/>
132        </xsl:message>
133        <xsl:value-of select="1"/>
134      </xsl:otherwise>
135    </xsl:choose>
136  </xsl:variable>
137
138  <div class="{name(.)}">
139    <xsl:call-template name="anchor"/>
140
141    <xsl:if test="title">
142      <xsl:call-template name="formal.object.heading"/>
143    </xsl:if>
144
145    <!-- Preserve order of PIs and comments -->
146    <xsl:apply-templates 
147        select="*[not(self::listitem
148                  or self::title
149                  or self::titleabbrev)]
150                |comment()[not(preceding-sibling::listitem)]
151                |processing-instruction()[not(preceding-sibling::listitem)]"/>
152
153    <ol>
154      <xsl:if test="$start != '1'">
155        <xsl:attribute name="start">
156          <xsl:value-of select="$start"/>
157        </xsl:attribute>
158      </xsl:if>
159      <xsl:if test="$numeration != ''">
160        <xsl:attribute name="type">
161          <xsl:value-of select="$type"/>
162        </xsl:attribute>
163      </xsl:if>
164      <xsl:if test="@spacing='compact'">
165        <xsl:attribute name="compact">
166          <xsl:value-of select="@spacing"/>
167        </xsl:attribute>
168      </xsl:if>
169      <xsl:apply-templates 
170            select="listitem
171                    |comment()[preceding-sibling::listitem]
172                    |processing-instruction()[preceding-sibling::listitem]"/>
173    </ol>
174  </div>
175</xsl:template>
176
177<xsl:template match="orderedlist/title">
178  <!-- nop -->
179</xsl:template>
180
181<xsl:template match="orderedlist/listitem">
182  <li>
183    <xsl:if test="@override">
184      <xsl:attribute name="value">
185        <xsl:value-of select="@override"/>
186      </xsl:attribute>
187    </xsl:if>
188
189    <!-- we can't just drop the anchor in since some browsers (Opera)
190         get confused about line breaks if we do. So if the first child
191         is a para, assume the para will put in the anchor. Otherwise,
192         put the anchor in anyway. -->
193    <xsl:if test="local-name(child::*[1]) != 'para'">
194      <xsl:call-template name="anchor"/>
195    </xsl:if>
196
197    <xsl:choose>
198      <xsl:when test="$show.revisionflag != 0 and @revisionflag">
199        <div class="{@revisionflag}">
200          <xsl:apply-templates/>
201        </div>
202      </xsl:when>
203      <xsl:otherwise>
204        <xsl:apply-templates/>
205      </xsl:otherwise>
206    </xsl:choose>
207  </li>
208</xsl:template>
209
210<xsl:template match="variablelist">
211  <xsl:variable name="pi-presentation">
212    <xsl:call-template name="dbhtml-attribute">
213      <xsl:with-param name="pis"
214                      select="processing-instruction('dbhtml')"/>
215      <xsl:with-param name="attribute" select="'list-presentation'"/>
216    </xsl:call-template>
217  </xsl:variable>
218
219  <xsl:variable name="presentation">
220    <xsl:choose>
221      <xsl:when test="$pi-presentation != ''">
222        <xsl:value-of select="$pi-presentation"/>
223      </xsl:when>
224      <xsl:when test="$variablelist.as.table != 0">
225        <xsl:value-of select="'table'"/>
226      </xsl:when>
227      <xsl:otherwise>
228        <xsl:value-of select="'list'"/>
229      </xsl:otherwise>
230    </xsl:choose>
231  </xsl:variable>
232
233  <xsl:variable name="list-width">
234    <xsl:call-template name="dbhtml-attribute">
235      <xsl:with-param name="pis"
236                      select="processing-instruction('dbhtml')"/>
237      <xsl:with-param name="attribute" select="'list-width'"/>
238    </xsl:call-template>
239  </xsl:variable>
240
241  <xsl:variable name="term-width">
242    <xsl:call-template name="dbhtml-attribute">
243      <xsl:with-param name="pis"
244                      select="processing-instruction('dbhtml')"/>
245      <xsl:with-param name="attribute" select="'term-width'"/>
246    </xsl:call-template>
247  </xsl:variable>
248
249  <xsl:variable name="table-summary">
250    <xsl:call-template name="dbhtml-attribute">
251      <xsl:with-param name="pis"
252                      select="processing-instruction('dbhtml')"/>
253      <xsl:with-param name="attribute" select="'table-summary'"/>
254    </xsl:call-template>
255  </xsl:variable>
256
257  <div class="{name(.)}">
258    <xsl:call-template name="anchor"/>
259    <xsl:if test="title">
260      <xsl:call-template name="formal.object.heading"/>
261    </xsl:if>
262
263    <xsl:choose>
264      <xsl:when test="$presentation = 'table'">
265        <!-- Preserve order of PIs and comments -->
266        <xsl:apply-templates 
267          select="*[not(self::varlistentry
268                    or self::title
269                    or self::titleabbrev)]
270                  |comment()[not(preceding-sibling::varlistentry)]
271                  |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
272        <table border="0">
273          <xsl:if test="$list-width != ''">
274            <xsl:attribute name="width">
275              <xsl:value-of select="$list-width"/>
276            </xsl:attribute>
277          </xsl:if>
278          <xsl:if test="$table-summary != ''">
279            <xsl:attribute name="summary">
280              <xsl:value-of select="$table-summary"/>
281            </xsl:attribute>
282          </xsl:if>
283          <col align="left" valign="top">
284            <xsl:if test="$term-width != ''">
285              <xsl:attribute name="width">
286                <xsl:value-of select="$term-width"/>
287              </xsl:attribute>
288            </xsl:if>
289          </col>
290          <tbody>
291            <xsl:apply-templates mode="varlist-table"
292              select="varlistentry
293                      |comment()[preceding-sibling::varlistentry]
294                      |processing-instruction()[preceding-sibling::varlistentry]"/>
295          </tbody>
296        </table>
297      </xsl:when>
298      <xsl:otherwise>
299        <!-- Preserve order of PIs and comments -->
300        <xsl:apply-templates 
301          select="*[not(self::varlistentry
302                    or self::title
303                    or self::titleabbrev)]
304                  |comment()[not(preceding-sibling::varlistentry)]
305                  |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
306        <dl>
307          <xsl:apply-templates 
308              select="varlistentry
309                      |comment()[preceding-sibling::varlistentry]
310                      |processing-instruction()[preceding-sibling::varlistentry]"/>
311        </dl>
312      </xsl:otherwise>
313    </xsl:choose>
314  </div>
315</xsl:template>
316
317<xsl:template match="variablelist/title">
318  <!-- nop -->
319</xsl:template>
320
321<xsl:template match="itemizedlist/titleabbrev|orderedlist/titleabbrev">
322  <!--nop-->
323</xsl:template>
324
325<xsl:template match="variablelist/titleabbrev">
326  <!--nop-->
327</xsl:template>
328
329<xsl:template match="listitem" mode="xref">
330  <xsl:number format="1"/>
331</xsl:template>
332
333<xsl:template match="listitem/simpara" priority="2">
334  <!-- If a listitem contains only a single simpara, don't output
335       the <p> wrapper; this has the effect of creating an li
336       with simple text content. -->
337  <xsl:choose>
338    <xsl:when test="not(preceding-sibling::*)
339                    and not (following-sibling::*)">
340      <xsl:call-template name="anchor"/>
341      <xsl:apply-templates/>
342    </xsl:when>
343    <xsl:otherwise>
344      <p>
345        <xsl:if test="@role and $para.propagates.style != 0">
346          <xsl:attribute name="class">
347            <xsl:value-of select="@role"/>
348          </xsl:attribute>
349        </xsl:if>
350
351        <xsl:call-template name="anchor"/>
352        <xsl:apply-templates/>
353      </p>
354    </xsl:otherwise>
355  </xsl:choose>
356</xsl:template>
357
358<xsl:template match="varlistentry">
359  <dt>
360    <xsl:call-template name="anchor"/>
361    <xsl:apply-templates select="term"/>
362  </dt>
363  <dd>
364    <xsl:apply-templates select="listitem"/>
365  </dd>
366</xsl:template>
367
368<xsl:template match="varlistentry" mode="varlist-table">
369  <xsl:variable name="presentation">
370    <xsl:call-template name="dbhtml-attribute">
371      <xsl:with-param name="pis"
372                      select="/processing-instruction('dbhtml')"/>
373      <xsl:with-param name="attribute" select="'term-presentation'"/>
374    </xsl:call-template>
375  </xsl:variable>
376
377  <xsl:variable name="separator">
378    <xsl:call-template name="dbhtml-attribute">
379      <xsl:with-param name="pis"
380                      select="/processing-instruction('dbhtml')"/>
381      <xsl:with-param name="attribute" select="'term-separator'"/>
382    </xsl:call-template>
383  </xsl:variable>
384  <tr>
385    <xsl:call-template name="tr.attributes">
386      <xsl:with-param name="rownum">
387        <xsl:number from="variablelist" count="varlistentry"/>
388      </xsl:with-param>
389    </xsl:call-template>
390
391    <td>
392      <xsl:call-template name="anchor"/>
393      <xsl:choose>
394        <xsl:when test="$presentation = 'bold'">
395          <b>
396            <xsl:apply-templates select="term"/>
397            <xsl:value-of select="$separator"/>
398          </b>
399        </xsl:when>
400        <xsl:when test="$presentation = 'italic'">
401          <i>
402            <xsl:apply-templates select="term"/>
403            <xsl:value-of select="$separator"/>
404          </i>
405        </xsl:when>
406        <xsl:when test="$presentation = 'bold-italic'">
407          <b>
408            <i>
409              <xsl:apply-templates select="term"/>
410              <xsl:value-of select="$separator"/>
411            </i>
412          </b>
413        </xsl:when>
414        <xsl:otherwise>
415          <xsl:apply-templates select="term"/>
416          <xsl:value-of select="$separator"/>
417        </xsl:otherwise>
418      </xsl:choose>
419    </td>
420    <td>
421      <xsl:apply-templates select="listitem"/>
422    </td>
423  </tr>
424</xsl:template>
425
426<xsl:template match="varlistentry/term">
427  <span class="term">
428    <xsl:call-template name="anchor"/>
429    <xsl:apply-templates/>
430    <xsl:choose>
431      <xsl:when test="position() = last()"/> <!-- do nothing -->
432      <xsl:otherwise>
433        <!-- * if we have multiple terms in the same varlistentry, generate -->
434        <!-- * a separator (", " by default) and/or an additional line -->
435        <!-- * break after each one except the last -->
436        <xsl:value-of select="$variablelist.term.separator"/>
437        <xsl:if test="not($variablelist.term.break.after = '0')">
438          <br/>
439        </xsl:if>
440      </xsl:otherwise>
441    </xsl:choose>
442  </span>
443</xsl:template>
444
445<xsl:template match="varlistentry/listitem">
446  <xsl:choose>
447    <xsl:when test="$show.revisionflag != 0 and @revisionflag">
448      <div class="{@revisionflag}">
449        <xsl:apply-templates/>
450      </div>
451    </xsl:when>
452    <xsl:otherwise>
453      <xsl:apply-templates/>
454    </xsl:otherwise>
455  </xsl:choose>
456</xsl:template>
457
458<!-- ==================================================================== -->
459
460<xsl:template match="simplelist">
461  <!-- with no type specified, the default is 'vert' -->
462  <xsl:call-template name="anchor"/>
463  <table class="simplelist" border="0" summary="Simple list">
464    <xsl:call-template name="simplelist.vert">
465      <xsl:with-param name="cols">
466        <xsl:choose>
467          <xsl:when test="@columns">
468            <xsl:value-of select="@columns"/>
469          </xsl:when>
470          <xsl:otherwise>1</xsl:otherwise>
471        </xsl:choose>
472      </xsl:with-param>
473    </xsl:call-template>
474  </table>
475</xsl:template>
476
477<xsl:template match="simplelist[@type='inline']">
478  <span class="{name(.)}">
479  <!-- if dbchoice PI exists, use that to determine the choice separator -->
480  <!-- (that is, equivalent of "and" or "or" in current locale), or literal -->
481  <!-- value of "choice" otherwise -->
482  <xsl:variable name="localized-choice-separator">
483    <xsl:choose>
484      <xsl:when test="processing-instruction('dbchoice')">
485	<xsl:call-template name="select.choice.separator"/>
486      </xsl:when>
487      <xsl:otherwise>
488	<!-- empty -->
489      </xsl:otherwise>
490    </xsl:choose>
491  </xsl:variable>
492
493  <xsl:for-each select="member">
494    <xsl:apply-templates/>
495    <xsl:choose>
496      <xsl:when test="position() = last()"/> <!-- do nothing -->
497      <xsl:otherwise>
498	<xsl:text>, </xsl:text>
499	<xsl:if test="position() = last() - 1">
500	  <xsl:if test="$localized-choice-separator != ''">
501	    <xsl:value-of select="$localized-choice-separator"/>
502	    <xsl:text> </xsl:text>
503	  </xsl:if>
504	</xsl:if>
505      </xsl:otherwise>
506    </xsl:choose>
507  </xsl:for-each>
508  </span>
509</xsl:template>
510
511<xsl:template match="simplelist[@type='horiz']">
512  <xsl:call-template name="anchor"/>
513  <table class="simplelist" border="0" summary="Simple list">
514    <xsl:call-template name="simplelist.horiz">
515      <xsl:with-param name="cols">
516        <xsl:choose>
517          <xsl:when test="@columns">
518            <xsl:value-of select="@columns"/>
519          </xsl:when>
520          <xsl:otherwise>1</xsl:otherwise>
521        </xsl:choose>
522      </xsl:with-param>
523    </xsl:call-template>
524  </table>
525</xsl:template>
526
527<xsl:template match="simplelist[@type='vert']">
528  <xsl:call-template name="anchor"/>
529  <table class="simplelist" border="0" summary="Simple list">
530    <xsl:call-template name="simplelist.vert">
531      <xsl:with-param name="cols">
532        <xsl:choose>
533          <xsl:when test="@columns">
534            <xsl:value-of select="@columns"/>
535          </xsl:when>
536          <xsl:otherwise>1</xsl:otherwise>
537        </xsl:choose>
538      </xsl:with-param>
539    </xsl:call-template>
540  </table>
541</xsl:template>
542
543<xsl:template name="simplelist.horiz">
544  <xsl:param name="cols">1</xsl:param>
545  <xsl:param name="cell">1</xsl:param>
546  <xsl:param name="members" select="/member"/>
547
548  <xsl:if test="$cell &lt;= count($members)">
549    <tr>
550      <xsl:call-template name="tr.attributes">
551        <xsl:with-param name="row" select="$members[1]"/>
552        <xsl:with-param name="rownum" select="(($cell - 1) div $cols) + 1"/>
553      </xsl:call-template>
554
555      <xsl:call-template name="simplelist.horiz.row">
556        <xsl:with-param name="cols" select="$cols"/>
557        <xsl:with-param name="cell" select="$cell"/>
558        <xsl:with-param name="members" select="$members"/>
559      </xsl:call-template>
560   </tr>
561    <xsl:call-template name="simplelist.horiz">
562      <xsl:with-param name="cols" select="$cols"/>
563      <xsl:with-param name="cell" select="$cell + $cols"/>
564      <xsl:with-param name="members" select="$members"/>
565    </xsl:call-template>
566  </xsl:if>
567</xsl:template>
568
569<xsl:template name="simplelist.horiz.row">
570  <xsl:param name="cols">1</xsl:param>
571  <xsl:param name="cell">1</xsl:param>
572  <xsl:param name="members" select="/member"/>
573  <xsl:param name="curcol">1</xsl:param>
574
575  <xsl:if test="$curcol &lt;= $cols">
576    <td>
577      <xsl:choose>
578        <xsl:when test="$members[position()=$cell]">
579          <xsl:apply-templates select="$members[position()=$cell]"/>
580        </xsl:when>
581        <xsl:otherwise>
582          <xsl:text>&#160;</xsl:text>
583        </xsl:otherwise>
584      </xsl:choose>
585    </td>
586    <xsl:call-template name="simplelist.horiz.row">
587      <xsl:with-param name="cols" select="$cols"/>
588      <xsl:with-param name="cell" select="$cell+1"/>
589      <xsl:with-param name="members" select="$members"/>
590      <xsl:with-param name="curcol" select="$curcol+1"/>
591    </xsl:call-template>
592  </xsl:if>
593</xsl:template>
594
595<xsl:template name="simplelist.vert">
596  <xsl:param name="cols">1</xsl:param>
597  <xsl:param name="cell">1</xsl:param>
598  <xsl:param name="members" select="/member"/>
599  <xsl:param name="rows"
600             select="floor((count($members)+$cols - 1) div $cols)"/>
601
602  <xsl:if test="$cell &lt;= $rows">
603    <tr>
604      <xsl:call-template name="tr.attributes">
605        <xsl:with-param name="row" select="$members[1]"/>
606        <xsl:with-param name="rownum" select="$cell"/>
607      </xsl:call-template>
608
609      <xsl:call-template name="simplelist.vert.row">
610        <xsl:with-param name="cols" select="$cols"/>
611        <xsl:with-param name="rows" select="$rows"/>
612        <xsl:with-param name="cell" select="$cell"/>
613        <xsl:with-param name="members" select="$members"/>
614      </xsl:call-template>
615    </tr>
616    <xsl:call-template name="simplelist.vert">
617      <xsl:with-param name="cols" select="$cols"/>
618      <xsl:with-param name="cell" select="$cell+1"/>
619      <xsl:with-param name="members" select="$members"/>
620      <xsl:with-param name="rows" select="$rows"/>
621    </xsl:call-template>
622  </xsl:if>
623</xsl:template>
624
625<xsl:template name="simplelist.vert.row">
626  <xsl:param name="cols">1</xsl:param>
627  <xsl:param name="rows">1</xsl:param>
628  <xsl:param name="cell">1</xsl:param>
629  <xsl:param name="members" select="/member"/>
630  <xsl:param name="curcol">1</xsl:param>
631
632  <xsl:if test="$curcol &lt;= $cols">
633    <td>
634      <xsl:choose>
635        <xsl:when test="$members[position()=$cell]">
636          <xsl:apply-templates select="$members[position()=$cell]"/>
637        </xsl:when>
638        <xsl:otherwise>
639          <xsl:text>&#160;</xsl:text>
640        </xsl:otherwise>
641      </xsl:choose>
642    </td>
643    <xsl:call-template name="simplelist.vert.row">
644      <xsl:with-param name="cols" select="$cols"/>
645      <xsl:with-param name="rows" select="$rows"/>
646      <xsl:with-param name="cell" select="$cell+$rows"/>
647      <xsl:with-param name="members" select="$members"/>
648      <xsl:with-param name="curcol" select="$curcol+1"/>
649    </xsl:call-template>
650  </xsl:if>
651</xsl:template>
652
653<xsl:template match="member">
654  <xsl:call-template name="anchor"/>
655  <xsl:apply-templates/>
656</xsl:template>
657
658<!-- ==================================================================== -->
659
660<xsl:template match="procedure">
661  <xsl:variable name="param.placement"
662                select="substring-after(normalize-space($formal.title.placement),
663                                        concat(local-name(.), ' '))"/>
664
665  <xsl:variable name="placement">
666    <xsl:choose>
667      <xsl:when test="contains($param.placement, ' ')">
668        <xsl:value-of select="substring-before($param.placement, ' ')"/>
669      </xsl:when>
670      <xsl:when test="$param.placement = ''">before</xsl:when>
671      <xsl:otherwise>
672        <xsl:value-of select="$param.placement"/>
673      </xsl:otherwise>
674    </xsl:choose>
675  </xsl:variable>
676
677  <!-- Preserve order of PIs and comments -->
678  <xsl:variable name="preamble"
679        select="*[not(self::step
680                  or self::title
681                  or self::titleabbrev)]
682                |comment()[not(preceding-sibling::step)]
683                |processing-instruction()[not(preceding-sibling::step)]"/>
684
685  <div class="{name(.)}">
686    <xsl:call-template name="anchor">
687      <xsl:with-param name="conditional">
688        <xsl:choose>
689	  <xsl:when test="title">0</xsl:when>
690	  <xsl:otherwise>1</xsl:otherwise>
691	</xsl:choose>
692      </xsl:with-param>
693    </xsl:call-template>
694
695    <xsl:if test="title and $placement = 'before'">
696      <xsl:call-template name="formal.object.heading"/>
697    </xsl:if>
698
699    <xsl:apply-templates select="$preamble"/>
700
701    <xsl:choose>
702      <xsl:when test="count(step) = 1">
703        <ul>
704          <xsl:apply-templates 
705            select="step
706                    |comment()[preceding-sibling::step]
707                    |processing-instruction()[preceding-sibling::step]"/>
708        </ul>
709      </xsl:when>
710      <xsl:otherwise>
711        <ol>
712          <xsl:attribute name="type">
713            <xsl:value-of select="substring($procedure.step.numeration.formats,1,1)"/>
714          </xsl:attribute>
715          <xsl:apply-templates 
716            select="step
717                    |comment()[preceding-sibling::step]
718                    |processing-instruction()[preceding-sibling::step]"/>
719        </ol>
720      </xsl:otherwise>
721    </xsl:choose>
722
723    <xsl:if test="title and $placement != 'before'">
724      <xsl:call-template name="formal.object.heading"/>
725    </xsl:if>
726  </div>
727</xsl:template>
728
729<xsl:template match="procedure/title">
730  <!-- nop -->
731</xsl:template>
732
733<xsl:template match="substeps">
734  <xsl:variable name="numeration">
735    <xsl:call-template name="procedure.step.numeration"/>
736  </xsl:variable>
737
738  <xsl:call-template name="anchor"/>
739
740  <ol type="{$numeration}">
741    <xsl:apply-templates/>
742  </ol>
743</xsl:template>
744
745<xsl:template match="step">
746  <li>
747    <xsl:call-template name="anchor"/>
748    <xsl:apply-templates/>
749  </li>
750</xsl:template>
751
752<xsl:template match="stepalternatives">
753  <xsl:call-template name="anchor"/>
754  <ul>
755    <xsl:apply-templates/>
756  </ul>
757</xsl:template>
758
759<xsl:template match="step/title">
760  <p class="title">
761    <b>
762      <xsl:apply-templates/>
763    </b>
764  </p>
765</xsl:template>
766
767<!-- ==================================================================== -->
768
769<xsl:template match="segmentedlist">
770  <xsl:variable name="presentation">
771    <xsl:call-template name="dbhtml-attribute">
772      <xsl:with-param name="pis"
773                      select="processing-instruction('dbhtml')"/>
774      <xsl:with-param name="attribute" select="'list-presentation'"/>
775    </xsl:call-template>
776  </xsl:variable>
777
778  <div class="{name(.)}">
779    <xsl:call-template name="anchor"/>
780
781    <xsl:choose>
782      <xsl:when test="$presentation = 'table'">
783        <xsl:apply-templates select="." mode="seglist-table"/>
784      </xsl:when>
785      <xsl:when test="$presentation = 'list'">
786        <xsl:apply-templates/>
787      </xsl:when>
788      <xsl:when test="$segmentedlist.as.table != 0">
789        <xsl:apply-templates select="." mode="seglist-table"/>
790      </xsl:when>
791      <xsl:otherwise>
792        <xsl:apply-templates/>
793      </xsl:otherwise>
794    </xsl:choose>
795  </div>
796</xsl:template>
797
798<xsl:template match="segmentedlist/title">
799  <div class="title">
800    <strong><span class="title"><xsl:apply-templates/></span></strong>
801  </div>
802</xsl:template>
803
804<xsl:template match="segtitle">
805</xsl:template>
806
807<xsl:template match="segtitle" mode="segtitle-in-seg">
808  <xsl:apply-templates/>
809</xsl:template>
810
811<xsl:template match="seglistitem">
812  <div class="seglistitem">
813    <xsl:call-template name="anchor"/>
814    <xsl:apply-templates/>
815  </div>
816</xsl:template>
817
818<xsl:template match="seg">
819  <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
820  <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
821  <xsl:variable name="segtitles" select="$seglist/segtitle"/>
822
823  <!--
824     Note: segtitle is only going to be the right thing in a well formed
825     SegmentedList.  If there are too many Segs or too few SegTitles,
826     you'll get something odd...maybe an error
827  -->
828
829  <div class="seg">
830    <strong>
831      <span class="segtitle">
832        <xsl:apply-templates select="$segtitles[$segnum=position()]"
833                             mode="segtitle-in-seg"/>
834        <xsl:text>: </xsl:text>
835      </span>
836    </strong>
837    <xsl:apply-templates/>
838  </div>
839</xsl:template>
840
841<xsl:template match="segmentedlist" mode="seglist-table">
842  <xsl:variable name="table-summary">
843    <xsl:call-template name="dbhtml-attribute">
844      <xsl:with-param name="pis"
845                      select="processing-instruction('dbhtml')"/>
846      <xsl:with-param name="attribute" select="'table-summary'"/>
847    </xsl:call-template>
848  </xsl:variable>
849
850  <xsl:variable name="list-width">
851    <xsl:call-template name="dbhtml-attribute">
852      <xsl:with-param name="pis"
853                      select="processing-instruction('dbhtml')"/>
854      <xsl:with-param name="attribute" select="'list-width'"/>
855    </xsl:call-template>
856  </xsl:variable>
857
858  <xsl:apply-templates select="title"/>
859
860  <table border="0">
861    <xsl:if test="$list-width != ''">
862      <xsl:attribute name="width">
863        <xsl:value-of select="$list-width"/>
864      </xsl:attribute>
865    </xsl:if>
866    <xsl:if test="$table-summary != ''">
867      <xsl:attribute name="summary">
868        <xsl:value-of select="$table-summary"/>
869      </xsl:attribute>
870    </xsl:if>
871    <thead>
872      <tr class="segtitle">
873        <xsl:call-template name="tr.attributes">
874          <xsl:with-param name="row" select="segtitle[1]"/>
875          <xsl:with-param name="rownum" select="1"/>
876        </xsl:call-template>
877        <xsl:apply-templates select="segtitle" mode="seglist-table"/>
878      </tr>
879    </thead>
880    <tbody>
881      <xsl:apply-templates select="seglistitem" mode="seglist-table"/>
882    </tbody>
883  </table>
884</xsl:template>
885
886<xsl:template match="segtitle" mode="seglist-table">
887  <th><xsl:apply-templates/></th>
888</xsl:template>
889
890<xsl:template match="seglistitem" mode="seglist-table">
891  <xsl:variable name="seglinum">
892    <xsl:number from="segmentedlist" count="seglistitem"/>
893  </xsl:variable>
894
895  <tr class="seglistitem">
896    <xsl:call-template name="tr.attributes">
897      <xsl:with-param name="rownum" select="$seglinum + 1"/>
898    </xsl:call-template>
899    <xsl:apply-templates mode="seglist-table"/>
900  </tr>
901</xsl:template>
902
903<xsl:template match="seg" mode="seglist-table">
904  <td class="seg"><xsl:apply-templates/></td>
905</xsl:template>
906
907<xsl:template match="seg[1]" mode="seglist-table">
908  <td class="seg">
909    <xsl:call-template name="anchor">
910      <xsl:with-param name="node" select="ancestor::seglistitem"/>
911    </xsl:call-template>
912    <xsl:apply-templates/>
913  </td>
914</xsl:template>
915
916<!-- ==================================================================== -->
917
918<xsl:template match="calloutlist">
919  <div class="{name(.)}">
920    <xsl:call-template name="anchor"/>
921    <xsl:if test="title">
922      <xsl:call-template name="formal.object.heading"/>
923    </xsl:if>
924
925    <!-- Preserve order of PIs and comments -->
926    <xsl:apply-templates 
927         select="*[not(self::callout or self::title or self::titleabbrev)]
928                   |comment()[not(preceding-sibling::callout)]
929		   |processing-instruction()[not(preceding-sibling::callout)]"/>
930
931    <xsl:choose>
932      <xsl:when test="$callout.list.table != 0">
933        <table border="0" summary="Callout list">
934	  <xsl:apply-templates select="callout
935			        |comment()[preceding-sibling::calllout]
936				|processing-instruction()[preceding-sibling::callout]"/>
937	</table>
938      </xsl:when>
939      <xsl:otherwise>
940	<dl compact="compact">
941	  <xsl:apply-templates select="callout
942			        |comment()[preceding-sibling::calllout]
943				|processing-instruction()[preceding-sibling::callout]"/>
944	</dl>
945      </xsl:otherwise>
946    </xsl:choose>
947  </div>
948</xsl:template>
949
950<xsl:template match="calloutlist/title">
951</xsl:template>
952
953<xsl:template match="callout">
954  <xsl:choose>
955    <xsl:when test="$callout.list.table != 0">
956      <tr>
957        <xsl:call-template name="tr.attributes">
958          <xsl:with-param name="rownum">
959            <xsl:number from="calloutlist" count="callout"/>
960          </xsl:with-param>
961        </xsl:call-template>
962
963        <td width="5%" valign="top" align="left">
964          <xsl:call-template name="anchor"/>
965          <xsl:call-template name="callout.arearefs">
966            <xsl:with-param name="arearefs" select="@arearefs"/>
967          </xsl:call-template>
968        </td>
969        <td valign="top" align="left">
970          <xsl:apply-templates/>
971        </td>
972      </tr>
973    </xsl:when>
974    <xsl:otherwise>
975      <dt>
976        <xsl:call-template name="anchor"/>
977        <xsl:call-template name="callout.arearefs">
978          <xsl:with-param name="arearefs" select="@arearefs"/>
979        </xsl:call-template>
980      </dt>
981      <dd><xsl:apply-templates/></dd>
982    </xsl:otherwise>
983  </xsl:choose>
984</xsl:template>
985
986<xsl:template match="callout/simpara" priority="2">
987  <!-- If a callout contains only a single simpara, don't output
988       the <p> wrapper; this has the effect of creating an li
989       with simple text content. -->
990  <xsl:choose>
991    <xsl:when test="not(preceding-sibling::*)
992                    and not (following-sibling::*)">
993      <xsl:call-template name="anchor"/>
994      <xsl:apply-templates/>
995    </xsl:when>
996    <xsl:otherwise>
997      <p>
998        <xsl:if test="@role and $para.propagates.style != 0">
999          <xsl:attribute name="class">
1000            <xsl:value-of select="@role"/>
1001          </xsl:attribute>
1002        </xsl:if>
1003
1004        <xsl:call-template name="anchor"/>
1005        <xsl:apply-templates/>
1006      </p>
1007    </xsl:otherwise>
1008  </xsl:choose>
1009</xsl:template>
1010
1011<xsl:template name="callout.arearefs">
1012  <xsl:param name="arearefs"></xsl:param>
1013  <xsl:if test="$arearefs!=''">
1014    <xsl:choose>
1015      <xsl:when test="substring-before($arearefs,' ')=''">
1016        <xsl:call-template name="callout.arearef">
1017          <xsl:with-param name="arearef" select="$arearefs"/>
1018        </xsl:call-template>
1019      </xsl:when>
1020      <xsl:otherwise>
1021        <xsl:call-template name="callout.arearef">
1022          <xsl:with-param name="arearef"
1023                          select="substring-before($arearefs,' ')"/>
1024        </xsl:call-template>
1025      </xsl:otherwise>
1026    </xsl:choose>
1027    <xsl:call-template name="callout.arearefs">
1028      <xsl:with-param name="arearefs"
1029                      select="substring-after($arearefs,' ')"/>
1030    </xsl:call-template>
1031  </xsl:if>
1032</xsl:template>
1033
1034<xsl:template name="callout.arearef">
1035  <xsl:param name="arearef"></xsl:param>
1036  <xsl:variable name="targets" select="key('id',$arearef)"/>
1037  <xsl:variable name="target" select="$targets[1]"/>
1038
1039  <xsl:call-template name="check.id.unique">
1040    <xsl:with-param name="linkend" select="$arearef"/>
1041  </xsl:call-template>
1042
1043  <xsl:choose>
1044    <xsl:when test="count($target)=0">
1045      <xsl:text>???</xsl:text>
1046    </xsl:when>
1047    <xsl:when test="local-name($target)='co'">
1048      <a>
1049        <xsl:attribute name="href">
1050          <xsl:text>#</xsl:text>
1051          <xsl:value-of select="$arearef"/>
1052        </xsl:attribute>
1053        <xsl:apply-templates select="$target" mode="callout-bug"/>
1054      </a>
1055      <xsl:text> </xsl:text>
1056    </xsl:when>
1057    <xsl:when test="local-name($target)='areaset'">
1058      <xsl:call-template name="callout-bug">
1059        <xsl:with-param name="conum">
1060          <xsl:apply-templates select="$target" mode="conumber"/>
1061        </xsl:with-param>
1062      </xsl:call-template>
1063    </xsl:when>
1064    <xsl:when test="local-name($target)='area'">
1065      <xsl:choose>
1066        <xsl:when test="$target/parent::areaset">
1067          <xsl:call-template name="callout-bug">
1068            <xsl:with-param name="conum">
1069              <xsl:apply-templates select="$target/parent::areaset"
1070                                   mode="conumber"/>
1071            </xsl:with-param>
1072          </xsl:call-template>
1073        </xsl:when>
1074        <xsl:otherwise>
1075          <xsl:call-template name="callout-bug">
1076            <xsl:with-param name="conum">
1077              <xsl:apply-templates select="$target" mode="conumber"/>
1078            </xsl:with-param>
1079          </xsl:call-template>
1080        </xsl:otherwise>
1081      </xsl:choose>
1082    </xsl:when>
1083    <xsl:otherwise>
1084      <xsl:text>???</xsl:text>
1085    </xsl:otherwise>
1086  </xsl:choose>
1087</xsl:template>
1088
1089<!-- ==================================================================== -->
1090
1091</xsl:stylesheet>
1092
1093