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'>
7 <xsl:import href='../../lib/lib.xsl'/>
11 <title>SVG Slides</title>
14 <firstname>Steve</firstname>
15 <surname>Ball</surname>
17 <orgname>Zveno</orgname>
20 <ulink url='http://www.zveno.com/'>zveno.com</ulink>
26 <releaseinfo>$Id: default.xsl 6567 2007-01-30 06:43:18Z xmldoc $</releaseinfo>
30 <holder>Steve Ball, Zveno Pty Ltd</holder>
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>
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"'/>
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"/>
45 <xsl:strip-space elements='slides foil foilgroup'/>
47 <xsl:param name='css-stylesheet'>slides.css</xsl:param>
48 <xsl:param name='graphics.dir'>graphics</xsl:param>
50 <xsl:param name='toc.bg.color'>white</xsl:param>
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>
56 <xsl:param name='foil.width' select='800'/>
57 <xsl:param name='foil.height' select='600'/>
59 <xsl:param name='toc.line.max' select='7'/>
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>
68 <xsl:attribute-set name="text-title">
69 <xsl:attribute name="style">font-size: 24pt; font-weight: bold</xsl:attribute>
71 <xsl:attribute-set name="text-author">
72 <xsl:attribute name="style">font-size: 18pt</xsl:attribute>
74 <xsl:attribute-set name="text-main">
75 <xsl:attribute name="style">font-size: 18pt</xsl:attribute>
78 <!-- ============================================================ -->
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'"/>
90 <xsl:when test="$source.graphics.dir != ''">
91 <xsl:value-of select="$source.graphics.dir"/>
94 <xsl:value-of select="$graphics.dir"/>
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'"/>
109 <xsl:when test="$source.css-stylesheet != ''">
110 <xsl:value-of select="$source.css-stylesheet"/>
113 <xsl:value-of select="$css-stylesheet"/>
118 <!-- ============================================================ -->
120 <xsl:template match="/">
121 <xsl:apply-templates/>
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>
133 <svg xsl:use-attribute-sets="svg.attributes">
135 <xsl:value-of select="slidesinfo/title"/>
139 <xsl:call-template name='svg.defs'/>
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"'/>
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'/>
152 <g id='title-author'>
153 <xsl:apply-templates select='/slides/slidesinfo/author|/slides/slidesinfo/corpauthor'/>
156 <set attributeName='display' to='none' attributeType='CSS'>
157 <xsl:attribute name='begin'>
158 <xsl:text>title.click</xsl:text>
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")'/>
170 <!-- Create the TOC -->
171 <xsl:if test='foilgroup'>
172 <g id='toc' display='none'>
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"'/>
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'/>
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")'/>
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")'/>
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'>
204 <xsl:when test='count(foilgroup) > $toc.line.max'>
205 <xsl:text>50</xsl:text>
207 <xsl:otherwise>75</xsl:otherwise>
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")'/>
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")'/>
228 <xsl:apply-templates select='*[not(self::slidesinfo)]'/>
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'/>
239 <!-- id is a required parameter to include in the generated graphics.
240 - This is important for slide transitions.
242 <xsl:param name='id'/>
244 <!-- This background covers most of the foil area,
245 - but leaves a space in the lower left corner for the
250 <xsl:when test='$mode = "toc"'>
253 <rect width='{2 * $foil.width}' height='75' style='fill: {$toc.bg.color}; stroke: none'/>
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"/>
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"/>
268 <xsl:template match='author'>
269 <text x='50%' y='60%' text-anchor='middle' xsl:use-attribute-sets='text-author'>
271 <xsl:apply-templates select='firstname'/>
274 <xsl:text> </xsl:text>
277 <xsl:apply-templates select='surname'/>
279 <xsl:if test='affiliation'>
281 <xsl:apply-templates select='affiliation'/>
286 <xsl:template match='corpauthor'>
287 <text x='50%' y='70%' text-anchor='middle' xsl:use-attribute-sets='text-author'>
288 <xsl:apply-templates/>
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'/>
299 <xsl:when test='not($nodes)'/>
302 <xsl:for-each select='$nodes[position() <= $toc.line.max]'>
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'/>
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>
315 <xsl:value-of select='title'/>
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'/>
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'/>
335 <xsl:template match='foilgroup'>
336 <xsl:variable name='fg-num' select='count(preceding-sibling::foilgroup) + 1'/>
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")'/>
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'/>
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'>
352 <xsl:when test='$fg-num = 1'>
353 <xsl:text>index-foilgroup-1.click; toc.click; toc-content.click</xsl:text>
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>
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'>
374 <xsl:when test='count(/slides/foilgroup) > $toc.line.max'>
375 <xsl:text>50</xsl:text>
377 <xsl:otherwise>75</xsl:otherwise>
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'>
384 <xsl:when test='$fg-num = 1'>
385 <xsl:text>index-foilgroup-1.click; toc.click; toc-content.click</xsl:text>
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>
399 <!-- still want TOC and Previous buttons -->
401 <xsl:apply-templates select='foil'/>
404 <xsl:template match='foil'>
405 <xsl:variable name='number' select='count(preceding-sibling::foil|preceding::foil) + 1'/>
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")'/>
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'>
415 <xsl:when test='parent::foilgroup'>
416 <xsl:value-of select='../title'/>
419 <xsl:value-of select='/slides/slidesinfo/title'/>
424 <tspan id='foil{$number}-title-foil' xsl:use-attribute-sets='text-title'>
425 <xsl:value-of select='title'/>
429 <g transform='translate(50 100)'>
430 <xsl:apply-templates select='*[not(self::title)][1]'/>
433 <xsl:call-template name='foil-events'>
434 <xsl:with-param name='number' select='$number'/>
439 <!-- Add previous and TOC buttons
440 - (no need for next, mouse click does that)
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'/>
450 <xsl:call-template name='foil-events'>
451 <xsl:with-param name='number' select='$number'/>
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'/>
463 <xsl:call-template name='foil-events'>
464 <xsl:with-param name='number' select='$number'/>
472 <!-- The application may override these -->
473 <xsl:template name='toc-button'/>
474 <xsl:template name='previous-button'/>
476 <xsl:template match='foilinfo|foil/title|foil/subtitle|foil/titleabbrev'/>
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"'/>
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.
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'>
499 <xsl:when test='parent::foilgroup'>
500 <xsl:value-of select='concat("toc-sep-", count(preceding::foilgroup) + 1, ".click")'/>
503 <xsl:text>title.click</xsl:text>
506 <xsl:if test='parent::foilgroup and not(preceding-sibling::foil)'>
507 <xsl:value-of select='concat("; index-foilgroup-", count(preceding::foilgroup) + 1, ".click")'/>
509 <xsl:value-of select='concat("; foil", $number + 1, "-previous-button.click")'/>
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'>
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")'/>
523 <xsl:value-of select='concat("foil", $number - 1, ".click")'/>
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")'/>
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")'/>
539 <xsl:value-of select='concat("; foil", $number - 1, ".click")'/>
549 <xsl:template match="para">
550 <xsl:variable name='depth'>
552 <xsl:when test='@depth'>
553 <xsl:value-of select='@depth'/>
556 <xsl:text>1</xsl:text>
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'/>
569 <xsl:attribute name='x'>
570 <xsl:value-of select='25 * $depth'/>
572 <xsl:if test='@style'>
573 <xsl:attribute name='style'>
574 <xsl:value-of select='@style'/>
578 <xsl:apply-templates/>
581 <xsl:apply-templates select='following-sibling::*[1]'/>
585 <xsl:template match='text()'>
587 <xsl:value-of select='.'/>
591 <xsl:template match='emphasis'>
592 <xsl:variable name='style'>
594 <xsl:when test='@role = "bold"'>
595 <xsl:text>font-weight: bold</xsl:text>
597 <xsl:when test='@role = "italic"'>
598 <xsl:text>font-style: italic</xsl:text>
601 <xsl:text>font-style: italic</xsl:text>
606 <tspan style='{$style}'>
607 <xsl:value-of select='.'/>
611 <xsl:template match='listitem'>
612 <xsl:call-template name="bullet"/>
613 <g transform='translate(20 0)'>
614 <xsl:apply-templates/>
618 <xsl:template name="bullet">
620 <xsl:when test="@depth = 1 or count(ancestor-or-self::listitem) = 1">
621 <xsl:call-template name="large-filled-circle"/>
623 <xsl:when test="@depth = 2 or count(ancestor-or-self::listitem) = 2">
624 <xsl:call-template name="small-open-circle"/>
626 <xsl:when test="@depth = 3 or count(ancestor-or-self::listitem) = 3">
627 <xsl:call-template name="small-filled-circle"/>
629 <xsl:when test="@depth = 4 or count(ancestor-or-self::listitem) = 4">
630 <xsl:call-template name="closed-toggle"/>
632 <xsl:when test="@depth = 5 or count(ancestor-or-self::listitem) = 5">
633 <xsl:call-template name="large-filled-circle"/>
636 <xsl:call-template name="small-open-box"/>
641 <xsl:template name="closed-toggle">
642 <polyline fill="white" stroke="black" stroke-width="1" points="0 0 10 5 0 10 0 0"/>
644 <xsl:template name="large-filled-circle">
645 <circle fill="black" cx="10" cy="6" r="5"/>
647 <xsl:template name="small-filled-circle">
648 <circle fill="black" cx="10" cy="6" r="2.5"/>
650 <xsl:template name="small-open-circle">
651 <circle fill="none" stroke="black" stroke-width="1" cx="10" cy="6" r="2.5"/>
653 <xsl:template name="small-open-box">
654 <rect fill="none" stroke="black" stroke-width="1" x="5" y="5" width="5" height="5"/>
657 <xsl:template match="subject">
658 <tspan style="font-weight: bold">
659 <xsl:apply-templates/>
663 <xsl:template match="informalexample">
665 <xsl:template match="programlisting">
666 <!-- Output lines verbatim -->
669 <xsl:template match="imageobject|mediaobject">
670 <xsl:apply-templates/>
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'/>
679 <xsl:template match='ulink'>
680 <a xlink:href='{@url}'>
681 <xsl:apply-templates/>