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