1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                version='1.0'>
4
5<!-- ********************************************************************
6     $Id$
7     ********************************************************************
8
9     This file is part of the XSL DocBook Stylesheet distribution.
10     See /README or http://nwalsh.com/docbook/xsl/ for copyright
11     and other information.
12
13     ******************************************************************** -->
14
15<!-- ==================================================================== -->
16
17<xsl:template match="itemizedlist">
18  <div class="{name(.)}">
19    <xsl:if test="title">
20      <xsl:apply-templates select="title"/>
21    </xsl:if>
22    <ul>
23      <xsl:if test="@spacing='compact'">
24        <xsl:attribute name="compact">
25          <xsl:value-of select="@spacing"/>
26        </xsl:attribute>
27      </xsl:if>
28      <xsl:apply-templates select="listitem"/>
29    </ul>
30  </div>
31</xsl:template>
32
33<xsl:template match="itemizedlist/title">
34  <p><b><xsl:apply-templates/></b></p>
35</xsl:template>
36
37<xsl:template name="orderedlist-starting-number">
38  <xsl:param name="list" select="."/>
39  <xsl:choose>
40    <xsl:when test="$list/@continuation != 'continues'">1</xsl:when>
41    <xsl:otherwise>
42      <xsl:variable name="prevlist"
43                    select="$list/preceding::orderedlist[1]"/>
44      <xsl:choose>
45        <xsl:when test="count($prevlist) = 0">2</xsl:when>
46        <xsl:otherwise>
47          <xsl:variable name="prevlength" select="count($prevlist/listitem)"/>
48          <xsl:variable name="prevstart">
49            <xsl:call-template name="orderedlist-starting-number">
50              <xsl:with-param name="list" select="$prevlist"/>
51            </xsl:call-template>
52          </xsl:variable>
53          <xsl:value-of select="$prevstart + $prevlength"/>
54        </xsl:otherwise>
55      </xsl:choose>
56    </xsl:otherwise>
57  </xsl:choose>
58</xsl:template>
59
60<xsl:template match="orderedlist">
61  <xsl:variable name="start">
62    <xsl:choose>
63      <xsl:when test="@continuation='continues'">
64        <xsl:call-template name="orderedlist-starting-number"/>
65      </xsl:when>
66      <xsl:otherwise>1</xsl:otherwise>
67    </xsl:choose>
68  </xsl:variable>
69  <xsl:variable name="numeration">
70    <xsl:choose>
71      <xsl:when test="@numeration='arabic'">1</xsl:when>
72      <xsl:when test="@numeration='loweralpha'">a</xsl:when>
73      <xsl:when test="@numeration='lowerroman'">i</xsl:when>
74      <xsl:when test="@numeration='upperalpha'">A</xsl:when>
75      <xsl:when test="@numeration='upperroman'">I</xsl:when>
76      <xsl:otherwise>
77        <!-- alternate the numeration based on depth -->
78        <xsl:variable name="depth" select="count(ancestor::orderedlist)"/>
79        <xsl:variable name="type" select="$depth mod 5"/>
80        <xsl:choose>
81          <xsl:when test="$type = 0">1</xsl:when>
82          <xsl:when test="$type = 1">a</xsl:when>
83          <xsl:when test="$type = 2">i</xsl:when>
84          <xsl:when test="$type = 3">A</xsl:when>
85          <xsl:when test="$type = 4">I</xsl:when>
86        </xsl:choose>
87      </xsl:otherwise>
88    </xsl:choose>
89  </xsl:variable>
90  <div class="{name(.)}">
91    <xsl:if test="title">
92      <xsl:apply-templates select="title"/>
93    </xsl:if>
94    <ol>
95    <xsl:if test="$start != '1'">
96      <xsl:attribute name="start">
97        <xsl:value-of select="$start"/>
98      </xsl:attribute>
99    </xsl:if>
100    <xsl:if test="$numeration != ''">
101      <xsl:attribute name="type">
102	<xsl:value-of select="$numeration"/>
103      </xsl:attribute>
104    </xsl:if>
105    <xsl:if test="@spacing='compact'">
106      <xsl:attribute name="compact">
107	<xsl:value-of select="compact"/>
108      </xsl:attribute>
109    </xsl:if>
110    <xsl:apply-templates select="listitem"/>
111    </ol>
112  </div>
113</xsl:template>
114
115<xsl:template match="orderedlist/title">
116  <p><b><xsl:apply-templates/></b></p>
117</xsl:template>
118
119<xsl:template match="variablelist">
120  <div class="{name(.)}">
121    <xsl:if test="title">
122      <xsl:apply-templates select="title"/>
123    </xsl:if>
124    <dl>
125    <xsl:apply-templates select="varlistentry"/>
126    </dl>
127  </div>
128</xsl:template>
129
130<xsl:template match="variablelist/title">
131  <p><b><xsl:apply-templates/></b></p>
132</xsl:template>
133
134<xsl:template match="listitem">
135  <xsl:variable name="id">
136    <xsl:call-template name="object.id"/>
137  </xsl:variable>
138  <xsl:variable name="mark" select="ancestor-or-self::*/@mark"/>
139  <xsl:variable name="override" select="@override"/>
140
141  <xsl:variable name="usemark">
142    <xsl:choose>
143      <xsl:when test="$override != ''">
144	<xsl:value-of select="$override"/>
145      </xsl:when>
146      <xsl:otherwise>
147	<xsl:value-of select="$mark"/>
148      </xsl:otherwise>
149    </xsl:choose>
150  </xsl:variable>
151  <xsl:variable name="cssmark">
152    <xsl:choose>
153      <xsl:when test="$usemark = 'bullet'">disc</xsl:when>
154      <xsl:when test="$usemark = 'box'">square</xsl:when>
155      <xsl:otherwise>
156	<xsl:value-of select="$usemark"/>
157      </xsl:otherwise>
158    </xsl:choose>
159  </xsl:variable>
160
161  <li>
162    <xsl:if test="$css.decoration = '1' and $cssmark != ''">
163      <xsl:attribute name="style">
164	<xsl:text>list-style-type: </xsl:text>
165	<xsl:value-of select="$cssmark"/>
166      </xsl:attribute>
167    </xsl:if>
168
169    <!-- we can't just drop the anchor in since some browsers (Opera)
170         get confused about line breaks if we do. So if the first child
171         is a para, assume the para will put in the anchor. Otherwise,
172         put the anchor in anyway. -->
173    <xsl:if test="local-name(child::*[1]) != 'para'">
174      <a name="{$id}"/>
175    </xsl:if>
176
177    <xsl:choose>
178      <xsl:when test="$show.revisionflag and @revisionflag">
179	<div class="{@revisionflag}">
180	  <xsl:apply-templates/>
181	</div>
182      </xsl:when>
183      <xsl:otherwise>
184	<xsl:apply-templates/>
185      </xsl:otherwise>
186    </xsl:choose>
187  </li>
188</xsl:template>
189
190<xsl:template match="listitem" mode="xref">
191  <xsl:number format="1"/>
192</xsl:template>
193
194<xsl:template match="varlistentry">
195  <xsl:variable name="id">
196    <xsl:call-template name="object.id"/>
197  </xsl:variable>
198  <dt><a name="{$id}"/><xsl:apply-templates select="term"/></dt>
199  <dd><xsl:apply-templates select="listitem"/></dd>
200</xsl:template>
201
202<xsl:template match="varlistentry/term">
203  <span class="term"><xsl:apply-templates/>, </span>
204</xsl:template>
205
206<xsl:template match="varlistentry/term[position()=last()]" priority="2">
207  <span class="term"><xsl:apply-templates/></span>
208</xsl:template>
209
210<xsl:template match="varlistentry/listitem">
211  <xsl:choose>
212    <xsl:when test="$show.revisionflag and @revisionflag">
213      <div class="{@revisionflag}">
214	<xsl:apply-templates/>
215      </div>
216    </xsl:when>
217    <xsl:otherwise>
218      <xsl:apply-templates/>
219    </xsl:otherwise>
220  </xsl:choose>
221</xsl:template>
222
223
224<!-- ==================================================================== -->
225
226<xsl:template match="simplelist">
227  <!-- with no type specified, the default is 'vert' -->
228  <table class="simplelist" border="0" summary="Simple list">
229    <xsl:call-template name="simplelist.vert">
230      <xsl:with-param name="cols">
231	<xsl:choose>
232	  <xsl:when test="@columns">
233	    <xsl:value-of select="@columns"/>
234	  </xsl:when>
235	  <xsl:otherwise>1</xsl:otherwise>
236	</xsl:choose>
237      </xsl:with-param>
238    </xsl:call-template>
239  </table>
240</xsl:template>
241
242<xsl:template match="simplelist[@type='inline']">
243  <span class="{name(.)}"><xsl:apply-templates/></span>
244</xsl:template>
245
246<xsl:template match="simplelist[@type='horiz']">
247  <table class="simplelist" border="0" summary="Simple list">
248    <xsl:call-template name="simplelist.horiz">
249      <xsl:with-param name="cols">
250        <xsl:choose>
251          <xsl:when test="@columns">
252            <xsl:value-of select="@columns"/>
253          </xsl:when>
254          <xsl:otherwise>1</xsl:otherwise>
255        </xsl:choose>
256      </xsl:with-param>
257    </xsl:call-template>
258  </table>
259</xsl:template>
260
261<xsl:template match="simplelist[@type='vert']">
262  <table class="simplelist" border="0" summary="Simple list">
263    <xsl:call-template name="simplelist.vert">
264      <xsl:with-param name="cols">
265        <xsl:choose>
266          <xsl:when test="@columns">
267            <xsl:value-of select="@columns"/>
268          </xsl:when>
269          <xsl:otherwise>1</xsl:otherwise>
270        </xsl:choose>
271      </xsl:with-param>
272    </xsl:call-template>
273  </table>
274</xsl:template>
275
276<xsl:template name="simplelist.horiz">
277  <xsl:param name="cols">1</xsl:param>
278  <xsl:param name="cell">1</xsl:param>
279  <xsl:param name="members" select="/member"/>
280
281  <xsl:if test="$cell &lt;= count($members)">
282    <tr>
283      <xsl:call-template name="simplelist.horiz.row">
284        <xsl:with-param name="cols" select="$cols"/>
285        <xsl:with-param name="cell" select="$cell"/>
286        <xsl:with-param name="members" select="$members"/>
287      </xsl:call-template>
288   </tr>
289    <xsl:call-template name="simplelist.horiz">
290      <xsl:with-param name="cols" select="$cols"/>
291      <xsl:with-param name="cell" select="$cell + $cols"/>
292      <xsl:with-param name="members" select="$members"/>
293    </xsl:call-template>
294  </xsl:if>
295</xsl:template>
296
297<xsl:template name="simplelist.horiz.row">
298  <xsl:param name="cols">1</xsl:param>
299  <xsl:param name="cell">1</xsl:param>
300  <xsl:param name="members" select="/member"/>
301  <xsl:param name="curcol">1</xsl:param>
302
303  <xsl:if test="$curcol &lt;= $cols">
304    <td>
305      <xsl:choose>
306        <xsl:when test="$members[position()=$cell]">
307          <xsl:apply-templates select="$members[position()=$cell]"/>
308        </xsl:when>
309        <xsl:otherwise>
310          <xsl:choose>
311            <xsl:when test="$using.chunker != 0">
312              <xsl:text>&#160;</xsl:text>
313            </xsl:when>
314            <xsl:otherwise>
315              <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
316            </xsl:otherwise>
317          </xsl:choose>
318        </xsl:otherwise>
319      </xsl:choose>
320    </td>
321    <xsl:call-template name="simplelist.horiz.row">
322      <xsl:with-param name="cols" select="$cols"/>
323      <xsl:with-param name="cell" select="$cell+1"/>
324      <xsl:with-param name="members" select="$members"/>
325      <xsl:with-param name="curcol" select="$curcol+1"/>
326    </xsl:call-template>
327  </xsl:if>
328</xsl:template>
329
330<xsl:template name="simplelist.vert">
331  <xsl:param name="cols">1</xsl:param>
332  <xsl:param name="cell">1</xsl:param>
333  <xsl:param name="members" select="/member"/>
334  <xsl:param name="rows"
335             select="floor((count($members)+$cols - 1) div $cols)"/>
336
337  <xsl:if test="$cell &lt;= $rows">
338    <tr>
339      <xsl:call-template name="simplelist.vert.row">
340	<xsl:with-param name="cols" select="$cols"/>
341	<xsl:with-param name="rows" select="$rows"/>
342	<xsl:with-param name="cell" select="$cell"/>
343	<xsl:with-param name="members" select="$members"/>
344      </xsl:call-template>
345    </tr>
346    <xsl:call-template name="simplelist.vert">
347      <xsl:with-param name="cols" select="$cols"/>
348      <xsl:with-param name="cell" select="$cell+1"/>
349      <xsl:with-param name="members" select="$members"/>
350      <xsl:with-param name="rows" select="$rows"/>
351    </xsl:call-template>
352  </xsl:if>
353</xsl:template>
354
355<xsl:template name="simplelist.vert.row">
356  <xsl:param name="cols">1</xsl:param>
357  <xsl:param name="rows">1</xsl:param>
358  <xsl:param name="cell">1</xsl:param>
359  <xsl:param name="members" select="/member"/>
360  <xsl:param name="curcol">1</xsl:param>
361
362  <xsl:if test="$curcol &lt;= $cols">
363    <td>
364      <xsl:choose>
365        <xsl:when test="$members[position()=$cell]">
366          <xsl:apply-templates select="$members[position()=$cell]"/>
367        </xsl:when>
368        <xsl:otherwise>
369          <xsl:choose>
370            <xsl:when test="$using.chunker != 0">
371              <xsl:text>&#160;</xsl:text>
372            </xsl:when>
373            <xsl:otherwise>
374              <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
375            </xsl:otherwise>
376          </xsl:choose>
377        </xsl:otherwise>
378      </xsl:choose>
379    </td>
380    <xsl:call-template name="simplelist.vert.row">
381      <xsl:with-param name="cols" select="$cols"/>
382      <xsl:with-param name="rows" select="$rows"/>
383      <xsl:with-param name="cell" select="$cell+$rows"/>
384      <xsl:with-param name="members" select="$members"/>
385      <xsl:with-param name="curcol" select="$curcol+1"/>
386    </xsl:call-template>
387  </xsl:if>
388</xsl:template>
389
390<xsl:template match="member">
391  <xsl:apply-templates/>
392</xsl:template>
393
394<xsl:template match="simplelist[@type='inline']/member">
395  <xsl:apply-templates/>
396  <xsl:text>, </xsl:text>
397</xsl:template>
398
399<xsl:template match="simplelist[@type='inline']/member[position()=last()]"
400              priority="2">
401  <xsl:apply-templates/>
402</xsl:template>
403
404<!-- ==================================================================== -->
405
406<xsl:template match="procedure">
407  <xsl:variable name="id">
408    <xsl:call-template name="object.id"/>
409  </xsl:variable>
410  <div class="{name(.)}">
411    <a name="{$id}"/>
412    <xsl:if test="title">
413      <xsl:apply-templates select="title" mode="procedure.title.mode"/>
414    </xsl:if>
415    <xsl:apply-templates select="*[local-name()!='step']"/>     
416    <ol><xsl:apply-templates select="step"/></ol>              
417  </div>
418</xsl:template>
419
420<xsl:template match="procedure/title">
421</xsl:template>
422
423<xsl:template match="title" mode="procedure.title.mode">
424  <p>
425    <b>
426      <xsl:apply-templates/>
427    </b>
428  </p>
429</xsl:template>
430
431<xsl:template match="substeps">
432  <xsl:variable name="depth" select="count(ancestor::substeps)"/>
433  <xsl:variable name="type" select="$depth mod 5"/>
434  <xsl:variable name="numeration">
435    <xsl:choose>
436      <xsl:when test="$type = 0">a</xsl:when>
437      <xsl:when test="$type = 1">i</xsl:when>
438      <xsl:when test="$type = 2">A</xsl:when>
439      <xsl:when test="$type = 3">I</xsl:when>
440      <xsl:when test="$type = 4">1</xsl:when>
441    </xsl:choose>
442  </xsl:variable>
443
444  <ol type="{$numeration}">
445    <xsl:apply-templates/>
446  </ol>
447</xsl:template>
448
449<xsl:template match="step">
450  <xsl:variable name="id">
451    <xsl:call-template name="object.id"/>
452  </xsl:variable>
453
454  <li>
455    <a name="{$id}"/>
456    <xsl:apply-templates/>
457  </li>
458</xsl:template>
459
460<xsl:template match="step/title">
461  <xsl:apply-templates select="." mode="procedure.title.mode"/>
462</xsl:template>
463
464<!-- ==================================================================== -->
465
466<xsl:template match="segmentedlist">
467  <xsl:apply-templates/>
468</xsl:template>
469
470<xsl:template match="segmentedlist/title">
471  <p><b><xsl:apply-templates/></b></p>
472</xsl:template>
473
474<xsl:template match="segtitle">
475</xsl:template>
476
477<xsl:template match="segtitle" mode="segtitle-in-seg">
478  <xsl:apply-templates/>
479</xsl:template>
480
481<xsl:template match="seglistitem">
482  <xsl:apply-templates/>
483</xsl:template>
484
485<xsl:template match="seg">
486  <xsl:variable name="segnum" select="position()"/>
487  <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
488  <xsl:variable name="segtitles" select="$seglist/segtitle"/>
489
490  <!--
491     Note: segtitle is only going to be the right thing in a well formed
492     SegmentedList.  If there are too many Segs or too few SegTitles,
493     you'll get something odd...maybe an error
494  -->
495
496  <p>
497    <b>
498      <xsl:apply-templates select="$segtitles[$segnum=position()]"
499                           mode="segtitle-in-seg"/>
500      <xsl:text>: </xsl:text>
501    </b>
502    <xsl:apply-templates/>
503  </p>
504</xsl:template>
505
506<!-- ==================================================================== -->
507
508<xsl:template match="calloutlist">
509  <xsl:variable name="id">
510    <xsl:call-template name="object.id"/>
511  </xsl:variable>
512  <div class="{name(.)}">
513    <a name="{$id}"/>
514    <xsl:if test="/title">
515      <p>
516        <b>
517          <xsl:apply-templates select="/title" mode="calloutlist.title.mode"/>
518        </b>
519      </p>
520    </xsl:if>
521    <xsl:choose>
522      <xsl:when test="$callout.list.table != 0">
523        <table border="0" summary="Callout list">
524          <xsl:apply-templates/>
525        </table>
526      </xsl:when>
527      <xsl:otherwise>
528        <dl compact="compact"><xsl:apply-templates/></dl>
529      </xsl:otherwise>
530    </xsl:choose>
531  </div>
532</xsl:template>
533
534<xsl:template match="calloutlist/title">
535</xsl:template>
536
537<xsl:template match="calloutlist/title" mode="calloutlist.title.mode">
538  <xsl:apply-templates/>
539</xsl:template>
540
541<xsl:template match="callout">
542  <xsl:variable name="id">
543    <xsl:call-template name="object.id"/>
544  </xsl:variable>
545  <xsl:choose>
546    <xsl:when test="$callout.list.table != 0">
547      <tr>
548        <td width="5%" valign="top" align="left">
549          <a name="{$id}"/>
550          <xsl:call-template name="callout.arearefs">
551            <xsl:with-param name="arearefs" select="@arearefs"/>
552          </xsl:call-template>
553        </td>
554        <td valign="top" align="left">
555          <xsl:apply-templates/>
556        </td>
557      </tr>
558    </xsl:when>
559    <xsl:otherwise>
560      <dt>
561        <a name="{$id}"/>
562        <xsl:call-template name="callout.arearefs">
563          <xsl:with-param name="arearefs" select="@arearefs"/>
564        </xsl:call-template>
565      </dt>
566      <dd><xsl:apply-templates/></dd>
567    </xsl:otherwise>
568  </xsl:choose>
569</xsl:template>
570
571<xsl:template name="callout.arearefs">
572  <xsl:param name="arearefs"></xsl:param>
573  <xsl:if test="$arearefs!=''">
574    <xsl:choose>
575      <xsl:when test="substring-before($arearefs,' ')=''">
576        <xsl:call-template name="callout.arearef">
577          <xsl:with-param name="arearef" select="$arearefs"/>
578        </xsl:call-template>
579      </xsl:when>
580      <xsl:otherwise>
581        <xsl:call-template name="callout.arearef">
582          <xsl:with-param name="arearef"
583                          select="substring-before($arearefs,' ')"/>
584        </xsl:call-template>
585      </xsl:otherwise>
586    </xsl:choose>
587    <xsl:call-template name="callout.arearefs">
588      <xsl:with-param name="arearefs"
589                      select="substring-after($arearefs,' ')"/>
590    </xsl:call-template>
591  </xsl:if>
592</xsl:template>
593
594<xsl:template name="callout.arearef">
595  <xsl:param name="arearef"></xsl:param>
596  <xsl:variable name="targets" select="id($arearef)"/>
597  <xsl:variable name="target" select="$targets[1]"/>
598
599  <xsl:call-template name="check.id.unique">
600    <xsl:with-param name="linkend" select="$arearef"/>
601  </xsl:call-template>
602
603  <xsl:choose>
604    <xsl:when test="count($target)=0">
605      <xsl:text>???</xsl:text>
606    </xsl:when>
607    <xsl:when test="local-name($target)='co'">
608      <a>
609        <xsl:attribute name="href">
610          <xsl:text>#</xsl:text>
611          <xsl:value-of select="$arearef"/>
612        </xsl:attribute>
613        <xsl:apply-templates select="$target" mode="callout-bug"/>
614      </a>
615      <xsl:text> </xsl:text>
616    </xsl:when>
617    <xsl:when test="local-name($target)='areaset'">
618      <xsl:call-template name="callout-bug">
619        <xsl:with-param name="conum">
620          <xsl:apply-templates select="$target" mode="conumber"/>
621        </xsl:with-param>
622      </xsl:call-template>
623    </xsl:when>
624    <xsl:when test="local-name($target)='area'">
625      <xsl:choose>
626        <xsl:when test="$target/parent::areaset">
627          <xsl:call-template name="callout-bug">
628            <xsl:with-param name="conum">
629              <xsl:apply-templates select="$target/parent::areaset"
630                                   mode="conumber"/>
631            </xsl:with-param>
632          </xsl:call-template>
633        </xsl:when>
634        <xsl:otherwise>
635          <xsl:call-template name="callout-bug">
636            <xsl:with-param name="conum">
637              <xsl:apply-templates select="$target" mode="conumber"/>
638            </xsl:with-param>
639          </xsl:call-template>
640        </xsl:otherwise>
641      </xsl:choose>
642    </xsl:when>
643    <xsl:otherwise>
644      <xsl:text>???</xsl:text>
645    </xsl:otherwise>
646  </xsl:choose>
647</xsl:template>
648
649<!-- ==================================================================== -->
650
651</xsl:stylesheet>
652
653