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