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