<?xml version="1.0" encoding="UTF-8"?>
<!-- Common variables, functions, etc, used by SVG generator stylesheets -->
<!-- I. Herman $Date: 2004/02/13 08:40:27 $ -->
<!--
     Copyright (c) 2003 W3C
     See http://www.w3.org/Consortium/Legal/copyright-software-19980720
     for W3C software licensing (open source compatible)
     Author: Ivan Herman <ivan@w3.org>     
-->
<!-- !!!!!! If you use XML Spy (or other tools with automatic XML formatting), be careful!     -->
<!-- Some of those may introduce extra spaces which may destroy, for example, d attributes in  -->
<!-- SVG path elements, or the output of text! Better avoid it for this file.                  -->
<!-- *********************************************************************** -->
<!-- FOR XSLT 2.0: the extension elements related to SAXON should be deleted -->
<!-- *********************************************************************** -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" extension-element-prefixes="saxon" xmlns:saxon="http://icl.com/saxon" xmlns:x="http://www.w3.org/1999/xhtml" xmlns:slide="http://www.w3.org/Consortium/Offices/Presentation/xsltSlidemaker" xmlns:xlink="http://www.w3.org/1999/xlink">
  <xsl:include href="common.xsl"/>
  <!-- ================================================================== -->
  <!-- ================================================================== -->
  <!-- Some of the variables below can be adapted by the user             -->
  <!-- for genearal customizations, see the 'common.xsl' file!            -->
  <!-- this file is specific to the SVG output                            -->
  <!-- ================================================================== -->
  <!-- ================================================================== -->
  <!-- Default values for the meta statements                             -->
  <!-- Width of the Logo                                                  -->
  <xsl:variable name="Logo_WDefault">72</xsl:variable>
  <!-- Height of the Logo                                                 -->
  <xsl:variable name="Logo_HDefault">48</xsl:variable>
  <!-- Separate SVG CSS is necessary?                                     -->
  <xsl:variable name="SeparateCSSDefault">true</xsl:variable>
  <!-- ================================================================== -->
  <!-- Variables controlling the general outlook of the slides            -->
  <!-- (primarily size variables)                                         -->
  <!--    -->
  <!-- Variables for the table of content                                 -->
  <!-- Number of items per coloumn                                        -->
  <xsl:variable name="dColH">25</xsl:variable>
  <!-- Distances for the coloumns' placement horizontally                 -->
  <xsl:variable name="dColW">160</xsl:variable>
  <!-- Downward step in the coloumns from one cell to the other           -->
  <xsl:variable name="dColTH">29</xsl:variable>
  <!-- Font size used for the table of content items                      -->
  <xsl:variable name="tocFontS">14</xsl:variable>
  <!--    -->
  <!-- Variables for the overal size of the slides                        -->
  <!-- Width of a slide (used in the viewBox attribute of the slide!)     -->
  <xsl:variable name="WDefault">1220</xsl:variable>
  <!-- Height of a slide (used in the viewBox attribute of the slide!)    -->
  <xsl:variable name="HDefault">915</xsl:variable>
  <!-- Default values for slide content sizes                             -->
  <xsl:variable name="sWDefault">1170</xsl:variable>
  <xsl:variable name="sHDefault">795</xsl:variable>
  <xsl:variable name="sXDefault">25</xsl:variable>
  <xsl:variable name="sYDefault">80</xsl:variable>
  <!-- Width and height of the slide's viewbox                            -->
  <xsl:variable name="W">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='W']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='W']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$WDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="H">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='H']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='H']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$HDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <!-- Width of the slide content (the real content area)                 -->
  <xsl:variable name="sW">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='sW']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='sW']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$sWDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <!-- Height of the slide content (the real content area)                -->
  <xsl:variable name="sH">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='sH']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='sH']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$sHDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <!-- X position of the top left corner of the content area              -->
  <xsl:variable name="sX">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='sX']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='sX']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$sXDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <!-- Y position of the top left corner of the content area              -->
  <xsl:variable name="sY">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='sY']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='sY']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$sYDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <!--   -->
  <!-- Variables controlling the text item generations                       -->
  <!-- Minimum left indent for all items (from the left of the content part) -->
  <!-- Nested list items will also use this as an indentation step           -->
  <xsl:variable name="dx">35</xsl:variable>
  <!-- 'Vertical step' for items, small and big                              -->
  <!-- depending on context, the small or the bigger step will be used, eg,  -->
  <!-- to separate a first level list items from the others                  -->
  <xsl:variable name="dyS">50</xsl:variable>
  <xsl:variable name="dyB">60</xsl:variable>
  <!-- 'Vertical step' for 'pre' items, ie, code examples. Typically, the    -->
  <!-- characters are slighly smaller, hence the vertical step should be     -->
  <!-- smaller, too                                                          -->
  <xsl:variable name="dyPre">30</xsl:variable>
  <!-- ========================================================================= -->
  <!-- If you know SVG, you can also fiddle around with the functions below      -->
  <!-- ========================================================================= -->
  <!--    Creation in the defintion section of: -->
  <!--       - path Definition of the arrows and the upward links                -->
  <!--       - basic geometry and gradients used by the tooltips                 -->
  <!--       - filters used for the title text                                   -->
  <!-- You can change the geometry if you want, just keep the 'id' values        -->
  <xsl:template name="title_effects">
    <filter id="title_effects" xmlns="http://www.w3.org/2000/svg">
      <feGaussianBlur in="SourceAlpha" stdDeviation="4.5" result="blur"/>
      <feSpecularLighting in="blur" surfaceScale="8" specularConstant="1.5" specularExponent="20" result="specOut" class="title">
        <fePointLight x="-5000" y="-10000" z="10000"/>
      </feSpecularLighting>
      <feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
      <feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0"/>
    </filter>
  </xsl:template>
  <xsl:template name="linkFigures">
    <filter id="arrow_effects" xmlns="http://www.w3.org/2000/svg">
      <feGaussianBlur in="SourceAlpha" stdDeviation="4.5" result="blur"/>
      <feSpecularLighting in="blur" surfaceScale="8" specularConstant="1.5" specularExponent="20" result="specOut" class="arrow">
        <fePointLight x="-5000" y="-10000" z="10000"/>
      </feSpecularLighting>
      <feComposite in="specOut" in2="SourceAlpha" operator="in" result="specOut"/>
      <feComposite in="SourceGraphic" in2="specOut" operator="arithmetic" k1="0" k2="1" k3="1" k4="0"/>
    </filter>
    <g id="Arrow" xmlns="http://www.w3.org/2000/svg">
      <g transform="scale(1.4)">
        <path class="linkArrow" d="M-12,12Q-4,0,-12,-12L15,0z"/>
      </g>
    </g>
    <g id="rightArrow" xmlns="http://www.w3.org/2000/svg" filter="url(#arrow_effects)">
      <use xlink:href="#Arrow"/>
    </g>
    <g id="leftArrow" xmlns="http://www.w3.org/2000/svg" filter="url(#arrow_effects)">
      <use transform="scale(-1,1)" xlink:href="#Arrow"/>
    </g>
    <circle r="10" class="linkArrow" id="upArrow" xmlns="http://www.w3.org/2000/svg" filter="url(#arrow_effects)"/>
    <linearGradient id="tooltip-back" x1="0%" y1="100%" x2="0%" y2="0%" xmlns="http://www.w3.org/2000/svg">
      <stop offset="20%" id="tooltip-back-c1"/>
      <stop offset="70%" id="tooltip-back-c2"/>
      <stop offset="100%" id="tooltip-back-c3"/>
    </linearGradient>
    <linearGradient id="tooltip-forward" x1="0%" y1="100%" x2="0%" y2="0%" xmlns="http://www.w3.org/2000/svg">
      <stop offset="20%" id="tooltip-forward-c1"/>
      <stop offset="70%" id="tooltip-forward-c2"/>
      <stop offset="100%" id="tooltip-forward-c3"/>
    </linearGradient>
    <rect width="150" height="30" id="tip-back" xmlns="http://www.w3.org/2000/svg" style="fill:url(#tooltip-back); stroke:black"/>
    <rect width="150" height="30" id="tip-forward" xmlns="http://www.w3.org/2000/svg" style="fill:url(#tooltip-forward); stroke:black"/>
    <clipPath id="tipClip" xmlns="http://www.w3.org/2000/svg">
      <rect width="136" height="30" x="8"/>
    </clipPath>
  </xsl:template>
  <!--    Creation of the frame around the content area. It consists of four     -->
  <!-- nearly identical groups, each of a dark and a light coloured part.        -->
  <!-- The exact colours are set in the CSS file. You can change the geometry of -->
  <!-- the frame, or make the full function empty if you do not want a frame at  -->
  <!-- all!                                                                      -->
  <xsl:template name="frameDef">
    <xsl:variable name="frW">
      <xsl:value-of select="$sW + 12"/>
    </xsl:variable>
    <xsl:variable name="frH">
      <xsl:value-of select="$sH + 12"/>
    </xsl:variable>
    <g transform="translate(-6,-6)" id="frame" xmlns="http://www.w3.org/2000/svg">
      <g>
        <xsl:comment>Top horizontal frame</xsl:comment>
        <path class="frameLight">
          <xsl:attribute name="d"><xsl:value-of select="concat('M0,0 h',$frW,' l-3,3 h-',$frW - 6,'z')"/></xsl:attribute>
        </path>
        <path class="frameDark">
          <xsl:attribute name="d"><xsl:value-of select="concat('M3,3 h',$frW - 6,' l-2,2 h-',$frW - 10,'z')"/></xsl:attribute>
        </path>
      </g>
      <g>
        <xsl:comment>Left vertical frame</xsl:comment>
        <path class="frameLight">
          <xsl:attribute name="d"><xsl:value-of select="concat('M0,0 v',$frH,' l3,-3 v-',$frH - 6,'z')"/></xsl:attribute>
        </path>
        <path class="frameDark">
          <xsl:attribute name="d"><xsl:value-of select="concat('M3,3 v',$frH - 6,' l2,-2 v-',$frH - 10,'z')"/></xsl:attribute>
        </path>
      </g>
      <g>
        <xsl:attribute name="transform"><xsl:value-of select="concat('translate(',$frW,')')"/></xsl:attribute>
        <xsl:comment>Right vertical frame</xsl:comment>
        <path class="frameDark">
          <xsl:attribute name="d"><xsl:value-of select="concat('M0,0 v',$frH,' l-3,-3 v-',$frH - 6,'z')"/></xsl:attribute>
        </path>
        <path class="frameLight">
          <xsl:attribute name="d"><xsl:value-of select="concat('M-3,3 v',$frH - 6,' l-2,-2 v-',$frH - 10,'z')"/></xsl:attribute>
        </path>
      </g>
      <g>
        <xsl:attribute name="transform"><xsl:value-of select="concat('translate(0,',$frH,')')"/></xsl:attribute>
        <xsl:comment>Bottom horizontal frame</xsl:comment>
        <path class="frameDark">
          <xsl:attribute name="d"><xsl:value-of select="concat('M0,0 h',$frW,' l-3,-3 h-',$frW - 6,'z')"/></xsl:attribute>
        </path>
        <path class="frameLight">
          <xsl:attribute name="d"><xsl:value-of select="concat('M3,-3 h',$frW - 6,' l-2,-2 h-',$frW - 10,'z')"/></xsl:attribute>
        </path>
      </g>
    </g>
  </xsl:template>
  <!-- Replace the default W3C logo by an SVG version                 -->
  <!-- This option is superceeded if the user gives a different logo! -->
  <xsl:template name="logoDef">
    <xsl:if test="string-length($Logo) != 0">
      <xsl:choose>
        <xsl:when test="contains($Logo,'w3chome')">
          <g xmlns="http://www.w3.org/2000/svg" id="SlideLogo" transform="translate(30,15) scale(1.2)">
            <svg height="51" width="90" viewBox="0 0 90 51">
              <rect class="w3clogoBackground" y="-2" x="-1" width="91" height="45"/>
              <g>
                <path d="M74.5,.2l0.8,5.1l-3,5.6c0,0-1.13-2.39-3-3.7
                              c-1.6-1.1-2.6-1.4-4.2-1c-2.1,0.4-4.4,2.9-5.4,5.9
                              c-1.2,3.6-1.2,5.4-1.3,7c-0.07,2.6,0.3,4.14,0.3,4.1
                              s-1.8-3.3-1.8-8.1c0.01-3.5,0.6-6.6,2.2-9.7
                              c1.41-2.7,3.5-4.4,5.4-4.5c1.9-0.2,3.4,0.7,4.6,1.7
                              c1.2,1,2.5,3.3,2.5,3.4z"/>
                <path d="M74.9,28.8c0,0-1.3,2.3-2.1,3.2c-.8.9-2.3,2.5-4.1,3.3
                              c-1.8.8-2.7.9-4.5,0.8c-1.8-.2-3.4-1.2-4-1.6s-2-1.7-2.9-2.9
                              c-.8-1.2-2.1-3.5-2.1-3.5s.7,2.4,1.2,3.3c.3.6,1.1,2.3,2.2,3.9
                              c1.1,1.4,3.1,3.9,6.3,4.4c3.1,.6,5.3-.9,5.8-1.2c.5-.3,1.7-1.3,2.4-2.1
                              c.7-.8,1.4-1.8,1.8-2.4c.3-.4,0.7-1.3.7-1.3z"/>
                <path style="fill:#0C479D" d="M20.7,0.43l7.1,24.1l7.1-24.1h5.1l-11.7,39.6
                              h-.5l-7.35-24.5l-7.35,24.5h-.5l-11.7-39.6h5.1l7.1,24.1l4.8-16.2l-2.3-7.9z"/>
                <path style="fill:#0C479D" d="M54.6,27.3c0,3.6-1,6.6-2.9,9
                              c-1.9,2.4-4.4,3.7-7.4,3.7c-2.3,0-4.3-0.7-5.9-2.2
                              c-1.7-1.4-2.9-3.4-3.8-5.9l4-1.7c.6,1.5,1.4,2.7,2.3,3.5
                              c1,.9,2.1,1.3,3.4,1.3c1.4,0,2.5-.8,3.5-2.3
                              c.9-1.5,1.4-3.4,1.4-5.5c0-2.4-.5-4.2-1.5-5.5
                              c-1.2-1.5-3-2.3-5.5-2.3h-2v-2.3l6.8-11.8h-8.2l-2.3,3.9
                              h-1.5v-8.7h19.1v2.4l-7.2,12.5c2.5.8,4.5,2.3,5.8,4.4
                              c1.3,2.1,2,4.7,1.9,7.5z"/>
                <text x="78" y="10" style="font-size:13">&#174;</text>
              </g>
            </svg>
          </g>
        </xsl:when>
        <xsl:otherwise>
          <image xmlns="http://www.w3.org/2000/svg" x="{$sX}" y="10" xlink:href="{$Logo}" height="{$LogoH}" width="{$LogoW}" id="SlideLogo">
            <desc>Logo, as specified by the author</desc>
          </image>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>
  <!-- ======================================================== -->
  <!-- ======================================================== -->
  <!-- If you begin to mess around with thing below, you should -->
  <!-- really know what you are doing!!!!!!!!!!!!!!!!           -->
  <!-- ======================================================== -->
  <!-- ======================================================== -->
  <xsl:variable name="BackgroundXML">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='SVGBackgroundXML']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='SVGBackgroundXML']/@content"/>
      </xsl:when>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="LogoW">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='Logo_W']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='Logo_W']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$Logo_WDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="LogoH">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='Logo_H']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='Logo_H']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$Logo_HDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="SeparateCSS">
    <xsl:choose>
      <xsl:when test="/x:html/x:head/x:meta[@name='SeparateCSS']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='SeparateCSS']/@content"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$SeparateCSSDefault"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:template name="getCssSVG">
    <xsl:param name="obj"/>
    <xsl:choose>
      <xsl:when test="$obj/@slide:cssSVGSlideIncl">
        <xsl:value-of select="$obj/@slide:cssSVGSlideIncl"/>
      </xsl:when>
      <xsl:when test="/x:html/x:head/x:meta[@name='cssSVGSlideIncl']">
        <xsl:value-of select="/x:html/x:head/x:meta[@name='cssSVGSlideIncl']/@content"/>
      </xsl:when>
      <xsl:otherwise/>
    </xsl:choose>
  </xsl:template>
  <!-- ================================================================== -->
  <!--           Slide background                                         -->
  <!-- ================================================================== -->
  <xsl:template name="slideBackgroundPattern">
    <xsl:choose>
      <xsl:when test="string-length($BackgroundXML) != 0">
        <xsl:comment>Included pattern for the background, as provided by the user</xsl:comment>
        <xsl:for-each select="document($BackgroundXML)/*">
          <xsl:copy-of select="."/>
        </xsl:for-each>
      </xsl:when>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="slideBackground">
    <xsl:choose>
      <xsl:when test="string-length($BackgroundXML) != 0">
        <xsl:comment>Slide background, to possibly give a distinct colour, but also refers to an external pattern or gradient</xsl:comment>
        <rect xmlns="http://www.w3.org/2000/svg" class="Background" style="fill:url(#_Background)" width="{$W}" height="{$H}" id="Background"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:comment>Slide background, to possibly give a distinct colour</xsl:comment>
        <rect xmlns="http://www.w3.org/2000/svg" class="Background" width="{$W}" height="{$H}" id="Background"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!-- ================================================================== -->
  <!--           Creation of a slide title and background                 -->
  <!-- ================================================================== -->
  <xsl:template name="titleBackground">
    <xsl:param name="title"/>
    <title xmlns="http://www.w3.org/2000/svg">
      <xsl:value-of select="$title"/>
    </title>
    <xsl:call-template name="slideBackground"/>
    <xsl:comment>Slide header area, again to give  distinct colour if wanted</xsl:comment>
    <xsl:variable name="TH">
      <xsl:value-of select="$sY - 6"/>
    </xsl:variable>
    <xsl:variable name="TW">
      <xsl:value-of select="$W - (2* $sXDefault) + 12"/>
    </xsl:variable>
    <xsl:variable name="Tx">
      <xsl:value-of select="$sXDefault - 6"/>
    </xsl:variable>
    <rect xmlns="http://www.w3.org/2000/svg" id="TitleArea" width="{$TW}" height="{$TH}" x="{$Tx}" rx="10" ry="10"/>
    <xsl:if test="string-length($Logo) != 0">
      <g class="slideTitleArea" xmlns="http://www.w3.org/2000/svg">
        <xsl:choose>
          <xsl:when test="string-length($LogoURI) = 0">
            <use xlink:href="#SlideLogo"/>
          </xsl:when>
          <xsl:otherwise>
            <a xlink:href="{$LogoURI}">
              <use xlink:href="#SlideLogo"/>
            </a>
          </xsl:otherwise>
        </xsl:choose>
      </g>
    </xsl:if>
  </xsl:template>
  <xsl:template name="createSlideTitle">
    <xsl:param name="title"/>
    <xsl:call-template name="titleBackground">
      <xsl:with-param name="title" select="$title"/>
    </xsl:call-template>
    <g class="slideTitleArea" xmlns="http://www.w3.org/2000/svg">
      <text y="50" class="slideTitle" x="{$W div 2}" filter="url(#title_effects)">
        <xsl:value-of select="$title"/>
      </text>
    </g>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                  Creation of the general metadata                  -->
  <!-- ================================================================== -->
  <xsl:template name="addMetadata">
  	<xsl:param name="title"/>
  	<metadata xmlns="http://www.w3.org/2000/svg">
		<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:contact="http://www.w3.org/2000/10/swap/pim/contact#">
			<rdf:Description rdf:about="">
				<dc:title xml:lang="{$documentLanguage}"><xsl:value-of select="$title"/></dc:title>
				<dc:format>image/svg+xml</dc:format>
				<dc:date xml:lang="{$documentLanguage}"><xsl:value-of select="$Date"/></dc:date>
				<dc:creator>
					<contact:Person>
						<contact:fullName xml:lang="{$documentLanguage}"><xsl:value-of select="$Author"/></contact:fullName>
						<contact:emailURI><xsl:value-of select="$AuthorURL"/></contact:emailURI>
					</contact:Person>
				</dc:creator>
				<dc:language><xsl:value-of select="$documentLanguage"/></dc:language>
				<dc:publisher><xsl:value-of select="$Organization"/></dc:publisher>
				<dc:rights>
					<xsl:attribute name="resource" namespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
						<xsl:value-of select="$CopyrightLink"/>
					</xsl:attribute>
				</dc:rights>
				<rdfs:seeAlso>
					<xsl:attribute name="resource" namespace="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
						<xsl:value-of select="$SlidesURL"/>
					</xsl:attribute>
				</rdfs:seeAlso>
			</rdf:Description>
		</rdf:RDF>
	</metadata>
  </xsl:template>  
  <!-- ================================================================== -->
  <!--                  Creation of the title page content                -->
  <!-- ================================================================== -->
  <xsl:template name="titlePageContent">
    <g class="slideContent" xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="transform"><xsl:value-of select="concat('translate(',$sX,' ',$sY,')')"/></xsl:attribute>
      <xsl:comment>Slide content area, to possibly give another colour</xsl:comment>
      <rect class="slideContent" width="{$sW + 10}" height="{$sH + 10}" x="-5" y="-5">
        <xsl:if test="$KeyPress = 'true'">
          <xsl:attribute name="id">slideContent</xsl:attribute>
        </xsl:if>
      </rect>
      <xsl:comment>The nice frame (just for the fun of it...</xsl:comment>
      <use xlink:href="#frame"/>
      <xsl:variable name="XPos">
        <xsl:value-of select="$sW div 2.0"/>
      </xsl:variable>
      <xsl:variable name="YPos">
        <xsl:value-of select="120 + $sY"/>
      </xsl:variable>
      <g>
        <xsl:attribute name="transform"><xsl:value-of select="concat('translate(',$XPos,',',$YPos,')')"/></xsl:attribute>
        <text class="TitleMajor" style="font-style:italic" y="0" filter="url(#title_effects)">
          <xsl:value-of select="$OverallTitle"/>
        </text>
        <text y="120">
          <tspan x="0" dy="0" class="TitleMinor">
            <xsl:value-of select="$Author"/>
          </tspan>
          <xsl:if test="$Event">
            <tspan x="0" dy="120" class="TitleMinor2">
              <xsl:value-of select="$Event"/>
            </tspan>
          </xsl:if>
          <tspan x="0" dy="60" class="TitleMinor2">
            <xsl:value-of select="$Date"/>
          </tspan>
          <xsl:if test="$SlidesURL">
            <tspan x="0" dy="120" class="TitleMinor2">
              <xsl:value-of select="$SlidesURL"/>
            </tspan>
          </xsl:if>
        </text>
      </g>
    </g>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                  Creation of a slide content                       -->
  <!-- ================================================================== -->
  <xsl:template name="createSlideContent">
    <xsl:param name="slide"/>
    <xsl:param name="pos"/>
    <g class="slideContent" xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="transform"><xsl:value-of select="concat('translate(',$sX,' ',$sY,')')"/></xsl:attribute>
      <xsl:comment>Slide content area, to possibly give another colour</xsl:comment>
      <rect class="slideContent" width="{$sW + 10}" height="{$sH + 10}" x="-5" y="-5">
        <xsl:if test="$KeyPress = 'true'">
          <xsl:attribute name="id">slideContent</xsl:attribute>
        </xsl:if>
      </rect>
      <xsl:comment>The nice frame (just for the fun of it...</xsl:comment>
      <use xlink:href="#frame"/>
      <xsl:variable name="imgs" select="$slide//x:object[@type='image/svg+xml']|$slide//x:img"/>
      <xsl:choose>
        <xsl:when test="count($imgs)=0">
          <!-- the simple case: no embedded svg file, or image -->
          <text transform="translate(5)">
            <xsl:apply-templates/>
          </text>
        </xsl:when>
        <xsl:when test="count($imgs)!=1">
          <xsl:message>Sorry, only one image per slide can be used....</xsl:message>
        </xsl:when>
        <xsl:otherwise>
          <xsl:variable name="obj" select="$imgs[1]"/>
          <xsl:variable name="imgW">
            <xsl:call-template name="imageWidth">
              <xsl:with-param name="obj" select="$obj"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:variable name="imgH">
            <xsl:call-template name="imageHeight">
              <xsl:with-param name="obj" select="$obj"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:variable name="div" select="$obj/parent::*"/>
          <xsl:choose>
            <xsl:when test="$div/@class = 'center' or $div/@class = 'centre'">
              <xsl:variable name="two" select="'2'"/>
              <xsl:variable name="imgX" select="($sW - $imgW) div $two"/>
              <xsl:call-template name="generateContent">
                <xsl:with-param name="W" select="$imgW * 0.99"/>
                <xsl:with-param name="H" select="$imgH * 0.99"/>
                <xsl:with-param name="X" select="$imgX"/>
                <xsl:with-param name="img" select="$obj"/>
                <xsl:with-param name="textStart" select="$obj/parent::*[1]"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="generateContent">
                <xsl:with-param name="W" select="$imgW * 0.99"/>
                <xsl:with-param name="H" select="$imgH * 0.99"/>
                <xsl:with-param name="X" select="'0'"/>
                <xsl:with-param name="img" select="$obj"/>
                <xsl:with-param name="textStart" select="$obj"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </g>
    <!-- Add the signature to the bottom -->
    <xsl:call-template name="signature">
      <xsl:with-param name="slideNumber" select="$pos"/>
    </xsl:call-template>
  </xsl:template>
  <!-- ================================================================== -->
  <!--       Positioning of the image and the text on the slide page      -->
  <!-- The possible 'float' style attribute is also taken into account!   -->
  <!-- ================================================================== -->
  <xsl:template name="generateContent">
    <xsl:param name="W"/>
    <xsl:param name="H"/>
    <xsl:param name="X"/>
    <xsl:param name="img"/>
    <xsl:param name="textStart"/>
    <xsl:variable name="IBorder" select="'10'"/>
    <xsl:variable name="float">
      <xsl:call-template name="returnAttr">
        <xsl:with-param name="element" select="$img"/>
        <xsl:with-param name="key" select="'float'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="iY">
      <xsl:choose>
        <xsl:when test="count($textStart/preceding-sibling::*) = 1">
          <xsl:value-of select="$IBorder"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$sH - $H - $IBorder"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="iX">
      <xsl:choose>
        <xsl:when test="$float = 'right'">
          <xsl:value-of select="$sW - $W - $IBorder"/>
        </xsl:when>
        <xsl:when test="$float = 'left'">
          <xsl:value-of select="$IBorder"/>
        </xsl:when>
        <xsl:when test="$X = '0'">
          <xsl:value-of select="$IBorder"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$X"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <g xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="transform"><xsl:value-of select="concat('translate(',$iX,',',$iY,')')"/></xsl:attribute>
      <!-- There is a bug in ASV3, somehow related to included svg images which refer to their
            own css files. As a consequence, the result of the process below does not properly work.
            Tabled until ASV6 comes out where, hopefully, this bug will not be present...
            <xsl:choose>
                <xsl:when test="$SingleSVG = 'true'">
                    <xsl:choose>
                        <xsl:when test="local-name($img) = 'object'">
                            <image xlink:href="{$img/@data}" height="{$H}" width="{$W}">
                                <xsl:if test="$img/@title">
                                    <desc>
                                        <xsl:value-of select="$img/@title"/>
                                    </desc>
                                </xsl:if>
                            </image>
                        </xsl:when>
                        <xsl:otherwise>
                            <image xlink:href="{$img/@src}" height="{$H}" width="{$W}">
                                <xsl:if test="$img/@alt">
                                    <desc>
                                        <xsl:value-of select="$img/@alt"/>
                                    </desc>
                                </xsl:if>
                            </image>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:choose>
                        <xsl:when test="local-name($img) = 'object'">
                            <xsl:call-template name="copySVG">
                                <xsl:with-param name="obj" select="$img"/>
                                <xsl:with-param name="hSize" select="$W"/>
                                <xsl:with-param name="vSize" select="$H"/>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <image xlink:href="{$img/@src}" height="{$H}" width="{$W}">
                                <xsl:if test="$img/@alt">
                                    <desc>
                                        <xsl:value-of select="$img/@alt"/>
                                    </desc>
                                </xsl:if>
                            </image>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:otherwise>
            </xsl:choose>
            -->
      <!-- This is the part which might be replaced with what is above... -->
      <xsl:choose>
        <xsl:when test="local-name($img) = 'object'">
          <xsl:call-template name="copySVG">
            <xsl:with-param name="obj" select="$img"/>
            <xsl:with-param name="hSize" select="$W"/>
            <xsl:with-param name="vSize" select="$H"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <image xlink:href="{$img/@src}" height="{$H}" width="{$W}">
            <xsl:if test="$img/@alt">
              <desc>
                <xsl:value-of select="$img/@alt"/>
              </desc>
            </xsl:if>
          </image>
        </xsl:otherwise>
      </xsl:choose>
      <!-- Until here..... -->
    </g>
    <xsl:if test="count($textStart/preceding-sibling::*) > 1 or count($textStart/following-sibling::*) != 0">
      <!-- There is something else on the slide... -->
      <xsl:variable name="tX">
        <xsl:choose>
          <xsl:when test="$float = 'left'">
            <xsl:value-of select="$W + $IBorder"/>
          </xsl:when>
          <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:variable name="tY">
        <xsl:choose>
          <xsl:when test="$float = 'left' or $float = 'right'">0</xsl:when>
          <xsl:otherwise>
            <xsl:choose>
              <xsl:when test="count($textStart/preceding-sibling::*) = 1">
                <!-- text after the object only -->
                <!-- an extra space is added vertically for the characters! -->
                <xsl:value-of select="$H + $IBorder + 40"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="'0'"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <text xmlns="http://www.w3.org/2000/svg">
        <xsl:attribute name="transform"><xsl:value-of select="concat('translate(',$tX,',',$tY,') translate(5,0)')"/></xsl:attribute>
        <xsl:choose>
          <xsl:when test="count($textStart/preceding-sibling::*) = 1">
            <xsl:apply-templates select="$textStart/following-sibling::*"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates select="$textStart/preceding-sibling::*"/>
          </xsl:otherwise>
        </xsl:choose>
      </text>
    </xsl:if>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                   Javascript portion to allow for keypress         -->
  <!-- ================================================================== -->
  <xsl:template name="navigationJS">
    <xsl:param name="previous"/>
    <xsl:param name="next"/>
    <xsl:comment>Add keyboard event handler</xsl:comment>
    <script type="text/ecmascript" xmlns="http://www.w3.org/2000/svg">
      <xsl:text>
              var indexPage = "</xsl:text>
      <xsl:value-of select="$indexPageSVG"/>
      <xsl:text>";</xsl:text>
      <xsl:text><![CDATA[
              function Slide_init(evt) {
                var svgdoc, kt;
                svgdoc = evt.getTarget().getOwnerDocument();
                kt = svgdoc.getElementById("Background");
                kt.addEventListener("keypress", Slide_handlekeypress, false);
                kt = svgdoc.getElementById("slideContent");
                kt.addEventListener("keypress", Slide_handlekeypress, false);
              }
            ]]></xsl:text>
      <xsl:text>
              function Slide_handlekeypress(evt) {
                var k = evt.getCharCode();
            </xsl:text>
      <xsl:if test="$next != 'dummy'">
        <xsl:text>    if ( k == 32 || k == 78 || k == 110  ) </xsl:text>
        <xsl:text>window.navigate("</xsl:text>
        <xsl:value-of select="$next"/>
        <xsl:text>");</xsl:text>
      </xsl:if>
      <xsl:text/>
      <xsl:if test="$previous != 'dummy'">
        <xsl:text>    if ( k == 80 || k == 112 || k == 8 || k == 127 ) </xsl:text>
        <xsl:text>window.navigate("</xsl:text>
        <xsl:value-of select="$previous"/>
        <xsl:text>");</xsl:text>
      </xsl:if>
      <xsl:text>    if ( k == 85 || k == 117  ) window.navigate(indexPage);</xsl:text>
      <xsl:text>
              }
            </xsl:text>
    </script>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                      Javascript for the flip-flop lists            -->
  <!-- ================================================================== -->
  <xsl:template name="flipScript">
    <script type="text/ecmascript" xmlns="http://www.w3.org/2000/svg">
       function flipList_(evt) {
          target   = evt.getTarget()
          targetId = target.getAttribute("slide:target");
          if( targetId.length == 0 ) return;
          cBullet  = target.firstChild;
          aBullet  = target.getAttribute("slide:bullet");
          tspan    = target.getOwnerDocument().getElementById(targetId);
          var disp = tspan.getAttribute("display");
          if( disp == 'none' ) {
            tspan.setAttribute("display","visible")
            if( cBullet.nodeType == 3 ) cBullet.replaceData(0,1,aBullet);
          } else {
            tspan.setAttribute("display","none")
            if( cBullet.nodeType == 3 ) cBullet.replaceData(0,1,"►");
          }
        }
    </script>
  </xsl:template>
  
  <!-- ================================================================== -->
  <!--                       Object/image dimensions                      -->
  <!--                         Object/image width                         -->
  <!-- ================================================================== -->
  <xsl:variable name="hundr" select="'100'"/>
  <xsl:template name="imageWidth">
    <xsl:param name="obj"/>
    <!-- get the value either from a style or from an attribute -->
    <xsl:variable name="W">
      <xsl:call-template name="returnAttr">
        <xsl:with-param name="element" select="$obj"/>
        <xsl:with-param name="key" select="'width'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="string-length($W) != 0">
        <xsl:variable name="hSize" select="substring-before($W,'%')"/>
        <xsl:choose>
          <xsl:when test="string-length($hSize) = 0">
            <!-- value is not specified in percentages -->
            <xsl:value-of select="$W"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:variable name="displacement" select="$hSize * $sW"/>
            <xsl:value-of select="$displacement div $hundr"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$sW"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!--                         Object/image height                         -->
  <xsl:template name="imageHeight">
    <xsl:param name="obj"/>
    <!-- get the value either from a style or from an attribute -->
    <xsl:variable name="H">
      <xsl:call-template name="returnAttr">
        <xsl:with-param name="element" select="$obj"/>
        <xsl:with-param name="key" select="'height'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="string-length($H) != 0">
        <xsl:variable name="vSize" select="substring-before($H,'%')"/>
        <xsl:choose>
          <xsl:when test="string-length($vSize) = 0">
            <!-- value is not specified in percentages -->
            <xsl:value-of select="$H"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:variable name="displacement" select="$vSize * $sH"/>
            <xsl:value-of select="$displacement div $hundr"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$sH"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                               SVG Copy                             -->
  <!-- ================================================================== -->
  <!-- 
        Function to copy the content of an SVG file to another directory.
        The css reference is changed on the fly to ensure proper display.
        The real copy is done in a separate recursive function, called
        from this template.
    -->
  <xsl:template name="copySVG">
    <xsl:param name="obj"/>
    <xsl:param name="vSize"/>
    <xsl:param name="hSize"/>
    <xsl:variable name="fileName" select="$obj/@data"/>
    <!-- 
            This is a somewhat longish setting of a variable.
            There two possible cases:  the possible setting in the object element itself should take precedence
            over the global setting through meta elements.
        -->
    <xsl:variable name="fromURL">
      <xsl:call-template name="getFromURL">
        <xsl:with-param name="obj" select="$obj"/>
      </xsl:call-template>
    </xsl:variable>
    <!-- 
            This is a somewhat longish setting of a variable.
            There four possible cases: either the css URL should be relative or absolute and,
            in both cases, the possible setting in the object element itself should take precedence
            over the global setting through meta elements.
        -->
    <xsl:variable name="toURL">
      <xsl:call-template name="getToURL">
        <xsl:with-param name="obj" select="$obj"/>
        <xsl:with-param name="orig" select="'svg'"/>
      </xsl:call-template>
    </xsl:variable>
    <!-- 
            The basename of the svg file name is necessary; this is generated through a 
            separate recursive function
        -->
    <xsl:variable name="name">
      <xsl:call-template name="basename">
        <xsl:with-param name="in" select="$fileName"/>
      </xsl:call-template>
    </xsl:variable>
    <!-- The real processing starts here -->
    <xsl:for-each select="document($fileName)/svg">
      <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid" xmlns:appl="http://www.w3.org/Consortium/Offices/Presentation/xsltSlidemaker#slideContent" >
        <!-- The for-each clause is actually unnecessary, we know that there is only one svg element... -->
        <!-- get all the attributes in place -->
        <xsl:for-each select="@*">
          <xsl:copy/>
        </xsl:for-each>
        <xsl:attribute name="width"><xsl:value-of select="$hSize"/></xsl:attribute>
        <xsl:attribute name="height"><xsl:value-of select="$vSize"/></xsl:attribute>
        <!-- Get all the child elements managed by a separate (recursive) function -->
        <xsl:for-each select="child::*">
          <xsl:call-template name="svg">
            <xsl:with-param name="element" select="."/>
            <xsl:with-param name="fromURL" select="$fromURL"/>
            <xsl:with-param name="toURL" select="$toURL"/>
          </xsl:call-template>
        </xsl:for-each>
      </svg>
    </xsl:for-each>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                      Generation of the signature                   -->
  <!-- ================================================================== -->
  <xsl:template name="signature">
    <xsl:param name="slideNumber"/>
    <g class="slideSignatureArea" xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="transform"><xsl:value-of select="concat('translate(',$sXDefault,',',$H - 5,')')"/></xsl:attribute>
      <text class="authorSig">
        <xsl:call-template name="sigList">
          <xsl:with-param name="aFirst" select="substring-before(concat($Author,','),',')"/>
          <xsl:with-param name="uFirst" select="normalize-space(substring-before(concat($AuthorURL,','),','))"/>
          <xsl:with-param name="aRest" select="substring-after(concat($Author,','),',')"/>
          <xsl:with-param name="uRest" select="normalize-space(substring-after(concat($AuthorURL,','),','))"/>
          <xsl:with-param name="target" select="'svg'"/>
        </xsl:call-template>
		<xsl:if test="string-length($Copyright) != 0">
		    <xsl:choose>
				<xsl:when test="string-length($CopyrightLink) != 0">
				    <a xlink:href="{$CopyrightLink}"><xsl:text>; </xsl:text><xsl:value-of select="$Copyright"/></a>
				</xsl:when>
				<xsl:otherwise><xsl:text>; </xsl:text><xsl:value-of select="$Copyright"/></xsl:otherwise>
			</xsl:choose>
		</xsl:if>
      </text>
      <text class="dateSig" x="{$W div 2}">
        <xsl:value-of select="$Date"/>
      </text>
      <text class="slideNumberSig" x="{$sWDefault}">
        <xsl:value-of select="$slideNumber"/> (<xsl:value-of select="$NumberOfSlides"/>)
            </text>
    </g>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                      Generation of the tooltips                    -->
  <!-- ================================================================== -->
  <xsl:template name="tooltips">
    <xsl:param name="previous"/>
    <xsl:param name="next"/>
    <xsl:param name="position"/>
    <xsl:param name="back"/>
    <xsl:param name="forward"/>
    <xsl:variable name="backE1" select="concat($back,'.mouseover')"/>
    <xsl:variable name="backE2" select="concat($back,'.mouseout')"/>
    <xsl:variable name="forE1" select="concat($forward,'.mouseover')"/>
    <xsl:variable name="forE2" select="concat($forward,'.mouseout')"/>
    <xsl:variable name="realPrevious">
      <xsl:choose>
        <xsl:when test="$previous">
          <xsl:value-of select="$previous"/>
        </xsl:when>
        <xsl:otherwise>Title Page</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <g xmlns="http://www.w3.org/2000/svg" transform="{$position}">
      <g transform="translate(-120)" visibility="hidden">
        <use xlink:href="#tip-back"/>
        <text class="tooltip" x="8" y="20" clip-path="url(#tipClip)">
          <xsl:value-of select="$realPrevious"/>
        </text>
        <set attributeName="visibility" to="visible" begin="{$backE1}"/>
        <set attributeName="visibility" to="hidden" begin="{$backE2}"/>
      </g>
      <g transform="translate(-120)" visibility="hidden">
        <use xlink:href="#tip-forward"/>
        <text class="tooltip" x="8" y="20" clip-path="url(#tipClip)">
          <xsl:value-of select="$next"/>
        </text>
        <set attributeName="visibility" to="visible" begin="{$forE1}"/>
        <set attributeName="visibility" to="hidden" begin="{$forE2}"/>
      </g>
    </g>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                    Generate the Stylesheet PI-s                    -->
  <!-- ================================================================== -->
  <xsl:template name="getStyleSheets">
    <xsl:text>&#xA;</xsl:text>
    <xsl:for-each select="/x:html/x:head/x:link[@type='text/css']">
      <xsl:variable name="cssFile">
        <xsl:choose>
          <xsl:when test="$SeparateCSS = 'false'">
            <xsl:value-of select="@href"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="concat(substring-before(@href,'.css'),'SVG','.css')"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:processing-instruction name="xml-stylesheet">href="<xsl:value-of select="$cssFile"/>" type="text/css"</xsl:processing-instruction>
      <xsl:text>&#xA;</xsl:text>
    </xsl:for-each>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                 Get cumulative classes                             -->
  <!-- ================================================================== -->
  <xsl:template name="setAllClasses">
    <xsl:param name="elm"/>
    <xsl:param name="newCl"/>
    <xsl:choose>
      <xsl:when test="$elm/@class">
        <xsl:value-of select="concat($newCl,' ',./@class)"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$newCl"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!-- ================================================================== -->
  <!-- Calculate the list value for an li. It is a recursive function which will
			   - either go back to the first li and thereby return the number for the li
				 - hit an li with a start or value attribute; in this case the recursion stops there
				   and the start/value will be used as an addition to the number accumulated so far
			PROBLEM: My understanding was that when using preceding::siblings, the order is reversed, 
			ie, the [1] refers to the closest sibling to the caller. This does not seem the case.
			I am not sure whether this is an error in saxon or in my understanding of xslt... but
			I am a bit lazy to find that out now!
			-->
  <!-- ================================================================== -->
  <!-- A separate, recursive function is needed to handle the start/value attributes for numbered lists -->
  <xsl:template name="getStart">
    <xsl:param name="node"/>
    <xsl:choose>
      <xsl:when test="$node/@start">
        <xsl:value-of select="$node/@start"/>
      </xsl:when>
      <xsl:when test="$node/@value">
        <xsl:value-of select="$node/@value"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="''"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="getLiValue">
    <xsl:param name="current"/>
    <xsl:param name="list"/>
    <xsl:choose>
      <xsl:when test="count($list) > 0">
        <xsl:variable name="start">
          <xsl:call-template name="getStart">
            <xsl:with-param name="node" select="$list[last()]"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
          <xsl:when test="string-length($start) > 0">
            <xsl:value-of select="$start + $current"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="getLiValue">
              <xsl:with-param name="current" select="$current + 1"/>
              <xsl:with-param name="list" select="$list[position() &lt; last()]"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$current"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!-- ================================================================== -->
  <!--                          General XHTML Patterns                    -->
  <!-- ================================================================== -->
  <xsl:template match="x:p|x:blockquote">
    <xsl:variable name="level">
      <xsl:value-of select="count(ancestor::x:ul|ancestor::x:ol|ancestor::x:dd)"/>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$level = 0">
        <xsl:choose>
          <xsl:when test="local-name(.) = 'blockquote'">
            <xsl:variable name="dy">
              <xsl:choose>
                <xsl:when test="local-name(preceding-sibling::*[1]) = 'blockquote'">
                  <xsl:value-of select="$dyS"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$dyB"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <tspan xmlns="http://www.w3.org/2000/svg" x="{$dx}" dy="{$dy}" class="blockquote">
              <xsl:apply-templates/>
            </tspan>
            <xsl:if test="local-name(following-sibling::*[1]) != 'blockquote'">
              <tspan xmlns="http://www.w3.org/2000/svg" x="0" dy="10">&#x20;</tspan>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <tspan xmlns="http://www.w3.org/2000/svg" x="0" dy="{$dyS}">
              <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="'p'"/></xsl:call-template></xsl:attribute>
              <xsl:apply-templates/>
            </tspan>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="dy">
          <xsl:choose>
            <xsl:when test="$level = 0">
              <xsl:value-of select="$dyB"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$dyS"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:variable name="x">
          <xsl:choose>
            <xsl:when test="local-name(parent::*) = 'dd'">
              <xsl:value-of select="$dx*$level"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$dx*($level + 1)"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <tspan xmlns="http://www.w3.org/2000/svg" dy="{$dy}" x="{$x}">
          <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="concat('li-',$level)"/></xsl:call-template></xsl:attribute>
          <xsl:apply-templates/>
        </tspan>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!-- Generation of a unique ID for binding folded li elements to their contents -->
  <xsl:template name="uniqueId">
    <xsl:param name="node"/>
    <xsl:value-of select="generate-id($node)"/>
  </xsl:template>
  <xsl:template match="x:li">
    <xsl:variable name="level">
      <xsl:value-of select="count(ancestor::x:ul|ancestor::x:ol|ancestor::x:dd)"/>
    </xsl:variable>
    <xsl:variable name="dy">
      <xsl:choose>
        <xsl:when test="$level = 1">
          <xsl:value-of select="$dyB"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$dyS"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="ldx">
      <xsl:choose>
        <xsl:when test="local-name(parent::*) = 'ol'">
          <xsl:value-of select="$dx*($level + 1)+20"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$dx*($level + 1)"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <tspan xmlns="http://www.w3.org/2000/svg" dy="{$dy}" x="{$dx*$level}">
      <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="concat('li-',$level)"/></xsl:call-template></xsl:attribute>
      <xsl:choose>
        <xsl:when test="local-name(parent::*) = 'ol'">
          <!-- Numbered list: have to find the right number and the right numbering style! -->
          <!-- The numbering style is controlled by the enclosing <ol>                     -->
          <!-- Get the list number -->
          <xsl:variable name="numb">
            <xsl:choose>
              <xsl:when test="./@start">
                <xsl:value-of select="./@start"/>
              </xsl:when>
              <xsl:when test="./@value">
                <xsl:value-of select="./@value"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:call-template name="getLiValue">
                  <xsl:with-param name="list" select="preceding-sibling::x:li"/>
                  <xsl:with-param name="current" select="1"/>
                </xsl:call-template>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <!-- try to find the numbering style with list-style-type first -->
          <xsl:variable name="numStyle1">
            <xsl:call-template name="returnAttr">
              <xsl:with-param name="element" select="parent::*"/>
              <xsl:with-param name="key" select="'list-style-type'"/>
            </xsl:call-template>
          </xsl:variable>
          <!-- if not found earlier, try it with the list-style -->
          <xsl:variable name="numStyle">
            <xsl:choose>
              <xsl:when test="string-length($numStyle1) = 0">
                <xsl:call-template name="returnAttr">
                  <xsl:with-param name="element" select="parent::*"/>
                  <xsl:with-param name="key" select="'list-style'"/>
                </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$numStyle1"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:choose>
            <xsl:when test="string-length($numStyle) = 0 or $numStyle = 'decimal'">
              <xsl:number level="single" value="$numb" format="1. "/>
            </xsl:when>
            <xsl:when test="$numStyle = 'lower-roman'">
              <xsl:number level="single" value="$numb" format="i. "/>
            </xsl:when>
            <xsl:when test="$numStyle = 'upper-roman'">
              <xsl:number level="single" value="$numb" format="I. "/>
            </xsl:when>
            <xsl:when test="$numStyle = 'lower-latin' or $numStyle = 'lower-alpha'">
              <xsl:number level="single" value="$numb" format="a. "/>
            </xsl:when>
            <xsl:when test="$numStyle = 'upper-latin' or $numStyle = 'upper-alpha'">
              <xsl:number level="single" value="$numb" format="A. "/>
            </xsl:when>
            <xsl:when test="$numStyle = 'upper-latin' or $numStyle = 'lower-greek'">
              <xsl:number level="single" value="$numb" format="&#x03B1;. " letter-value="traditional"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:number level="single" value="$numb" format="1. "/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
          <!-- Simple bulleted list. The bullet type should be found through the list type attribute.
                         Priority: first the local is searched then the parent
                    -->
          <!-- try to find the numbering style with list-style-type first -->
          <xsl:if test="@slide:fold = 'true'">
            <xsl:attribute name="onclick">flipList_(evt)</xsl:attribute>
            <xsl:attribute name="slide:target">
              <xsl:call-template name="uniqueId">
                <xsl:with-param name="node" select="."/>
              </xsl:call-template>
            </xsl:attribute>
          </xsl:if>
          <xsl:variable name="bulletStyle1">
            <xsl:call-template name="returnAttr">
              <xsl:with-param name="element" select="self::*"/>
              <xsl:with-param name="key" select="'list-style-type'"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:variable name="bulletStyle2">
            <xsl:choose>
              <xsl:when test="string-length($bulletStyle1) = 0">
                <xsl:call-template name="returnAttr">
                  <xsl:with-param name="element" select="."/>
                  <xsl:with-param name="key" select="'list-style'"/>
                </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$bulletStyle1"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:variable name="bulletStyle3">
            <xsl:choose>
              <xsl:when test="string-length($bulletStyle2) = 0">
                <xsl:call-template name="returnAttr">
                  <xsl:with-param name="element" select="parent::*"/>
                  <xsl:with-param name="key" select="'list-style-type'"/>
                </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$bulletStyle2"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:variable name="bulletStyle4">
            <xsl:choose>
              <xsl:when test="string-length($bulletStyle3) = 0">
                <xsl:call-template name="returnAttr">
                  <xsl:with-param name="element" select="parent::*"/>
                  <xsl:with-param name="key" select="'list-style'"/>
                </xsl:call-template>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$bulletStyle3"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:variable name="bulletStyle">
            <xsl:choose>
              <xsl:when test="string-length($bulletStyle4) = 0">
                <xsl:choose>
                  <xsl:when test="$level = 1">disc</xsl:when>
                  <xsl:when test="$level = 2">circle</xsl:when>
                  <xsl:otherwise>square</xsl:otherwise>
                </xsl:choose>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="$bulletStyle4"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:if test="$bulletStyle != 'none'">
            <xsl:variable name="theBullet">
              <xsl:choose>
                <xsl:when test="string-length($bulletStyle) = 0 or $bulletStyle = 'disc'">●</xsl:when>
                <xsl:when test="$bulletStyle = 'circle'">○</xsl:when>
                <xsl:when test="$bulletStyle = 'square'">□</xsl:when>
                <xsl:otherwise>●</xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <xsl:choose>
              <xsl:when test="@slide:fold = 'true'">
                <xsl:attribute name="style">cursor:pointer</xsl:attribute>
                <xsl:attribute name="slide:bullet">▼</xsl:attribute>
                <xsl:text>►</xsl:text>
              </xsl:when>
              <xsl:otherwise><xsl:value-of select="$theBullet"/></xsl:otherwise>
            </xsl:choose>
          </xsl:if>
        </xsl:otherwise>
      </xsl:choose>
      <tspan x="{$ldx}">
        <xsl:if test="@slide:fold = 'true'">
        	<xsl:attribute name="style">cursor:auto</xsl:attribute>
        </xsl:if>        
        <xsl:apply-templates/>
      </tspan>
    </tspan>
  </xsl:template>
  <!-- Do not touch the spacing here!!!!! -->
  <xsl:template match="x:pre">
    <xsl:variable name="dy">
      <xsl:choose>
        <xsl:when test="local-name(preceding-sibling::*[1]) = 'pre'">
          <xsl:value-of select="$dyPre"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$dyS"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:element name="tspan" namespace="http://www.w3.org/2000/svg">
      <xsl:attribute name="x">0</xsl:attribute>
      <xsl:attribute name="dy"><xsl:value-of select="$dy"/></xsl:attribute>
      <xsl:attribute name="xml:space">preserve</xsl:attribute>
      <xsl:attribute name="class"><xsl:choose><xsl:when test="./@class"><xsl:value-of select="concat('pre ',./@class)"/></xsl:when><xsl:otherwise>pre</xsl:otherwise></xsl:choose></xsl:attribute>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>
  <xsl:template match="x:span|x:div">
    <xsl:if test="@class|@style">
      <tspan xmlns="http://www.w3.org/2000/svg">
        <xsl:if test="@class">
          <xsl:attribute name="class"><xsl:value-of select="@class"/></xsl:attribute>
        </xsl:if>
        <xsl:if test="@style">
          <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute>
        </xsl:if>
        <xsl:apply-templates/>
      </tspan>
    </xsl:if>
  </xsl:template>
  <xsl:template match="x:dt">
    <xsl:variable name="level">
      <xsl:value-of select="count(ancestor::x:ul|ancestor::x:ol|ancestor::x:dd)"/>
    </xsl:variable>
    <tspan x="{$dx*$level}" dy="{$dyB}" xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="'dt'"/></xsl:call-template></xsl:attribute>
      <xsl:apply-templates/>
    </tspan>
  </xsl:template>
  <xsl:template match="x:dd">
    <xsl:variable name="level">
      <xsl:value-of select="count(ancestor::x:ul|ancestor::x:ol|ancestor::x:dd)"/>
    </xsl:variable>
    <tspan x="{$dx*($level+1)}" dy="{$dyS}" xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="'dd'"/></xsl:call-template></xsl:attribute>
      <xsl:apply-templates/>
    </tspan>
  </xsl:template>
  <xsl:template match="x:a">
    <a xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="xlink:href"><xsl:value-of select="@href"/></xsl:attribute>
	  <xsl:if test="@target"><xsl:attribute name="target"><xsl:value-of select="@target"/></xsl:attribute></xsl:if>
      <tspan class="a">
        <xsl:apply-templates/>
      </tspan>
    </a>
  </xsl:template>
  <!-- inline elements which are copied as classes into a tspan and are, therefore, easily styleable -->
  <xsl:template match="x:em|x:strong|x:code|x:i|x:b|x:abbr|x:acronym|x:cite|x:dfn|x:kbd|x:var|x:dfn|x:samp|x:abbr|x:q">
    <tspan xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
      <xsl:apply-templates/>
    </tspan>
  </xsl:template>
  <xsl:template match="x:h2|x:h3|x:h4|x:h5|x:h6">
    <tspan xmlns="http://www.w3.org/2000/svg" x="0" dy="{$dyB}">
      <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="local-name(.)"/></xsl:call-template></xsl:attribute>
      <xsl:apply-templates/>
    </tspan>
  </xsl:template>
  <xsl:template match="x:ul|x:dl|x:ol">
    <tspan xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="local-name(.)"/></xsl:call-template></xsl:attribute>
      <xsl:if test="parent::*/@slide:fold = 'true'">
        <xsl:attribute name="display">none</xsl:attribute>
        <xsl:attribute name="id"><xsl:call-template name="uniqueId"><xsl:with-param name="node" select="parent::*"/></xsl:call-template></xsl:attribute>
      </xsl:if>
      <xsl:apply-templates select="node()"/>
    </tspan>
  </xsl:template>
  <xsl:template match="x:table">
    <tspan xmlns="http://www.w3.org/2000/svg">
      <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="local-name(.)"/></xsl:call-template></xsl:attribute>
      <xsl:for-each select="x:tr">
        <xsl:variable name="rows" select="count(x:td|x:th)"/>
        <xsl:variable name="DX" select="$sW div $rows"/>
        <tspan dy="{$dyB}" x="0" class="tr">
          <xsl:for-each select="x:td|x:th">
            <xsl:variable name="xpos" select="$DX * (position()-1)"/>
            <xsl:variable name="xpos2" select="$xpos + ($DX div 2)"/>
            <tspan>
              <xsl:attribute name="x"><xsl:choose><xsl:when test="local-name(.) = 'th'"><xsl:value-of select="$xpos2"/></xsl:when><xsl:otherwise><xsl:value-of select="$xpos"/></xsl:otherwise></xsl:choose></xsl:attribute>
              <xsl:attribute name="class"><xsl:call-template name="setAllClasses"><xsl:with-param name="elm" select="."/><xsl:with-param name="newCl" select="local-name(.)"/></xsl:call-template></xsl:attribute>
              <xsl:apply-templates/>
            </tspan>
          </xsl:for-each>
        </tspan>
      </xsl:for-each>
    </tspan>
  </xsl:template>
  <xsl:template match="x:html">
    <xsl:apply-templates select="node()|@*"/>
  </xsl:template>
  <xsl:template match="x:html/@lang"/>
  <xsl:template match="x:html/@xml:lang"/>
 <xsl:template match="comment()" priority="0.5"/>
  <xsl:template match="node()|@*">
    <xsl:message>Sorry, but <xsl:value-of select="local-name(.)"/> with those attributes is not handled yet...</xsl:message>
  </xsl:template>
  <xsl:template match="x:div[@class = 'svgOnly']">
    <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="x:div[@class = 'htmlOnly']"/>
  <xsl:template match="x:li[@class = 'htmlOnly']"/>
  <xsl:template match="x:p[@class = 'htmlOnly']"/>
  <xsl:template match="x:dd[@class = 'htmlOnly']"/>
  <xsl:template match="x:blockquote[@class = 'htmlOnly']"/>
  <xsl:template match="x:div[@class = 'prologue']"/>
</xsl:stylesheet>
