]> git.stg.codes - stg.git/blob - doc/xslt/slides/svg/default.xsl
Do not flush indexes on stop (fixes #44).
[stg.git] / doc / xslt / slides / svg / default.xsl
1 <xsl:stylesheet version='1.0'
2   xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
3   xmlns:xlink="http://www.w3.org/1999/xlink"
4   xmlns:doc='http://nwalsh.com/xsl/documentation/1.0'
5   exclude-result-prefixes='doc'>
6
7   <xsl:import href='../../lib/lib.xsl'/>
8
9   <doc:article xmlns=''>
10     <articleinfo>
11       <title>SVG Slides</title>
12
13       <author>
14         <firstname>Steve</firstname>
15         <surname>Ball</surname>
16         <affiliation>
17           <orgname>Zveno</orgname>
18           <address>
19             <otheraddr>
20               <ulink url='http://www.zveno.com/'>zveno.com</ulink>
21             </otheraddr>
22           </address>
23         </affiliation>
24       </author>
25
26       <releaseinfo>$Id: default.xsl 6567 2007-01-30 06:43:18Z xmldoc $</releaseinfo>
27
28       <copyright>
29         <year>2002</year>
30         <holder>Steve Ball, Zveno Pty Ltd</holder>
31       </copyright>
32
33       <legalnotice>
34         <para>Zveno Pty Ltd makes this software and associated documentation available free of charge for any purpose.  You may make copies of the software but you must include all of this notice on any copy.</para>
35         <para>Zveno Pty Ltd does not warrant that this software is error free or fit for any purpose.  Zveno Pty Ltd disclaims any liability for all claims, expenses, losses, damages and costs any user may incur as a result of using, copying or modifying the software.</para>
36       </legalnotice>
37     </articleinfo>
38   </doc:article>
39
40   <xsl:variable name='svg-public-id' select='"-//W3C//DTD SVG 20001102//EN"'/>
41   <xsl:variable name='svg-system-id' select='"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"'/>
42
43   <xsl:output method="xml" indent='yes' doctype-public='-//W3C//DTD SVG 20001102//EN' doctype-system='http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd' cdata-section-elements="script"/>
44
45   <xsl:strip-space elements='slides foil foilgroup'/>
46
47   <xsl:param name='css-stylesheet'>slides.css</xsl:param>
48   <xsl:param name='graphics.dir'>graphics</xsl:param>
49
50   <xsl:param name='toc.bg.color'>white</xsl:param>
51
52   <xsl:param name='font.family'>Arial</xsl:param>
53   <xsl:param name='bg.color'>white</xsl:param>
54   <xsl:param name='fg.color'>black</xsl:param>
55
56   <xsl:param name='foil.width' select='800'/>
57   <xsl:param name='foil.height' select='600'/>
58
59   <xsl:param name='toc.line.max' select='7'/>
60
61   <xsl:attribute-set name="svg.attributes">
62     <xsl:attribute name="xml:space">preserve</xsl:attribute>
63     <xsl:attribute name="width">100%</xsl:attribute>
64     <xsl:attribute name="height"><xsl:value-of select='$foil.height'/></xsl:attribute>
65     <xsl:attribute name="style">font-family: <xsl:value-of select='$font.family'/>; font-size: 18pt; fill: <xsl:value-of select='$fg.color'/>; stroke: <xsl:value-of select='$fg.color'/>; background-color: <xsl:value-of select='$bg.color'/></xsl:attribute>
66   </xsl:attribute-set>
67
68   <xsl:attribute-set name="text-title">
69     <xsl:attribute name="style">font-size: 24pt; font-weight: bold</xsl:attribute>
70   </xsl:attribute-set>
71   <xsl:attribute-set name="text-author">
72     <xsl:attribute name="style">font-size: 18pt</xsl:attribute>
73   </xsl:attribute-set>
74   <xsl:attribute-set name="text-main">
75     <xsl:attribute name="style">font-size: 18pt</xsl:attribute>
76   </xsl:attribute-set>
77
78 <!-- ============================================================ -->
79
80 <xsl:template name="graphics.dir">
81   <!-- danger will robinson: template shadows parameter -->
82   <xsl:variable name="source.graphics.dir">
83     <xsl:call-template name="dbhtml-attribute">
84       <xsl:with-param name="pis" select="/processing-instruction('dbhtml')"/>
85       <xsl:with-param name="attribute" select="'graphics-dir'"/>
86     </xsl:call-template>
87   </xsl:variable>
88
89   <xsl:choose>
90     <xsl:when test="$source.graphics.dir != ''">
91       <xsl:value-of select="$source.graphics.dir"/>
92     </xsl:when>
93     <xsl:otherwise>
94       <xsl:value-of select="$graphics.dir"/>
95     </xsl:otherwise>
96   </xsl:choose>
97 </xsl:template>
98
99 <xsl:template name="css-stylesheet">
100   <!-- danger will robinson: template shadows parameter -->
101   <xsl:variable name="source.css-stylesheet">
102     <xsl:call-template name="dbhtml-attribute">
103       <xsl:with-param name="pis" select="/processing-instruction('dbhtml')"/>
104       <xsl:with-param name="attribute" select="'css-stylesheet'"/>
105     </xsl:call-template>
106   </xsl:variable>
107
108   <xsl:choose>
109     <xsl:when test="$source.css-stylesheet != ''">
110       <xsl:value-of select="$source.css-stylesheet"/>
111     </xsl:when>
112     <xsl:otherwise>
113       <xsl:value-of select="$css-stylesheet"/>
114     </xsl:otherwise>
115   </xsl:choose>
116 </xsl:template>
117
118 <!-- ============================================================ -->
119
120   <xsl:template match="/">
121     <xsl:apply-templates/>
122   </xsl:template>
123
124   <xsl:template match="slides">
125     <xsl:if test='$css-stylesheet != ""'>
126       <xsl:processing-instruction name='xml-stylesheet'>
127         <xsl:text> href="</xsl:text>
128         <xsl:value-of select='$css-stylesheet'/>
129         <xsl:text>" type="text/css"</xsl:text>
130       </xsl:processing-instruction>
131     </xsl:if>
132
133     <svg xsl:use-attribute-sets="svg.attributes">
134       <title>
135         <xsl:value-of select="slidesinfo/title"/>
136       </title>
137
138       <defs>
139         <xsl:call-template name='svg.defs'/>
140       </defs>
141
142       <!-- Create the title foil -->
143       <g id='title' display='inline'>
144         <xsl:call-template name='render-background'>
145           <xsl:with-param name='mode'>title</xsl:with-param>
146           <xsl:with-param name='id' select='"title-bg"'/>
147         </xsl:call-template>
148
149         <text id='title-main' x='50%' y='33.3%' text-anchor='middle' xsl:use-attribute-sets='text-title'>
150           <xsl:value-of select='/slides/slidesinfo/title'/>
151         </text>
152         <g id='title-author'>
153           <xsl:apply-templates select='/slides/slidesinfo/author|/slides/slidesinfo/corpauthor'/>
154         </g>
155
156         <set attributeName='display' to='none' attributeType='CSS'>
157           <xsl:attribute name='begin'>
158             <xsl:text>title.click</xsl:text>
159           </xsl:attribute>
160           <xsl:attribute name='end'>
161             <xsl:text>foil1-previous-button.click; </xsl:text>
162             <xsl:value-of select='concat("foil", count(//foil), ".click")'/>
163             <xsl:for-each select='//foil'>
164               <xsl:value-of select='concat("; foil", count(preceding-sibling::foil|preceding::foil) + 1, "-title-button.click")'/>
165             </xsl:for-each>
166           </xsl:attribute>
167         </set>
168       </g>
169
170       <!-- Create the TOC -->
171       <xsl:if test='foilgroup'>
172         <g id='toc' display='none'>
173
174           <xsl:call-template name='render-background'>
175             <xsl:with-param name='mode'>toc</xsl:with-param>
176             <xsl:with-param name='id' select='"index-bg"'/>
177           </xsl:call-template>
178
179           <text id='toc-main' x='50%' y='50' text-anchor='middle' xsl:use-attribute-sets='text-title'>
180             <xsl:value-of select='/slides/slidesinfo/title'/>
181           </text>
182
183           <set attributeName='display' to='inline' attributeType='CSS'>
184             <xsl:attribute name='begin'>
185               <xsl:text>title.click</xsl:text>
186               <xsl:for-each select='//foil'>
187                 <xsl:value-of select='concat("; foil", count(preceding-sibling::foil|preceding::foil) + 1, "-toc-button.click")'/>
188               </xsl:for-each>
189             </xsl:attribute>
190             <xsl:attribute name='end'>
191               <xsl:text>toc.click; toc-content.click</xsl:text>
192               <xsl:for-each select='//foilgroup'>
193                 <xsl:value-of select='concat("; index-foilgroup-", count(preceding-sibling::foilgroup|preceding::foilgroup) + 1, ".click")'/>
194               </xsl:for-each>
195             </xsl:attribute>
196           </set>
197
198         </g>
199         <g id='toc-content' display='none'>
200           <xsl:call-template name='layout-toc-columns'>
201             <xsl:with-param name='nodes' select='foilgroup'/>
202             <xsl:with-param name='x'>
203               <xsl:choose>
204                 <xsl:when test='count(foilgroup) > $toc.line.max'>
205                   <xsl:text>50</xsl:text>
206                 </xsl:when>
207                 <xsl:otherwise>75</xsl:otherwise>
208               </xsl:choose>
209             </xsl:with-param>
210           </xsl:call-template>
211           <set attributeName='display' to='inline' attributeType='CSS'>
212             <xsl:attribute name='begin'>
213               <xsl:text>title.click</xsl:text>
214               <xsl:for-each select='//foil'>
215                 <xsl:value-of select='concat("; foil", count(preceding-sibling::foil|preceding::foil) + 1, "-toc-button.click")'/>
216               </xsl:for-each>
217             </xsl:attribute>
218             <xsl:attribute name='end'>
219               <xsl:text>toc.click; toc-content.click</xsl:text>
220               <xsl:for-each select='//foilgroup'>
221                 <xsl:value-of select='concat("; index-foilgroup-", count(preceding-sibling::foilgroup|preceding::foilgroup) + 1, ".click")'/>
222               </xsl:for-each>
223             </xsl:attribute>
224           </set>
225         </g>
226       </xsl:if>
227
228       <xsl:apply-templates select='*[not(self::slidesinfo)]'/>
229
230     </svg>
231   </xsl:template>
232
233   <!-- The application is expected to override these templates -->
234   <xsl:template name='svg.defs'/>
235   <xsl:template name='render-background'>
236     <!-- mode lets us know what kind of foil is being produced -->
237     <xsl:param name='mode'/>
238
239     <!-- id is a required parameter to include in the generated graphics.
240        - This is important for slide transitions.
241       -->
242     <xsl:param name='id'/>
243
244     <!-- This background covers most of the foil area,
245        - but leaves a space in the lower left corner for the
246        - controls
247       -->
248
249     <xsl:choose>
250       <xsl:when test='$mode = "toc"'>
251         <g id='{$id}'>
252           <!--
253           <rect width='{2 * $foil.width}' height='75' style='fill: {$toc.bg.color}; stroke: none'/>
254 -->
255           <rect width="{2 * $foil.width}" height="{$foil.height - 200}" style="fill: {$toc.bg.color}; stroke: none"/>
256           <rect transform='translate(100 {$foil.height - 200})' width="{2 * $foil.width}" height="200" style="fill: {$toc.bg.color}; stroke: none"/>
257         </g>
258       </xsl:when>
259       <xsl:otherwise>
260         <g id="{$id}">
261           <rect width="{2 * $foil.width}" height="{$foil.height - 200}" style="fill: {$bg.color}; stroke: none"/>
262           <rect transform='translate(100 {$foil.height - 200})' width="{2 * $foil.width}" height="200" style="fill: {$bg.color}; stroke: none"/>
263         </g>
264       </xsl:otherwise>
265     </xsl:choose>
266   </xsl:template>
267
268   <xsl:template match='author'>
269     <text x='50%' y='60%' text-anchor='middle' xsl:use-attribute-sets='text-author'>
270       <tspan>
271         <xsl:apply-templates select='firstname'/>
272       </tspan>
273       <tspan>
274         <xsl:text> </xsl:text>
275       </tspan>
276       <tspan>
277         <xsl:apply-templates select='surname'/>
278       </tspan>
279       <xsl:if test='affiliation'>
280         <tspan x='0' y='20'>
281           <xsl:apply-templates select='affiliation'/>
282         </tspan>
283       </xsl:if>
284     </text>
285   </xsl:template>
286   <xsl:template match='corpauthor'>
287     <text x='50%' y='70%' text-anchor='middle' xsl:use-attribute-sets='text-author'>
288       <xsl:apply-templates/>
289     </text>
290   </xsl:template>
291
292   <xsl:template name='layout-toc-columns'>
293     <xsl:param name='nodes'/>
294     <xsl:param name='entries-are-links' select='"yes"'/>
295     <xsl:param name='highlight'/>
296     <xsl:param name='x' select='50'/>
297
298     <xsl:choose>
299       <xsl:when test='not($nodes)'/>
300
301       <xsl:otherwise>
302         <xsl:for-each select='$nodes[position() &lt;= $toc.line.max]'>
303           <g>
304             <xsl:if test='$entries-are-links = "yes"'>
305               <xsl:attribute name='id'>
306                 <xsl:text>index-foilgroup-</xsl:text>
307                 <xsl:value-of select='count(preceding-sibling::foilgroup|preceding::foilgroup) + 1'/>
308               </xsl:attribute>
309             </xsl:if>
310             <text x='{$x}' y='{position() * 35 + 75}' xsl:use-attribute-sets='text-main'>
311               <xsl:if test='$highlight and generate-id($highlight) = generate-id(.)'>
312                 <xsl:attribute name='fill'>#ff8000</xsl:attribute>
313                 <xsl:attribute name='stroke'>#ff8000</xsl:attribute>
314               </xsl:if>
315               <xsl:value-of select='title'/>
316             </text>
317             <xsl:if test='$entries-are-links = "yes"'>
318               <set attributeName='fill' attributeType='CSS' to='#ff0033' begin='mouseover' end='mouseout'/>
319               <set attributeName='stroke' attributeType='CSS' to='#ff0033' begin='mouseover' end='mouseout'/>
320             </xsl:if>
321           </g>
322         </xsl:for-each>
323
324         <xsl:call-template name='layout-toc-columns'>
325           <xsl:with-param name='nodes' select='$nodes[position() > $toc.line.max]'/>
326           <xsl:with-param name='entries-are-links' select='$entries-are-links'/>
327           <xsl:with-param name='highlight' select='$highlight'/>
328           <xsl:with-param name='x' select='$x + 200'/>
329         </xsl:call-template>
330
331       </xsl:otherwise>
332     </xsl:choose>
333   </xsl:template>
334
335   <xsl:template match='foilgroup'>
336     <xsl:variable name='fg-num' select='count(preceding-sibling::foilgroup) + 1'/>
337
338     <!-- Add a separator foil to indicate progress -->
339     <g id='toc-sep-{$fg-num}' display='none'>
340       <xsl:call-template name='render-background'>
341         <xsl:with-param name='mode'>toc</xsl:with-param>
342         <xsl:with-param name='id' select='concat("toc-sep-", $fg-num, "-bg")'/>
343       </xsl:call-template>
344
345       <text id='toc-sep-{$fg-num}-main' x='50%' y='50' text-anchor='middle' xsl:use-attribute-sets='text-title'>
346         <xsl:value-of select='/slides/slidesinfo/title'/>
347       </text>
348
349       <set attributeName='display' to='inline' attributeType='CSS' end='toc-sep-{$fg-num}.click; toc-sep-{$fg-num}-content.click'>
350         <xsl:attribute name='begin'>
351           <xsl:choose>
352             <xsl:when test='$fg-num = 1'>
353               <xsl:text>index-foilgroup-1.click; toc.click; toc-content.click</xsl:text>
354             </xsl:when>
355             <xsl:otherwise>
356               <xsl:text>index-foilgroup-</xsl:text>
357               <xsl:value-of select='count(preceding-sibling::foilgroup) + 1'/>
358               <xsl:text>.click; foil</xsl:text>
359               <xsl:value-of select='count(preceding::foil)'/>
360               <xsl:text>.click</xsl:text>
361             </xsl:otherwise>
362           </xsl:choose>
363         </xsl:attribute>
364       </set>
365
366     </g>
367     <g id='toc-sep-{$fg-num}-content' display='none'>
368       <xsl:call-template name='layout-toc-columns'>
369         <xsl:with-param name='nodes' select='/slides/foilgroup'/>
370         <xsl:with-param name='entries-are-links' select='no'/>
371         <xsl:with-param name='highlight' select='.'/>
372         <xsl:with-param name='x'>
373           <xsl:choose>
374             <xsl:when test='count(/slides/foilgroup) > $toc.line.max'>
375               <xsl:text>50</xsl:text>
376             </xsl:when>
377             <xsl:otherwise>75</xsl:otherwise>
378           </xsl:choose>
379         </xsl:with-param>
380       </xsl:call-template>
381       <set attributeName='display' to='inline' attributeType='CSS' end='toc-sep-{$fg-num}.click; toc-sep-{$fg-num}-content.click'>
382         <xsl:attribute name='begin'>
383           <xsl:choose>
384             <xsl:when test='$fg-num = 1'>
385               <xsl:text>index-foilgroup-1.click; toc.click; toc-content.click</xsl:text>
386             </xsl:when>
387             <xsl:otherwise>
388               <xsl:text>index-foilgroup-</xsl:text>
389               <xsl:value-of select='count(preceding-sibling::foilgroup) + 1'/>
390               <xsl:text>.click; foil</xsl:text>
391               <xsl:value-of select='count(preceding::foil)'/>
392               <xsl:text>.click</xsl:text>
393             </xsl:otherwise>
394           </xsl:choose>
395         </xsl:attribute>
396       </set>
397     </g>
398
399     <!-- still want TOC and Previous buttons -->
400
401     <xsl:apply-templates select='foil'/>
402   </xsl:template>
403
404   <xsl:template match='foil'>
405     <xsl:variable name='number' select='count(preceding-sibling::foil|preceding::foil) + 1'/>
406
407     <g id='foil{$number}' display='none'>
408       <xsl:call-template name='render-background'>
409         <xsl:with-param name='id' select='concat("foil", $number, "-bg")'/>
410       </xsl:call-template>
411
412       <text id='foil{$number}-title' transform='translate(50 50)'>
413         <tspan id='foil{$number}-title-foilgroup' x='0' y='0' xsl:use-attribute-sets='text-title'>
414           <xsl:choose>
415             <xsl:when test='parent::foilgroup'>
416               <xsl:value-of select='../title'/>
417             </xsl:when>
418             <xsl:otherwise>
419               <xsl:value-of select='/slides/slidesinfo/title'/>
420             </xsl:otherwise>
421           </xsl:choose>
422         </tspan>
423         <tspan> - </tspan>
424         <tspan id='foil{$number}-title-foil' xsl:use-attribute-sets='text-title'>
425           <xsl:value-of select='title'/>
426         </tspan>
427       </text>
428
429       <g transform='translate(50 100)'>
430         <xsl:apply-templates select='*[not(self::title)][1]'/>
431       </g>
432
433       <xsl:call-template name='foil-events'>
434         <xsl:with-param name='number' select='$number'/>
435       </xsl:call-template>
436
437     </g>
438
439     <!-- Add previous and TOC buttons 
440        - (no need for next, mouse click does that)
441       -->
442
443     <g id='foil{$number}-toc-button' transform='translate(20 {$foil.height - 180})' display='none'>
444       <g style='opacity: 0'>
445         <xsl:call-template name='toc-button'/>
446         <text x='25' y='28'>TOC</text>
447         <set attributeName='opacity' to='1' attributeType='CSS' begin='mouseover' end='mouseout'/>
448       </g>
449
450       <xsl:call-template name='foil-events'>
451         <xsl:with-param name='number' select='$number'/>
452       </xsl:call-template>
453
454     </g>
455     <xsl:if test='$number != 1'>
456       <g id='foil{$number}-previous-button' transform='translate(20 {$foil.height - 150})' display='none'>
457         <g style='opacity: 0'>
458           <xsl:call-template name='previous-button'/>
459           <text x='17' y='28'>Previous</text>
460           <set attributeName='opacity' to='1' attributeType='CSS' begin='mouseover' end='mouseout'/>
461         </g>
462
463         <xsl:call-template name='foil-events'>
464           <xsl:with-param name='number' select='$number'/>
465         </xsl:call-template>
466
467       </g>
468     </xsl:if>
469
470   </xsl:template>
471
472   <!-- The application may override these -->
473   <xsl:template name='toc-button'/>
474   <xsl:template name='previous-button'/>
475
476   <xsl:template match='foilinfo|foil/title|foil/subtitle|foil/titleabbrev'/>
477
478   <xsl:template name='foil-events'>
479     <xsl:param name='number' select='0'/>
480     <xsl:param name='attribute' select='"display"'/>
481     <xsl:param name='onvalue' select='"inline"'/>
482     <xsl:param name='offvalue' select='"none"'/>
483
484     <!-- Must account for first and last foils and also foilgroup separators:
485        - On first foil, previous goes back to main TOC,
486        - If no TOC foil, then go to title foil instead.
487        - First foil in foilgroup follows group separator.
488        - Last foil in foilgroup goes to next group separator,
489        - except last foil in last group goes to main TOC.
490       -->
491
492     <xsl:choose>
493       <xsl:when test='$number = 1'>
494         <!-- This is the very first foil -->
495         <set attributeName='{$attribute}' to='{$onvalue}' attributeType='CSS'
496             end='foil{$number}.click; foil{$number}-toc-button.click'>
497           <xsl:attribute name='begin'>
498             <xsl:choose>
499               <xsl:when test='parent::foilgroup'>
500                 <xsl:value-of select='concat("toc-sep-", count(preceding::foilgroup) + 1, ".click")'/>
501               </xsl:when>
502               <xsl:otherwise>
503                 <xsl:text>title.click</xsl:text>
504               </xsl:otherwise>
505             </xsl:choose>
506             <xsl:if test='parent::foilgroup and not(preceding-sibling::foil)'>
507               <xsl:value-of select='concat("; index-foilgroup-", count(preceding::foilgroup) + 1, ".click")'/>
508             </xsl:if>
509             <xsl:value-of select='concat("; foil", $number + 1, "-previous-button.click")'/>
510           </xsl:attribute>
511         </set>
512       </xsl:when>
513       <xsl:when test='count(following-sibling::foil|following::foil) = 0'>
514         <!-- This is the very last foil -->
515         <set attributeName='{$attribute}' to='{$onvalue}' attributeType='CSS'
516             end='foil{$number}.click; foil{$number}-toc-button.click; foil{$number}-previous-button.click'>
517           <xsl:attribute name='begin'>
518             <xsl:choose>
519               <xsl:when test='parent::foilgroup and not(preceding-sibling::foil)'>
520                 <xsl:value-of select='concat("; index-foilgroup-", count(preceding::foilgroup) + 1, ".click; toc-sep-", count(preceding::foilgroup) + 1, ".click")'/>
521               </xsl:when>
522               <xsl:otherwise>
523                 <xsl:value-of select='concat("foil", $number - 1, ".click")'/>
524               </xsl:otherwise>
525             </xsl:choose>
526           </xsl:attribute>
527         </set>
528       </xsl:when>
529       <xsl:otherwise>
530         <set attributeName='{$attribute}' to='{$onvalue}' attributeType='CSS'
531             end='foil{$number}.click; foil{$number}-toc-button.click; foil{$number}-previous-button.click'>
532           <xsl:attribute name='begin'>
533             <xsl:value-of select='concat("foil", $number + 1, "-previous-button.click")'/>
534             <xsl:choose>
535               <xsl:when test='parent::foilgroup and not(preceding-sibling::foil)'>
536                 <xsl:value-of select='concat("; index-foilgroup-", count(preceding::foilgroup) + 1, ".click; toc-sep-", count(preceding::foilgroup) + 1, ".click")'/>
537               </xsl:when>
538               <xsl:otherwise>
539                 <xsl:value-of select='concat("; foil", $number - 1, ".click")'/>
540               </xsl:otherwise>
541             </xsl:choose>
542           </xsl:attribute>
543         </set>
544       </xsl:otherwise>
545     </xsl:choose>
546
547   </xsl:template>
548
549   <xsl:template match="para">
550     <xsl:variable name='depth'>
551       <xsl:choose>
552         <xsl:when test='@depth'>
553           <xsl:value-of select='@depth'/>
554         </xsl:when>
555         <xsl:otherwise>
556           <xsl:text>1</xsl:text>
557         </xsl:otherwise>
558       </xsl:choose>
559     </xsl:variable>
560
561     <g transform='translate(0 30)'>
562       <xsl:if test='not(@style)'>
563         <g transform='translate({25 * ($depth - 1)} 0)'>
564           <xsl:call-template name='bullet'/>
565         </g>
566       </xsl:if>
567
568       <text y="10">
569         <xsl:attribute name='x'>
570           <xsl:value-of select='25 * $depth'/>
571         </xsl:attribute>
572         <xsl:if test='@style'>
573           <xsl:attribute name='style'>
574             <xsl:value-of select='@style'/>
575           </xsl:attribute>
576         </xsl:if>
577
578         <xsl:apply-templates/>
579       </text>
580
581       <xsl:apply-templates select='following-sibling::*[1]'/>
582     </g>
583   </xsl:template>
584
585   <xsl:template match='text()'>
586     <tspan>
587       <xsl:value-of select='.'/>
588     </tspan>
589   </xsl:template>
590
591   <xsl:template match='emphasis'>
592     <xsl:variable name='style'>
593       <xsl:choose>
594         <xsl:when test='@role = "bold"'>
595           <xsl:text>font-weight: bold</xsl:text>
596         </xsl:when>
597         <xsl:when test='@role = "italic"'>
598           <xsl:text>font-style: italic</xsl:text>
599         </xsl:when>
600         <xsl:otherwise>
601           <xsl:text>font-style: italic</xsl:text>
602         </xsl:otherwise>
603       </xsl:choose>
604     </xsl:variable>
605
606     <tspan style='{$style}'>
607       <xsl:value-of select='.'/>
608     </tspan>
609   </xsl:template>
610
611   <xsl:template match='listitem'>
612     <xsl:call-template name="bullet"/>
613     <g transform='translate(20 0)'>
614       <xsl:apply-templates/>
615     </g>
616   </xsl:template>
617
618   <xsl:template name="bullet">
619     <xsl:choose>
620       <xsl:when test="@depth = 1 or count(ancestor-or-self::listitem) = 1">
621         <xsl:call-template name="large-filled-circle"/>
622       </xsl:when>
623       <xsl:when test="@depth = 2 or count(ancestor-or-self::listitem) = 2">
624         <xsl:call-template name="small-open-circle"/>
625       </xsl:when>
626       <xsl:when test="@depth = 3 or count(ancestor-or-self::listitem) = 3">
627         <xsl:call-template name="small-filled-circle"/>
628       </xsl:when>
629       <xsl:when test="@depth = 4 or count(ancestor-or-self::listitem) = 4">
630         <xsl:call-template name="closed-toggle"/>
631       </xsl:when>
632       <xsl:when test="@depth = 5 or count(ancestor-or-self::listitem) = 5">
633         <xsl:call-template name="large-filled-circle"/>
634       </xsl:when>
635       <xsl:otherwise>
636         <xsl:call-template name="small-open-box"/>
637       </xsl:otherwise>
638     </xsl:choose>
639   </xsl:template>
640
641   <xsl:template name="closed-toggle">
642     <polyline fill="white" stroke="black" stroke-width="1" points="0 0 10 5 0 10 0 0"/>
643   </xsl:template>
644   <xsl:template name="large-filled-circle">
645     <circle fill="black" cx="10" cy="6" r="5"/>
646   </xsl:template>
647   <xsl:template name="small-filled-circle">
648     <circle fill="black" cx="10" cy="6" r="2.5"/>
649   </xsl:template>
650   <xsl:template name="small-open-circle">
651     <circle fill="none" stroke="black" stroke-width="1" cx="10" cy="6" r="2.5"/>
652   </xsl:template>
653   <xsl:template name="small-open-box">
654     <rect fill="none" stroke="black" stroke-width="1" x="5" y="5" width="5" height="5"/>
655   </xsl:template>
656
657   <xsl:template match="subject">
658     <tspan style="font-weight: bold">
659       <xsl:apply-templates/>
660     </tspan>
661   </xsl:template>
662
663   <xsl:template match="informalexample">
664   </xsl:template>
665   <xsl:template match="programlisting">
666     <!-- Output lines verbatim -->
667   </xsl:template>
668
669   <xsl:template match="imageobject|mediaobject">
670     <xsl:apply-templates/>
671   </xsl:template>
672   <xsl:template match='textobject|videoobject'/>
673   <xsl:template match='imagedata'>
674     <g transform='translate(0 30)'>
675       <image xlink:href='{@fileref}' x='0' y='0' width='600' height='400'/>
676     </g>
677   </xsl:template>
678
679   <xsl:template match='ulink'>
680     <a xlink:href='{@url}'>
681       <xsl:apply-templates/>
682     </a>
683   </xsl:template>
684
685 </xsl:stylesheet>
686