]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/fo/lists.xsl
Capitalized the start of a sentence in the bucket section of cataloging.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / fo / lists.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4                 version='1.0'>
5
6 <!-- ********************************************************************
7      $Id: lists.xsl 8436 2009-05-11 08:20:40Z 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   <xsl:variable name="id">
20     <xsl:call-template name="object.id"/>
21   </xsl:variable>
22
23   <xsl:variable name="keep.together">
24     <xsl:call-template name="pi.dbfo_keep-together"/>
25   </xsl:variable>
26
27   <xsl:variable name="pi-label-width">
28     <xsl:call-template name="pi.dbfo_label-width"/>
29   </xsl:variable>
30
31   <xsl:variable name="label-width">
32     <xsl:choose>
33       <xsl:when test="$pi-label-width = ''">
34         <xsl:value-of select="$itemizedlist.label.width"/>
35       </xsl:when>
36       <xsl:otherwise>
37         <xsl:value-of select="$pi-label-width"/>
38       </xsl:otherwise>
39     </xsl:choose>
40   </xsl:variable>
41
42   <xsl:if test="title">
43     <xsl:apply-templates select="title" mode="list.title.mode"/>
44   </xsl:if>
45
46   <!-- Preserve order of PIs and comments -->
47   <xsl:apply-templates 
48       select="*[not(self::listitem
49                 or self::title
50                 or self::titleabbrev)]
51               |comment()[not(preceding-sibling::listitem)]
52               |processing-instruction()[not(preceding-sibling::listitem)]"/>
53
54   <xsl:variable name="content">
55     <xsl:apply-templates 
56           select="listitem
57                   |comment()[preceding-sibling::listitem]
58                   |processing-instruction()[preceding-sibling::listitem]"/>
59   </xsl:variable>
60
61   <!-- nested lists don't add extra list-block spacing -->
62   <xsl:choose>
63     <xsl:when test="ancestor::listitem">
64       <fo:list-block id="{$id}" xsl:use-attribute-sets="itemizedlist.properties">
65         <xsl:attribute name="provisional-distance-between-starts">
66           <xsl:value-of select="$label-width"/>
67         </xsl:attribute>
68         <xsl:if test="$keep.together != ''">
69           <xsl:attribute name="keep-together.within-column"><xsl:value-of
70                           select="$keep.together"/></xsl:attribute>
71         </xsl:if>
72         <xsl:copy-of select="$content"/>
73       </fo:list-block>
74     </xsl:when>
75     <xsl:otherwise>
76       <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing itemizedlist.properties">
77         <xsl:attribute name="provisional-distance-between-starts">
78           <xsl:value-of select="$label-width"/>
79         </xsl:attribute>
80         <xsl:if test="$keep.together != ''">
81           <xsl:attribute name="keep-together.within-column"><xsl:value-of
82                           select="$keep.together"/></xsl:attribute>
83         </xsl:if>
84         <xsl:copy-of select="$content"/>
85       </fo:list-block>
86     </xsl:otherwise>
87   </xsl:choose>
88
89 </xsl:template>
90
91 <xsl:template match="itemizedlist/title|orderedlist/title">
92   <!--nop-->
93 </xsl:template>
94
95 <xsl:template match="variablelist/title" mode="vl.as.list">
96   <!--nop-->
97 </xsl:template>
98
99 <xsl:template match="variablelist/title" mode="vl.as.blocks">
100   <!--nop-->
101 </xsl:template>
102
103 <xsl:template match="itemizedlist/titleabbrev|orderedlist/titleabbrev">
104   <!--nop-->
105 </xsl:template>
106
107 <xsl:template match="procedure/titleabbrev">
108   <!--nop-->
109 </xsl:template>
110
111 <xsl:template match="variablelist/titleabbrev" mode="vl.as.list">
112   <!--nop-->
113 </xsl:template>
114
115 <xsl:template match="variablelist/titleabbrev" mode="vl.as.blocks">
116   <!--nop-->
117 </xsl:template>
118
119 <xsl:template match="itemizedlist/listitem">
120   <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
121
122   <xsl:variable name="keep.together">
123     <xsl:call-template name="pi.dbfo_keep-together"/>
124   </xsl:variable>
125
126   <xsl:variable name="item.contents">
127     <fo:list-item-label end-indent="label-end()" xsl:use-attribute-sets="itemizedlist.label.properties">
128       <fo:block>
129         <xsl:call-template name="itemizedlist.label.markup">
130           <xsl:with-param name="itemsymbol">
131             <xsl:call-template name="list.itemsymbol">
132               <xsl:with-param name="node" select="parent::itemizedlist"/>
133             </xsl:call-template>
134           </xsl:with-param>
135         </xsl:call-template>
136       </fo:block>
137     </fo:list-item-label>
138     <fo:list-item-body start-indent="body-start()">
139       <xsl:choose>
140         <!-- * work around broken passivetex list-item-body rendering -->
141         <xsl:when test="$passivetex.extensions = '1'">
142           <xsl:apply-templates/>
143         </xsl:when>
144         <xsl:otherwise>
145           <fo:block>
146             <xsl:apply-templates/>
147           </fo:block>
148         </xsl:otherwise>
149       </xsl:choose>
150     </fo:list-item-body>
151   </xsl:variable>
152
153   <xsl:choose>
154     <xsl:when test="parent::*/@spacing = 'compact'">
155       <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
156         <xsl:if test="$keep.together != ''">
157           <xsl:attribute name="keep-together.within-column"><xsl:value-of
158                           select="$keep.together"/></xsl:attribute>
159         </xsl:if>
160         <xsl:copy-of select="$item.contents"/>
161       </fo:list-item>
162     </xsl:when>
163     <xsl:otherwise>
164       <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
165         <xsl:if test="$keep.together != ''">
166           <xsl:attribute name="keep-together.within-column"><xsl:value-of
167                           select="$keep.together"/></xsl:attribute>
168         </xsl:if>
169         <xsl:copy-of select="$item.contents"/>
170       </fo:list-item>
171     </xsl:otherwise>
172   </xsl:choose>
173 </xsl:template>
174
175 <xsl:template name="itemizedlist.label.markup">
176   <xsl:param name="itemsymbol" select="'disc'"/>
177
178   <xsl:choose>
179     <xsl:when test="$itemsymbol='none'"></xsl:when>
180     <xsl:when test="$itemsymbol='disc'">&#x2022;</xsl:when>
181     <xsl:when test="$itemsymbol='bullet'">&#x2022;</xsl:when>
182     <xsl:when test="$itemsymbol='endash'">&#x2013;</xsl:when>
183     <xsl:when test="$itemsymbol='emdash'">&#x2014;</xsl:when>
184     <!-- Some of these may work in your XSL-FO processor and fonts -->
185     <!--
186     <xsl:when test="$itemsymbol='square'">&#x25A0;</xsl:when>
187     <xsl:when test="$itemsymbol='box'">&#x25A0;</xsl:when>
188     <xsl:when test="$itemsymbol='smallblacksquare'">&#x25AA;</xsl:when>
189     <xsl:when test="$itemsymbol='circle'">&#x25CB;</xsl:when>
190     <xsl:when test="$itemsymbol='opencircle'">&#x25CB;</xsl:when>
191     <xsl:when test="$itemsymbol='whitesquare'">&#x25A1;</xsl:when>
192     <xsl:when test="$itemsymbol='smallwhitesquare'">&#x25AB;</xsl:when>
193     <xsl:when test="$itemsymbol='round'">&#x25CF;</xsl:when>
194     <xsl:when test="$itemsymbol='blackcircle'">&#x25CF;</xsl:when>
195     <xsl:when test="$itemsymbol='whitebullet'">&#x25E6;</xsl:when>
196     <xsl:when test="$itemsymbol='triangle'">&#x2023;</xsl:when>
197     <xsl:when test="$itemsymbol='point'">&#x203A;</xsl:when>
198     <xsl:when test="$itemsymbol='hand'"><fo:inline 
199                          font-family="Wingdings 2">A</fo:inline></xsl:when>
200     -->
201     <xsl:otherwise>&#x2022;</xsl:otherwise>
202   </xsl:choose>
203 </xsl:template>
204
205 <xsl:template match="orderedlist">
206   <xsl:variable name="id">
207     <xsl:call-template name="object.id"/>
208   </xsl:variable>
209
210   <xsl:variable name="pi-label-width">
211     <xsl:call-template name="pi.dbfo_label-width"/>
212   </xsl:variable>
213
214   <xsl:variable name="label-width">
215     <xsl:choose>
216       <xsl:when test="$pi-label-width = ''">
217         <xsl:value-of select="$orderedlist.label.width"/>
218       </xsl:when>
219       <xsl:otherwise>
220         <xsl:value-of select="$pi-label-width"/>
221       </xsl:otherwise>
222     </xsl:choose>
223   </xsl:variable>
224
225   <xsl:variable name="keep.together">
226     <xsl:call-template name="pi.dbfo_keep-together"/>
227   </xsl:variable>
228
229   <xsl:if test="title">
230     <xsl:apply-templates select="title" mode="list.title.mode"/>
231   </xsl:if>
232
233   <!-- Preserve order of PIs and comments -->
234   <xsl:apply-templates 
235       select="*[not(self::listitem
236                 or self::title
237                 or self::titleabbrev)]
238               |comment()[not(preceding-sibling::listitem)]
239               |processing-instruction()[not(preceding-sibling::listitem)]"/>
240
241   <xsl:variable name="content">
242     <xsl:apply-templates 
243           select="listitem
244                   |comment()[preceding-sibling::listitem]
245                   |processing-instruction()[preceding-sibling::listitem]"/>
246   </xsl:variable>
247
248   <!-- nested lists don't add extra list-block spacing -->
249   <xsl:choose>
250     <xsl:when test="ancestor::listitem">
251       <fo:list-block id="{$id}" xsl:use-attribute-sets="orderedlist.properties">
252         <xsl:attribute name="provisional-distance-between-starts">
253           <xsl:value-of select="$label-width"/>
254         </xsl:attribute>
255         <xsl:if test="$keep.together != ''">
256           <xsl:attribute name="keep-together.within-column"><xsl:value-of
257                           select="$keep.together"/></xsl:attribute>
258         </xsl:if>
259         <xsl:copy-of select="$content"/>
260       </fo:list-block>
261     </xsl:when>
262     <xsl:otherwise>
263       <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing orderedlist.properties">
264         <xsl:attribute name="provisional-distance-between-starts">
265           <xsl:value-of select="$label-width"/>
266         </xsl:attribute>
267         <xsl:if test="$keep.together != ''">
268           <xsl:attribute name="keep-together.within-column"><xsl:value-of
269                           select="$keep.together"/></xsl:attribute>
270         </xsl:if>
271         <xsl:copy-of select="$content"/>
272       </fo:list-block>
273     </xsl:otherwise>
274   </xsl:choose>
275 </xsl:template>
276
277 <xsl:template match="orderedlist/listitem">
278   <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
279
280   <xsl:variable name="keep.together">
281     <xsl:call-template name="pi.dbfo_keep-together"/>
282   </xsl:variable>
283
284   <xsl:variable name="item.contents">
285     <fo:list-item-label end-indent="label-end()" xsl:use-attribute-sets="orderedlist.label.properties">
286       <fo:block>
287         <xsl:apply-templates select="." mode="item-number"/>
288       </fo:block>
289     </fo:list-item-label>
290     <fo:list-item-body start-indent="body-start()">
291       <fo:block>
292         <xsl:apply-templates/>
293       </fo:block>
294     </fo:list-item-body>
295   </xsl:variable>
296
297   <xsl:choose>
298     <xsl:when test="parent::*/@spacing = 'compact'">
299       <fo:list-item id="{$id}" xsl:use-attribute-sets="compact.list.item.spacing">
300         <xsl:if test="$keep.together != ''">
301           <xsl:attribute name="keep-together.within-column"><xsl:value-of
302                           select="$keep.together"/></xsl:attribute>
303         </xsl:if>
304         <xsl:copy-of select="$item.contents"/>
305       </fo:list-item>
306     </xsl:when>
307     <xsl:otherwise>
308       <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
309         <xsl:if test="$keep.together != ''">
310           <xsl:attribute name="keep-together.within-column"><xsl:value-of
311                           select="$keep.together"/></xsl:attribute>
312         </xsl:if>
313         <xsl:copy-of select="$item.contents"/>
314       </fo:list-item>
315     </xsl:otherwise>
316   </xsl:choose>
317 </xsl:template>
318
319 <xsl:template match="listitem/*[1][local-name()='para' or 
320                                    local-name()='simpara' or 
321                                    local-name()='formalpara']
322                      |glossdef/*[1][local-name()='para' or 
323                                    local-name()='simpara' or 
324                                    local-name()='formalpara']
325                      |step/*[1][local-name()='para' or 
326                                    local-name()='simpara' or 
327                                    local-name()='formalpara']
328                      |callout/*[1][local-name()='para' or 
329                                    local-name()='simpara' or 
330                                    local-name()='formalpara']"
331               priority="2">
332   <fo:block>
333     <xsl:call-template name="anchor"/>
334     <xsl:apply-templates/>
335   </fo:block>
336 </xsl:template>
337
338 <xsl:template match="variablelist">
339   <xsl:variable name="presentation">
340     <xsl:call-template name="pi.dbfo_list-presentation"/>
341   </xsl:variable>
342
343   <xsl:choose>
344     <xsl:when test="$presentation = 'list'">
345       <xsl:apply-templates select="." mode="vl.as.list"/>
346     </xsl:when>
347     <xsl:when test="$presentation = 'blocks'">
348       <xsl:apply-templates select="." mode="vl.as.blocks"/>
349     </xsl:when>
350     <xsl:when test="$variablelist.as.blocks != 0">
351       <xsl:apply-templates select="." mode="vl.as.blocks"/>
352     </xsl:when>
353     <xsl:otherwise>
354       <xsl:apply-templates select="." mode="vl.as.list"/>
355     </xsl:otherwise>
356   </xsl:choose>
357 </xsl:template>
358
359 <xsl:template match="variablelist" mode="vl.as.list">
360   <xsl:variable name="id">
361     <xsl:call-template name="object.id"/>
362   </xsl:variable>
363
364   <xsl:variable name="keep.together">
365     <xsl:call-template name="pi.dbfo_keep-together"/>
366   </xsl:variable>
367
368   <xsl:variable name="term-width">
369     <xsl:call-template name="pi.dbfo_term-width"/>
370   </xsl:variable>
371
372   <xsl:variable name="termlength">
373     <xsl:choose>
374       <xsl:when test="$term-width != ''">
375         <xsl:value-of select="$term-width"/>
376       </xsl:when>
377       <xsl:when test="@termlength">
378         <xsl:variable name="termlength.is.number">
379           <xsl:value-of select="@termlength + 0"/>
380         </xsl:variable>
381         <xsl:choose>
382           <xsl:when test="string($termlength.is.number) = 'NaN'">
383             <!-- if the term length isn't just a number, assume it's a measurement -->
384             <xsl:value-of select="@termlength"/>
385           </xsl:when>
386           <xsl:otherwise>
387             <xsl:value-of select="@termlength"/>
388             <xsl:choose>
389               <!-- workaround for passivetex lack of support for non-constant expressions -->
390               <xsl:when test="$passivetex.extensions != 0">
391                 <xsl:text>em</xsl:text>
392               </xsl:when>
393               <xsl:otherwise>
394                 <xsl:text>em * 0.60</xsl:text>
395               </xsl:otherwise>
396             </xsl:choose>
397           </xsl:otherwise>
398         </xsl:choose>
399       </xsl:when>
400       <xsl:otherwise>
401         <xsl:call-template name="longest.term">
402           <xsl:with-param name="terms" select="varlistentry/term"/>
403           <xsl:with-param name="maxlength" select="$variablelist.max.termlength"/>
404         </xsl:call-template>
405         <xsl:choose>
406           <!-- workaround for passivetex lack of support for non-constant expressions -->
407           <xsl:when test="$passivetex.extensions != 0">
408             <xsl:text>em</xsl:text>
409           </xsl:when>
410           <xsl:otherwise>
411             <xsl:text>em * 0.60</xsl:text>
412           </xsl:otherwise>
413         </xsl:choose>
414       </xsl:otherwise>
415     </xsl:choose>
416   </xsl:variable>
417
418 <!--
419   <xsl:message>
420     <xsl:text>term width: </xsl:text>
421     <xsl:value-of select="$termlength"/>
422   </xsl:message>
423 -->
424
425   <xsl:variable name="label-separation">1em</xsl:variable>
426   <xsl:variable name="distance-between-starts">
427     <xsl:choose>
428       <!-- workaround for passivetex lack of support for non-constant expressions -->
429       <xsl:when test="$passivetex.extensions != 0">
430         <xsl:value-of select="$termlength"/>
431       </xsl:when>
432       <xsl:otherwise>
433         <xsl:value-of select="$termlength"/>
434         <xsl:text>+</xsl:text>
435         <xsl:value-of select="$label-separation"/>
436       </xsl:otherwise>
437     </xsl:choose>
438   </xsl:variable>
439
440   <xsl:if test="title">
441     <xsl:apply-templates select="title" mode="list.title.mode"/>
442   </xsl:if>
443
444   <!-- Preserve order of PIs and comments -->
445   <xsl:apply-templates 
446     select="*[not(self::varlistentry
447               or self::title
448               or self::titleabbrev)]
449             |comment()[not(preceding-sibling::varlistentry)]
450             |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
451
452   <xsl:variable name="content">
453     <xsl:apply-templates mode="vl.as.list"
454       select="varlistentry
455               |comment()[preceding-sibling::varlistentry]
456               |processing-instruction()[preceding-sibling::varlistentry]"/>
457   </xsl:variable>
458
459   <!-- nested lists don't add extra list-block spacing -->
460   <xsl:choose>
461     <xsl:when test="ancestor::listitem">
462       <fo:list-block id="{$id}"
463                      provisional-distance-between-starts=
464                         "{$distance-between-starts}"
465                      provisional-label-separation="{$label-separation}">
466         <xsl:if test="$keep.together != ''">
467           <xsl:attribute name="keep-together.within-column"><xsl:value-of
468                           select="$keep.together"/></xsl:attribute>
469         </xsl:if>
470         <xsl:copy-of select="$content"/>
471       </fo:list-block>
472     </xsl:when>
473     <xsl:otherwise>
474       <fo:list-block id="{$id}"
475                      provisional-distance-between-starts=
476                         "{$distance-between-starts}"
477                      provisional-label-separation="{$label-separation}"
478                      xsl:use-attribute-sets="list.block.spacing">
479         <xsl:if test="$keep.together != ''">
480           <xsl:attribute name="keep-together.within-column"><xsl:value-of
481                           select="$keep.together"/></xsl:attribute>
482         </xsl:if>
483         <xsl:copy-of select="$content"/>
484       </fo:list-block>
485     </xsl:otherwise>
486   </xsl:choose>
487 </xsl:template>
488
489 <xsl:template name="longest.term">
490   <xsl:param name="longest" select="0"/>
491   <xsl:param name="terms" select="."/>
492   <xsl:param name="maxlength" select="-1"/>
493
494   <!-- Process out any indexterms in the term -->
495   <xsl:variable name="term.text">
496     <xsl:apply-templates select="$terms[1]"/>
497   </xsl:variable>
498
499   <xsl:choose>
500     <xsl:when test="$longest &gt; $maxlength and $maxlength &gt; 0">
501       <xsl:value-of select="$maxlength"/>
502     </xsl:when>
503     <xsl:when test="not($terms)">
504       <xsl:value-of select="$longest"/>
505     </xsl:when>
506     <xsl:when test="string-length($term.text) &gt; $longest">
507       <xsl:call-template name="longest.term">
508         <xsl:with-param name="longest" 
509             select="string-length($term.text)"/>
510         <xsl:with-param name="maxlength" select="$maxlength"/>
511         <xsl:with-param name="terms" select="$terms[position() &gt; 1]"/>
512       </xsl:call-template>
513     </xsl:when>
514     <xsl:otherwise>
515       <xsl:call-template name="longest.term">
516         <xsl:with-param name="longest" select="$longest"/>
517         <xsl:with-param name="maxlength" select="$maxlength"/>
518         <xsl:with-param name="terms" select="$terms[position() &gt; 1]"/>
519       </xsl:call-template>
520     </xsl:otherwise>
521   </xsl:choose>
522 </xsl:template>
523
524 <xsl:template match="varlistentry" mode="vl.as.list">
525   <xsl:variable name="id">
526     <xsl:call-template name="object.id"/>
527   </xsl:variable>
528
529   <xsl:variable name="keep.together">
530     <xsl:call-template name="pi.dbfo_keep-together"/>
531   </xsl:variable>
532
533   <xsl:variable name="item.contents">
534     <fo:list-item-label end-indent="label-end()" text-align="start">
535       <fo:block xsl:use-attribute-sets="variablelist.term.properties">
536         <xsl:apply-templates select="term"/>
537       </fo:block>
538     </fo:list-item-label>
539     <fo:list-item-body start-indent="body-start()">
540       <fo:block>
541         <xsl:apply-templates select="listitem"/>
542       </fo:block>
543     </fo:list-item-body>
544   </xsl:variable>
545
546   <xsl:choose>
547     <xsl:when test="parent::*/@spacing = 'compact'">
548       <fo:list-item id="{$id}"
549           xsl:use-attribute-sets="compact.list.item.spacing">
550         <xsl:if test="$keep.together != ''">
551           <xsl:attribute name="keep-together.within-column"><xsl:value-of
552                           select="$keep.together"/></xsl:attribute>
553         </xsl:if>
554         <xsl:copy-of select="$item.contents"/>
555       </fo:list-item>
556     </xsl:when>
557     <xsl:otherwise>
558       <fo:list-item id="{$id}" xsl:use-attribute-sets="list.item.spacing">
559         <xsl:if test="$keep.together != ''">
560           <xsl:attribute name="keep-together.within-column"><xsl:value-of
561                           select="$keep.together"/></xsl:attribute>
562         </xsl:if>
563         <xsl:copy-of select="$item.contents"/>
564       </fo:list-item>
565     </xsl:otherwise>
566   </xsl:choose>
567 </xsl:template>
568
569
570 <xsl:template match="variablelist" mode="vl.as.blocks">
571   <xsl:variable name="id">
572     <xsl:call-template name="object.id"/>
573   </xsl:variable>
574
575   <!-- termlength is irrelevant -->
576
577   <xsl:if test="title">
578     <xsl:apply-templates select="title" mode="list.title.mode"/>
579   </xsl:if>
580
581   <!-- Preserve order of PIs and comments -->
582   <xsl:apply-templates 
583     select="*[not(self::varlistentry
584               or self::title
585               or self::titleabbrev)]
586             |comment()[not(preceding-sibling::varlistentry)]
587             |processing-instruction()[not(preceding-sibling::varlistentry)]"/>
588
589   <xsl:variable name="content">
590     <xsl:apply-templates mode="vl.as.blocks"
591       select="varlistentry
592               |comment()[preceding-sibling::varlistentry]
593               |processing-instruction()[preceding-sibling::varlistentry]"/>
594   </xsl:variable>
595
596   <!-- nested lists don't add extra list-block spacing -->
597   <xsl:choose>
598     <xsl:when test="ancestor::listitem">
599       <fo:block id="{$id}">
600         <xsl:copy-of select="$content"/>
601       </fo:block>
602     </xsl:when>
603     <xsl:otherwise>
604       <fo:block id="{$id}" xsl:use-attribute-sets="list.block.spacing">
605         <xsl:copy-of select="$content"/>
606       </fo:block>
607     </xsl:otherwise>
608   </xsl:choose>
609 </xsl:template>
610
611 <xsl:template match="varlistentry" mode="vl.as.blocks">
612   <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
613
614   <fo:block id="{$id}" xsl:use-attribute-sets="variablelist.term.properties
615                                                list.item.spacing"  
616       keep-together.within-column="always" 
617       keep-with-next.within-column="always">
618     <xsl:apply-templates select="term"/>
619   </fo:block>
620
621   <fo:block>
622     <xsl:attribute name="margin-{$direction.align.start}">0.25in</xsl:attribute>
623     <xsl:apply-templates select="listitem"/>
624   </fo:block>
625 </xsl:template>
626
627 <xsl:template match="varlistentry/term">
628   <fo:inline>
629     <xsl:call-template name="simple.xlink">
630       <xsl:with-param name="content">
631         <xsl:apply-templates/>
632       </xsl:with-param>
633     </xsl:call-template>
634   </fo:inline>
635   <xsl:choose>
636     <xsl:when test="not(following-sibling::term)"/> <!-- do nothing -->
637     <xsl:otherwise>
638       <!-- * if we have multiple terms in the same varlistentry, generate -->
639       <!-- * a separator (", " by default) and/or an additional line -->
640       <!-- * break after each one except the last -->
641       <fo:inline><xsl:value-of select="$variablelist.term.separator"/></fo:inline>
642       <xsl:if test="not($variablelist.term.break.after = '0')">
643         <fo:block/>
644       </xsl:if>
645     </xsl:otherwise>
646   </xsl:choose>
647 </xsl:template>
648
649 <xsl:template match="varlistentry/listitem">
650   <xsl:apply-templates/>
651 </xsl:template>
652
653 <!-- ==================================================================== -->
654
655 <xsl:template match="title" mode="list.title.mode">
656   <xsl:call-template name="formal.object.heading">
657     <xsl:with-param name="object" select=".."/>
658   </xsl:call-template>
659 </xsl:template>
660
661 <!-- ==================================================================== -->
662
663 <xsl:template match="simplelist|simplelist[@type='vert']">
664   <!-- with no type specified, the default is 'vert' -->
665
666   <xsl:variable name="id">
667     <xsl:call-template name="object.id"/>
668   </xsl:variable>
669
670   <xsl:variable name="explicit.table.width">
671     <xsl:call-template name="dbfo-attribute">
672       <xsl:with-param name="pis"
673                       select="processing-instruction('dbfo')"/>
674       <xsl:with-param name="attribute" select="'list-width'"/>
675     </xsl:call-template>
676   </xsl:variable>
677
678   <xsl:variable name="table.width">
679     <xsl:choose>
680       <xsl:when test="$explicit.table.width != ''">
681         <xsl:value-of select="$explicit.table.width"/>
682       </xsl:when>
683       <xsl:when test="$default.table.width = ''">
684         <xsl:text>100%</xsl:text>
685       </xsl:when>
686       <xsl:otherwise>
687         <xsl:value-of select="$default.table.width"/>
688       </xsl:otherwise>
689     </xsl:choose>
690   </xsl:variable>
691
692   <fo:table id="{$id}" xsl:use-attribute-sets="normal.para.spacing">
693
694     <xsl:choose>
695       <xsl:when test="$axf.extensions != 0 or $xep.extensions != 0">
696         <xsl:attribute name="table-layout">auto</xsl:attribute>
697         <xsl:if test="$explicit.table.width != ''">
698           <xsl:attribute name="width"><xsl:value-of 
699           select="$explicit.table.width"/></xsl:attribute>
700         </xsl:if>
701       </xsl:when>
702       <xsl:otherwise>
703         <xsl:attribute name="table-layout">fixed</xsl:attribute>
704         <xsl:attribute name="width"><xsl:value-of 
705                                       select="$table.width"/></xsl:attribute>
706       </xsl:otherwise>
707     </xsl:choose>
708
709     <xsl:call-template name="simplelist.table.columns">
710       <xsl:with-param name="cols">
711         <xsl:choose>
712           <xsl:when test="@columns">
713             <xsl:value-of select="@columns"/>
714           </xsl:when>
715           <xsl:otherwise>1</xsl:otherwise>
716         </xsl:choose>
717       </xsl:with-param>
718     </xsl:call-template>
719     <fo:table-body start-indent="0pt" end-indent="0pt">
720       <xsl:call-template name="simplelist.vert">
721         <xsl:with-param name="cols">
722           <xsl:choose>
723             <xsl:when test="@columns">
724               <xsl:value-of select="@columns"/>
725             </xsl:when>
726             <xsl:otherwise>1</xsl:otherwise>
727           </xsl:choose>
728         </xsl:with-param>
729       </xsl:call-template>
730     </fo:table-body>
731   </fo:table>
732 </xsl:template>
733
734 <xsl:template match="simplelist[@type='inline']">
735   <!-- if dbchoice PI exists, use that to determine the choice separator -->
736   <!-- (that is, equivalent of "and" or "or" in current locale), or literal -->
737   <!-- value of "choice" otherwise -->
738   <xsl:variable name="id">
739     <xsl:call-template name="object.id"/>
740   </xsl:variable>
741
742   <fo:inline id="{$id}"><xsl:variable name="localized-choice-separator">
743     <xsl:choose>
744       <xsl:when test="processing-instruction('dbchoice')">
745         <xsl:call-template name="select.choice.separator"/>
746       </xsl:when>
747       <xsl:otherwise>
748         <!-- empty -->
749       </xsl:otherwise>
750     </xsl:choose>
751   </xsl:variable>
752
753   <xsl:for-each select="member">
754     <xsl:apply-templates/>
755     <xsl:choose>
756       <xsl:when test="position() = last()"/> <!-- do nothing -->
757       <xsl:otherwise>
758         <xsl:text>, </xsl:text>
759         <xsl:if test="position() = last() - 1">
760           <xsl:if test="$localized-choice-separator != ''">
761             <xsl:value-of select="$localized-choice-separator"/>
762             <xsl:text> </xsl:text>
763           </xsl:if>
764         </xsl:if>
765       </xsl:otherwise>
766     </xsl:choose>
767   </xsl:for-each></fo:inline>
768 </xsl:template>
769
770 <xsl:template match="simplelist[@type='horiz']">
771
772   <xsl:variable name="id">
773     <xsl:call-template name="object.id"/>
774   </xsl:variable>
775
776   <xsl:variable name="explicit.table.width">
777     <xsl:call-template name="pi.dbfo_list-width"/>
778   </xsl:variable>
779
780   <xsl:variable name="table.width">
781     <xsl:choose>
782       <xsl:when test="$explicit.table.width != ''">
783         <xsl:value-of select="$explicit.table.width"/>
784       </xsl:when>
785       <xsl:when test="$default.table.width = ''">
786         <xsl:text>100%</xsl:text>
787       </xsl:when>
788       <xsl:otherwise>
789         <xsl:value-of select="$default.table.width"/>
790       </xsl:otherwise>
791     </xsl:choose>
792   </xsl:variable>
793
794   <fo:table id="{$id}" xsl:use-attribute-sets="normal.para.spacing">
795     <xsl:choose>
796       <xsl:when test="$axf.extensions != 0 or $xep.extensions != 0">
797         <xsl:attribute name="table-layout">auto</xsl:attribute>
798         <xsl:if test="$explicit.table.width != ''">
799           <xsl:attribute name="width"><xsl:value-of 
800                              select="$explicit.table.width"/></xsl:attribute>
801         </xsl:if>
802       </xsl:when>
803       <xsl:otherwise>
804         <xsl:attribute name="table-layout">fixed</xsl:attribute>
805         <xsl:attribute name="width"><xsl:value-of 
806                                       select="$table.width"/></xsl:attribute>
807       </xsl:otherwise>
808     </xsl:choose>
809     <xsl:call-template name="simplelist.table.columns">
810       <xsl:with-param name="cols">
811         <xsl:choose>
812           <xsl:when test="@columns">
813             <xsl:value-of select="@columns"/>
814           </xsl:when>
815           <xsl:otherwise>1</xsl:otherwise>
816         </xsl:choose>
817       </xsl:with-param>
818     </xsl:call-template>
819     <fo:table-body start-indent="0pt" end-indent="0pt">
820       <xsl:call-template name="simplelist.horiz">
821         <xsl:with-param name="cols">
822           <xsl:choose>
823             <xsl:when test="@columns">
824               <xsl:value-of select="@columns"/>
825             </xsl:when>
826             <xsl:otherwise>1</xsl:otherwise>
827           </xsl:choose>
828         </xsl:with-param>
829       </xsl:call-template>
830     </fo:table-body>
831   </fo:table>
832 </xsl:template>
833
834 <xsl:template name="simplelist.table.columns">
835   <xsl:param name="cols" select="1"/>
836   <xsl:param name="curcol" select="1"/>
837   <fo:table-column column-number="{$curcol}"
838                    column-width="proportional-column-width(1)"/>
839   <xsl:if test="$curcol &lt; $cols">
840     <xsl:call-template name="simplelist.table.columns">
841       <xsl:with-param name="cols" select="$cols"/>
842       <xsl:with-param name="curcol" select="$curcol + 1"/>
843     </xsl:call-template>
844   </xsl:if>
845 </xsl:template>
846
847 <xsl:template name="simplelist.horiz">
848   <xsl:param name="cols">1</xsl:param>
849   <xsl:param name="cell">1</xsl:param>
850   <xsl:param name="members" select="./member"/>
851
852   <xsl:if test="$cell &lt;= count($members)">
853     <fo:table-row>
854       <xsl:call-template name="simplelist.horiz.row">
855         <xsl:with-param name="cols" select="$cols"/>
856         <xsl:with-param name="cell" select="$cell"/>
857         <xsl:with-param name="members" select="$members"/>
858       </xsl:call-template>
859    </fo:table-row>
860     <xsl:call-template name="simplelist.horiz">
861       <xsl:with-param name="cols" select="$cols"/>
862       <xsl:with-param name="cell" select="$cell + $cols"/>
863       <xsl:with-param name="members" select="$members"/>
864     </xsl:call-template>
865   </xsl:if>
866 </xsl:template>
867
868 <xsl:template name="simplelist.horiz.row">
869   <xsl:param name="cols">1</xsl:param>
870   <xsl:param name="cell">1</xsl:param>
871   <xsl:param name="members" select="./member"/>
872   <xsl:param name="curcol">1</xsl:param>
873
874   <xsl:if test="$curcol &lt;= $cols">
875     <fo:table-cell>
876       <fo:block>
877         <xsl:if test="$members[position()=$cell]">
878           <xsl:apply-templates select="$members[position()=$cell]"/>
879         </xsl:if>
880       </fo:block>
881     </fo:table-cell>
882     <xsl:call-template name="simplelist.horiz.row">
883       <xsl:with-param name="cols" select="$cols"/>
884       <xsl:with-param name="cell" select="$cell+1"/>
885       <xsl:with-param name="members" select="$members"/>
886       <xsl:with-param name="curcol" select="$curcol+1"/>
887     </xsl:call-template>
888   </xsl:if>
889 </xsl:template>
890
891 <xsl:template name="simplelist.vert">
892   <xsl:param name="cols">1</xsl:param>
893   <xsl:param name="cell">1</xsl:param>
894   <xsl:param name="members" select="./member"/>
895   <xsl:param name="rows"
896              select="floor((count($members)+$cols - 1) div $cols)"/>
897
898   <xsl:if test="$cell &lt;= $rows">
899     <fo:table-row>
900       <xsl:call-template name="simplelist.vert.row">
901         <xsl:with-param name="cols" select="$cols"/>
902         <xsl:with-param name="rows" select="$rows"/>
903         <xsl:with-param name="cell" select="$cell"/>
904         <xsl:with-param name="members" select="$members"/>
905       </xsl:call-template>
906    </fo:table-row>
907     <xsl:call-template name="simplelist.vert">
908       <xsl:with-param name="cols" select="$cols"/>
909       <xsl:with-param name="cell" select="$cell+1"/>
910       <xsl:with-param name="members" select="$members"/>
911       <xsl:with-param name="rows" select="$rows"/>
912     </xsl:call-template>
913   </xsl:if>
914 </xsl:template>
915
916 <xsl:template name="simplelist.vert.row">
917   <xsl:param name="cols">1</xsl:param>
918   <xsl:param name="rows">1</xsl:param>
919   <xsl:param name="cell">1</xsl:param>
920   <xsl:param name="members" select="./member"/>
921   <xsl:param name="curcol">1</xsl:param>
922
923   <xsl:if test="$curcol &lt;= $cols">
924     <fo:table-cell>
925       <fo:block>
926         <xsl:if test="$members[position()=$cell]">
927           <xsl:apply-templates select="$members[position()=$cell]"/>
928         </xsl:if>
929       </fo:block>
930     </fo:table-cell>
931     <xsl:call-template name="simplelist.vert.row">
932       <xsl:with-param name="cols" select="$cols"/>
933       <xsl:with-param name="rows" select="$rows"/>
934       <xsl:with-param name="cell" select="$cell+$rows"/>
935       <xsl:with-param name="members" select="$members"/>
936       <xsl:with-param name="curcol" select="$curcol+1"/>
937     </xsl:call-template>
938   </xsl:if>
939 </xsl:template>
940
941 <xsl:template match="member">
942   <xsl:call-template name="simple.xlink">
943     <xsl:with-param name="content">
944       <xsl:apply-templates/>
945     </xsl:with-param>
946   </xsl:call-template>
947 </xsl:template>
948
949 <!-- ==================================================================== -->
950
951 <xsl:template match="procedure">
952   <xsl:variable name="id">
953     <xsl:call-template name="object.id"/>
954   </xsl:variable>
955
956   <xsl:variable name="param.placement"
957                 select="substring-after(normalize-space($formal.title.placement),
958                                         concat(local-name(.), ' '))"/>
959
960   <xsl:variable name="placement">
961     <xsl:choose>
962       <xsl:when test="contains($param.placement, ' ')">
963         <xsl:value-of select="substring-before($param.placement, ' ')"/>
964       </xsl:when>
965       <xsl:when test="$param.placement = ''">before</xsl:when>
966       <xsl:otherwise>
967         <xsl:value-of select="$param.placement"/>
968       </xsl:otherwise>
969     </xsl:choose>
970   </xsl:variable>
971
972   <!-- Preserve order of PIs and comments -->
973   <xsl:variable name="preamble"
974         select="*[not(self::step
975                   or self::title
976                   or self::titleabbrev)]
977                 |comment()[not(preceding-sibling::step)]
978                 |processing-instruction()[not(preceding-sibling::step)]"/>
979
980   <xsl:variable name="steps" 
981                 select="step
982                         |comment()[preceding-sibling::step]
983                         |processing-instruction()[preceding-sibling::step]"/>
984
985   <fo:block id="{$id}" xsl:use-attribute-sets="procedure.properties list.block.spacing">
986     <xsl:if test="./title and $placement = 'before'">
987       <!-- n.b. gentext code tests for $formal.procedures and may make an "informal" -->
988       <!-- heading even though we called formal.object.heading. odd but true. -->
989       <xsl:call-template name="formal.object.heading"/>
990     </xsl:if>
991
992     <xsl:apply-templates select="$preamble"/>
993
994     <fo:list-block xsl:use-attribute-sets="list.block.spacing"
995                    provisional-distance-between-starts="2em"
996                    provisional-label-separation="0.2em">
997       <xsl:apply-templates select="$steps"/>
998     </fo:list-block>
999
1000     <xsl:if test="./title and $placement != 'before'">
1001       <!-- n.b. gentext code tests for $formal.procedures and may make an "informal" -->
1002       <!-- heading even though we called formal.object.heading. odd but true. -->
1003       <xsl:call-template name="formal.object.heading"/>
1004     </xsl:if>
1005   </fo:block>
1006 </xsl:template>
1007
1008 <xsl:template match="procedure/title">
1009 </xsl:template>
1010
1011 <xsl:template match="substeps">
1012   <fo:list-block xsl:use-attribute-sets="list.block.spacing"
1013                  provisional-distance-between-starts="2em"
1014                  provisional-label-separation="0.2em">
1015     <xsl:apply-templates/>
1016   </fo:list-block>
1017 </xsl:template>
1018
1019 <xsl:template match="procedure/step|substeps/step">
1020   <xsl:variable name="id">
1021     <xsl:call-template name="object.id"/>
1022   </xsl:variable>
1023
1024   <xsl:variable name="keep.together">
1025     <xsl:call-template name="pi.dbfo_keep-together"/>
1026   </xsl:variable>
1027
1028   <fo:list-item xsl:use-attribute-sets="list.item.spacing">
1029     <xsl:if test="$keep.together != ''">
1030       <xsl:attribute name="keep-together.within-column"><xsl:value-of
1031                       select="$keep.together"/></xsl:attribute>
1032     </xsl:if>
1033     <fo:list-item-label end-indent="label-end()">
1034       <fo:block id="{$id}">
1035         <!-- dwc: fix for one step procedures. Use a bullet if there's no step 2 -->
1036         <xsl:choose>
1037           <xsl:when test="count(../step) = 1">
1038             <xsl:text>&#x2022;</xsl:text>
1039           </xsl:when>
1040           <xsl:otherwise>
1041             <xsl:apply-templates select="." mode="number">
1042               <xsl:with-param name="recursive" select="0"/>
1043             </xsl:apply-templates>.
1044           </xsl:otherwise>
1045         </xsl:choose>
1046       </fo:block>
1047     </fo:list-item-label>
1048     <fo:list-item-body start-indent="body-start()">
1049       <fo:block>
1050         <xsl:apply-templates/>
1051       </fo:block>
1052     </fo:list-item-body>
1053   </fo:list-item>
1054 </xsl:template>
1055
1056 <xsl:template match="stepalternatives">
1057   <fo:list-block provisional-distance-between-starts="2em"
1058                  provisional-label-separation="0.2em">
1059     <xsl:apply-templates select="step"/>
1060   </fo:list-block>
1061 </xsl:template>
1062
1063 <xsl:template match="stepalternatives/step">
1064   <xsl:variable name="id">
1065     <xsl:call-template name="object.id"/>
1066   </xsl:variable>
1067
1068   <xsl:variable name="keep.together">
1069     <xsl:call-template name="pi.dbfo_keep-together"/>
1070   </xsl:variable>
1071
1072   <fo:list-item xsl:use-attribute-sets="list.item.spacing">
1073     <xsl:if test="$keep.together != ''">
1074       <xsl:attribute name="keep-together.within-column"><xsl:value-of
1075                       select="$keep.together"/></xsl:attribute>
1076     </xsl:if>
1077     <fo:list-item-label end-indent="label-end()">
1078       <fo:block id="{$id}">
1079         <xsl:text>&#x2022;</xsl:text>
1080       </fo:block>
1081     </fo:list-item-label>
1082     <fo:list-item-body start-indent="body-start()">
1083       <fo:block>
1084         <xsl:apply-templates/>
1085       </fo:block>
1086     </fo:list-item-body>
1087   </fo:list-item>
1088 </xsl:template>
1089
1090 <xsl:template match="step/title">
1091   <fo:block font-weight="bold"
1092             keep-together.within-column="always" 
1093             keep-with-next.within-column="always">
1094     <xsl:apply-templates/>
1095   </fo:block>
1096 </xsl:template>
1097
1098 <!-- ==================================================================== -->
1099
1100 <xsl:template match="segmentedlist">
1101   <xsl:variable name="presentation">
1102     <xsl:call-template name="pi.dbfo_list-presentation"/>
1103   </xsl:variable>
1104
1105   <xsl:variable name="keep.together">
1106     <xsl:call-template name="pi.dbfo_keep-together"/>
1107   </xsl:variable>
1108
1109   <xsl:variable name="id">
1110     <xsl:call-template name="object.id"/>
1111   </xsl:variable>
1112
1113   <xsl:choose>
1114     <xsl:when test="$presentation = 'table'">
1115       <fo:block id="{$id}">
1116         <xsl:if test="$keep.together != ''">
1117           <xsl:attribute name="keep-together.within-column"><xsl:value-of
1118                           select="$keep.together"/></xsl:attribute>
1119         </xsl:if>
1120         <xsl:apply-templates select="." mode="seglist-table"/>
1121       </fo:block>
1122     </xsl:when>
1123     <xsl:when test="$presentation = 'list'">
1124       <fo:block id="{$id}">
1125         <xsl:if test="$keep.together != ''">
1126           <xsl:attribute name="keep-together.within-column"><xsl:value-of
1127                           select="$keep.together"/></xsl:attribute>
1128         </xsl:if>
1129         <xsl:apply-templates/>
1130       </fo:block>
1131     </xsl:when>
1132     <xsl:when test="$segmentedlist.as.table != 0">
1133       <fo:block id="{$id}">
1134         <xsl:if test="$keep.together != ''">
1135           <xsl:attribute name="keep-together.within-column"><xsl:value-of
1136                           select="$keep.together"/></xsl:attribute>
1137         </xsl:if>
1138         <xsl:apply-templates select="." mode="seglist-table"/>
1139       </fo:block>
1140     </xsl:when>
1141     <xsl:otherwise>
1142       <fo:block id="{$id}">
1143         <xsl:if test="$keep.together != ''">
1144           <xsl:attribute name="keep-together.within-column"><xsl:value-of
1145                           select="$keep.together"/></xsl:attribute>
1146         </xsl:if>
1147
1148         <xsl:apply-templates/>
1149       </fo:block>
1150     </xsl:otherwise>
1151   </xsl:choose>
1152 </xsl:template>
1153
1154 <xsl:template match="segmentedlist/title">
1155   <xsl:apply-templates select="." mode="list.title.mode" />
1156 </xsl:template>
1157
1158 <xsl:template match="segtitle">
1159 </xsl:template>
1160
1161 <xsl:template match="segtitle" mode="segtitle-in-seg">
1162   <xsl:apply-templates/>
1163 </xsl:template>
1164
1165 <xsl:template match="seglistitem">
1166   <xsl:variable name="id">
1167     <xsl:call-template name="object.id"/>
1168   </xsl:variable>
1169   <fo:block id="{$id}">
1170     <xsl:apply-templates/>
1171   </fo:block>
1172 </xsl:template>
1173
1174 <xsl:template match="seg">
1175   <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
1176   <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
1177   <xsl:variable name="segtitles" select="$seglist/segtitle"/>
1178
1179   <!--
1180      Note: segtitle is only going to be the right thing in a well formed
1181      SegmentedList.  If there are too many Segs or too few SegTitles,
1182      you'll get something odd...maybe an error
1183   -->
1184
1185   <fo:block>
1186     <fo:inline font-weight="bold">
1187       <xsl:apply-templates select="$segtitles[$segnum=position()]"
1188                            mode="segtitle-in-seg"/>
1189       <xsl:text>: </xsl:text>
1190     </fo:inline>
1191     <xsl:apply-templates/>
1192   </fo:block>
1193 </xsl:template>
1194
1195 <xsl:template match="segmentedlist" mode="seglist-table">
1196   <xsl:apply-templates select="title" mode="list.title.mode" />
1197   <fo:table>
1198     <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
1199     <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
1200     <fo:table-header start-indent="0pt" end-indent="0pt">
1201       <fo:table-row>
1202         <xsl:apply-templates select="segtitle" mode="seglist-table"/>
1203       </fo:table-row>
1204     </fo:table-header>
1205     <fo:table-body start-indent="0pt" end-indent="0pt">
1206       <xsl:apply-templates select="seglistitem" mode="seglist-table"/>
1207     </fo:table-body>
1208   </fo:table>
1209 </xsl:template>
1210
1211 <xsl:template match="segtitle" mode="seglist-table">
1212   <fo:table-cell>
1213     <fo:block font-weight="bold">
1214       <xsl:apply-templates/>
1215     </fo:block>
1216   </fo:table-cell>
1217 </xsl:template>
1218
1219 <xsl:template match="seglistitem" mode="seglist-table">
1220   <xsl:variable name="id">
1221     <xsl:call-template name="object.id"/>
1222   </xsl:variable>
1223   <fo:table-row id="{$id}">
1224     <xsl:apply-templates mode="seglist-table"/>
1225   </fo:table-row>
1226 </xsl:template>
1227
1228 <xsl:template match="seg" mode="seglist-table">
1229   <fo:table-cell>
1230     <fo:block>
1231       <xsl:apply-templates/>
1232     </fo:block>
1233   </fo:table-cell>
1234 </xsl:template>
1235
1236 <!-- ==================================================================== -->
1237
1238 <xsl:template match="calloutlist">
1239   <xsl:variable name="id">
1240   <xsl:call-template name="object.id"/>
1241   </xsl:variable>
1242
1243   <xsl:variable name="pi-label-width">
1244     <xsl:call-template name="pi.dbfo_label-width"/>
1245   </xsl:variable>
1246
1247   <fo:block id="{$id}"
1248             text-align="{$alignment}">
1249     <!-- The above restores alignment altered by image align attribute -->
1250     <xsl:if test="title|info/title">
1251       <xsl:apply-templates select="(title|info/title)[1]" 
1252                            mode="list.title.mode"/>
1253     </xsl:if>
1254
1255     <!-- Preserve order of PIs and comments -->
1256     <xsl:apply-templates 
1257          select="*[not(self::callout or self::title or self::titleabbrev)]
1258                    |comment()[not(preceding-sibling::callout)]
1259                    |processing-instruction()[not(preceding-sibling::callout)]"/>
1260
1261     <fo:list-block space-before.optimum="1em"
1262                    space-before.minimum="0.8em"
1263                    space-before.maximum="1.2em"
1264                    provisional-distance-between-starts="2.2em"
1265                    provisional-label-separation="0.2em">
1266
1267       <xsl:if test="$pi-label-width != ''">
1268               <xsl:attribute name="provisional-distance-between-starts">
1269           <xsl:value-of select="$pi-label-width"/>
1270         </xsl:attribute>
1271       </xsl:if>
1272       
1273       <xsl:apply-templates select="callout
1274                                 |comment()[preceding-sibling::callout]
1275                                 |processing-instruction()[preceding-sibling::callout]"/>
1276     </fo:list-block>
1277   </fo:block>
1278 </xsl:template>
1279
1280 <xsl:template match="calloutlist/title">
1281 </xsl:template>
1282
1283 <xsl:template match="callout">
1284   <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
1285
1286   <xsl:variable name="keep.together">
1287     <xsl:call-template name="pi.dbfo_keep-together"/>
1288   </xsl:variable>
1289
1290   <fo:list-item id="{$id}">
1291     <xsl:if test="$keep.together != ''">
1292       <xsl:attribute name="keep-together.within-column"><xsl:value-of
1293                       select="$keep.together"/></xsl:attribute>
1294     </xsl:if>
1295     <fo:list-item-label end-indent="label-end()">
1296       <fo:block>
1297         <xsl:call-template name="callout.arearefs">
1298           <xsl:with-param name="arearefs" select="@arearefs"/>
1299         </xsl:call-template>
1300       </fo:block>
1301     </fo:list-item-label>
1302     <fo:list-item-body start-indent="body-start()">
1303       <fo:block>
1304         <xsl:apply-templates/>
1305       </fo:block>
1306     </fo:list-item-body>
1307   </fo:list-item>
1308 </xsl:template>
1309
1310 <xsl:template name="callout.arearefs">
1311   <xsl:param name="arearefs"></xsl:param>
1312   <xsl:if test="$arearefs!=''">
1313     <xsl:choose>
1314       <xsl:when test="substring-before($arearefs,' ')=''">
1315         <xsl:call-template name="callout.arearef">
1316           <xsl:with-param name="arearef" select="$arearefs"/>
1317         </xsl:call-template>
1318       </xsl:when>
1319       <xsl:otherwise>
1320         <xsl:call-template name="callout.arearef">
1321           <xsl:with-param name="arearef"
1322                           select="substring-before($arearefs,' ')"/>
1323         </xsl:call-template>
1324       </xsl:otherwise>
1325     </xsl:choose>
1326     <xsl:call-template name="callout.arearefs">
1327       <xsl:with-param name="arearefs"
1328                       select="substring-after($arearefs,' ')"/>
1329     </xsl:call-template>
1330   </xsl:if>
1331 </xsl:template>
1332
1333 <xsl:template name="callout.arearef">
1334   <xsl:param name="arearef"></xsl:param>
1335   <xsl:variable name="targets" select="key('id',$arearef)"/>
1336   <xsl:variable name="target" select="$targets[1]"/>
1337
1338   <xsl:choose>
1339     <xsl:when test="count($target)=0">
1340       <xsl:value-of select="$arearef"/>
1341       <xsl:text>: ???</xsl:text>
1342     </xsl:when>
1343     <xsl:when test="local-name($target)='co'">
1344       <xsl:apply-templates select="$target" mode="callout-bug"/>
1345     </xsl:when>
1346     <xsl:when test="local-name($target)='areaset'">
1347       <xsl:call-template name="callout-bug">
1348         <xsl:with-param name="conum">
1349           <xsl:apply-templates select="$target" mode="conumber"/>
1350         </xsl:with-param>
1351       </xsl:call-template>
1352     </xsl:when>
1353     <xsl:when test="local-name($target)='area'">
1354       <xsl:choose>
1355         <xsl:when test="$target/parent::areaset">
1356           <xsl:call-template name="callout-bug">
1357             <xsl:with-param name="conum">
1358               <xsl:apply-templates select="$target/parent::areaset"
1359                                    mode="conumber"/>
1360             </xsl:with-param>
1361           </xsl:call-template>
1362         </xsl:when>
1363         <xsl:otherwise>
1364           <xsl:call-template name="callout-bug">
1365             <xsl:with-param name="conum">
1366               <xsl:apply-templates select="$target" mode="conumber"/>
1367             </xsl:with-param>
1368           </xsl:call-template>
1369         </xsl:otherwise>
1370       </xsl:choose>
1371     </xsl:when>
1372     <xsl:otherwise>
1373       <xsl:text>???</xsl:text>
1374     </xsl:otherwise>
1375   </xsl:choose>
1376 </xsl:template>
1377
1378 <!-- ==================================================================== -->
1379
1380 <xsl:template name="orderedlist-starting-number">
1381   <xsl:param name="list" select="."/>
1382   <xsl:variable name="pi-start">
1383     <xsl:call-template name="pi.dbfo_start">
1384       <xsl:with-param name="node" select="$list"/>
1385     </xsl:call-template>
1386   </xsl:variable>
1387   <xsl:call-template name="output-orderedlist-starting-number">
1388     <xsl:with-param name="list" select="$list"/>
1389     <xsl:with-param name="pi-start" select="$pi-start"/>
1390   </xsl:call-template>
1391 </xsl:template>
1392
1393 </xsl:stylesheet>