<?xml version="1.0" encoding="UTF-8"?>
<!-- Stylesheet used to generate a single SVG file with all the slides -->
<!-- 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>     
-->
<!-- *********************************************************************** -->
<!-- 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="svgCommon.xsl"/>
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" omit-xml-declaration="no"/>
    <!-- ======================================================= -->
    <!--     Parameters governing the behaviour of the script    -->
    <!-- ======================================================= -->
    <!--
        If SVG-s are manipulated, the relative URL-s in the files
        have to be changed on the fly. There are two modes for this:
        relative and absolute.
    -->
    <xsl:param name="SVGURLs" select="'relative'"/>
    <!--
        Some common functions may work differently whether one or several svg slides are generated
    -->
    <xsl:variable name="SingleSVG" select="'true'"/>
    <!--
        Generate a separete title page or not
    -->
    <xsl:param name="TitlePage" select="'true'"/>
    <xsl:variable name="KeyPress">false</xsl:variable>
    <xsl:variable name="ZippedReferences" select="'false'"/>
    <!-- 
        The real meat: go through the full input's body.
        In fact, the input is scanned twice, once to generate the overview and once for the individual slide
        files. The first pass dumps the output through one call to saxon:output; the second pass
        uses a separate saxon:output for each individual slide file.
    -->
    <xsl:template match="x:html/x:body">
        <!--  
                The Overview file has two parts, each in its own 'div':
                - a numbered list as links to the slide files
                - a copy of the slides with a possible change of the object's parameters.
                By using the right css statements, the two divs can be made invisible depending
                on whether a projection media is used or not.
            -->
        <xsl:call-template name="getStyleSheets"/>
        <xsl:if test="/x:html/x:head/x:meta[@name='cssSVGSlideIncl']">
            <xsl:processing-instruction name="xml-stylesheet">href="<xsl:value-of select="/x:html/x:head/x:meta[@name='cssSVGSlideIncl']/@content"/>" type="text/css"</xsl:processing-instruction>
        </xsl:if>
        <svg xmlns="http://www.w3.org/2000/svg"  xml:lang="{$documentLanguage}">
            <xsl:attribute name="viewBox">
                <xsl:value-of select="concat('0 0 ',$W,' ',$H)"/>
            </xsl:attribute>
			<xsl:call-template name="addMetadata">
				<xsl:with-param name="title" select="$OverallTitle"/> 
			</xsl:call-template>
            <!-- Add flip-flop javascript -->
            <xsl:call-template name="flipScript"/>
            <xsl:for-each select="/x:html/x:head/x:style">
                <style type="text/css" xmlns="http://www.w3.org/2000/svg">
                    <xsl:copy-of select="./text()"/>
                </style>
            </xsl:for-each>
            <defs>
                <xsl:call-template name="linkFigures"/>
                <xsl:call-template name="title_effects"/>
                <xsl:call-template name="frameDef"/>
                <xsl:call-template name="logoDef"/>
                <g id="tocr">
                    <rect x="-5" y="-{($dColTH div 2)}" class="tocItem" width="{$dColW - 25}" height="{$dColTH - 10}"/>
                </g>
                <xsl:call-template name="slideBackgroundPattern"/>
            </defs>
            <clipPath id="clPP" clipPathUnits="userSpaceOnUse">
                <rect x="-5" y="-{($dColTH div 2)}" fill="none" stroke="black" width="{$dColW - 25}" height="{$dColTH - 10}"/>
            </clipPath>
            <title>
                <xsl:value-of select="$OverallTitle"/>
            </title>
            <style type="text/css">
                <xsl:text>text.toc { font-size:</xsl:text>
                <xsl:value-of select="$tocFontS"/>
                <xsl:text>;}</xsl:text>
            </style>
            <!-- <g id="slide_0" display="block"> -->
            <g>
                <xsl:call-template name="createSlideTitle">
                    <xsl:with-param name="title" select="$OverallTitle"/>
                </xsl:call-template>
                <g class="slideContent">
                    <xsl:attribute name="transform">
                        <xsl:value-of select="concat('translate(',$sXDefault,' ',$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:comment>The nice frame (just for the fun of it...</xsl:comment>
                    <use xlink:href="#frame"/>
                    <g transform="translate(10)">
                        <xsl:attribute name="transform">
                            <xsl:value-of select="concat('translate(20,',1.5*$dColTH,')')"/>
                        </xsl:attribute>
                        <xsl:for-each select="x:div[@class='slide']">
                            <xsl:variable name="x" select="floor(((position()-1) div $dColH)) * $dColW"/>
                            <xsl:variable name="y" select="((position()-1) mod $dColH) * $dColTH"/>
                            <g>
                                <xsl:attribute name="transform">
                                    <xsl:value-of select="concat('translate(',$x,' ',$y,')')"/>
                                </xsl:attribute>
                                <use xlink:href="#tocr">
                                    <set attributeName="display" to="block" begin="click">
                                        <xsl:attribute name="xlink:href">
                                            <xsl:value-of select="concat('#slide_',position())"/>
                                        </xsl:attribute>
                                    </set>
                                </use>
                                <text class="toc" y="3" clip-path="url(#clPP)">
                                    <xsl:value-of select="position()"/>
                                    <xsl:text>. </xsl:text>
                                    <xsl:value-of select="x:h1"/>
                                </text>
                            </g>
                        </xsl:for-each>
                    </g>
                </g>
                <!-- Add the signature to the bottom -->
                <xsl:call-template name="signature">
                    <xsl:with-param name="slideNumber" select="0"/>
                </xsl:call-template>
            </g>
            <!-- Generation of a title page, if required -->
            <xsl:if test="$TitlePage = 'true'">
                <xsl:message>Generate Title Page</xsl:message>
                <g id="slide_0">
                    <xsl:call-template name="titleBackground">
                        <xsl:with-param name="title" select="'Title Page'"/>
                    </xsl:call-template>
                    <g class="slideTitleArea">
                        <xsl:comment>Right Arrow</xsl:comment>
                        <use xlink:href="#rightArrow" id="fw_0">
                            <xsl:attribute name="transform">
                                <xsl:value-of select="concat('translate(',$W - $sXDefault - 12,',40)')"/>
                            </xsl:attribute>
                            <set attributeName="display" to="inline" begin="click" xlink:href="#slide_1"/>
                            <set attributeName="display" to="none" begin="click" xlink:href="#slide_0"/>
                        </use>
                    </g>
                    <xsl:call-template name="titlePageContent"/>
                    <!-- Add the tooltips; these should cover everything else, hence their position in the file -->
                    <xsl:call-template name="tooltips">
                        <xsl:with-param name="position" select="concat('translate(',$W - $sXDefault - 38,',60)')"/>
                        <xsl:with-param name="previous" select="preceding-sibling::x:div[position()=1]/x:h1"/>
                        <xsl:with-param name="next" select="x:div[@class='slide'][position()=1]/x:h1"/>
                        <xsl:with-param name="forward" select="'fw_0'"/>
                    </xsl:call-template>
                </g>
            </xsl:if>
            <!-- Generation of each separate slide file through a cycle on all slide div-s -->
            <xsl:for-each select="x:div[@class='slide']">
                <xsl:variable name="fw_a" select="concat('forward_arrow_',position())"/>
                <xsl:variable name="bw_a" select="concat('back_arrow_',position())"/>
                <xsl:message>Generate slide_<xsl:value-of select="position()"/>
                </xsl:message>
                <g display="none">
                    <xsl:attribute name="id">
                        <xsl:value-of select="concat('slide_',position())"/>
                    </xsl:attribute>
                    <xsl:call-template name="createSlideTitle">
                        <xsl:with-param name="title" select="./x:h1"/>
                    </xsl:call-template>
                    <g class="slideTitleArea">
                        <xsl:attribute name="transform">
                            <xsl:value-of select="concat('translate(',$W - $sXDefault - 86,',40)')"/>
                        </xsl:attribute>
                        <xsl:if test="position()!=1">
                            <xsl:comment>Left arrow</xsl:comment>
                            <use xlink:href="#leftArrow" id="{$bw_a}">
                                <set attributeName="display" to="inline" begin="click">
                                    <xsl:attribute name="xlink:href">
                                        <xsl:value-of select="concat('#slide_',position()-1)"/>
                                    </xsl:attribute>
                                </set>
                                <set attributeName="display" to="none" begin="click">
                                    <xsl:attribute name="xlink:href">
                                        <xsl:value-of select="concat('#slide_',position())"/>
                                    </xsl:attribute>
                                </set>
                            </use>
                        </xsl:if>
                        <use xlink:href="#upArrow">
                            <xsl:attribute name="transform">
                                <xsl:value-of select="concat('translate(',34,')')"/>
                            </xsl:attribute>
                            <set attributeName="display" to="none" begin="click">
                                <xsl:attribute name="xlink:href">
                                    <xsl:value-of select="concat('#slide_',position())"/>
                                </xsl:attribute>
                            </set>
                        </use>
                        <xsl:if test="position()!=last()">
                            <xsl:comment>Right Arrow</xsl:comment>
                            <use xlink:href="#rightArrow" id="{$fw_a}">
                                <xsl:attribute name="transform">
                                    <xsl:value-of select="concat('translate(',68,',0)')"/>
                                </xsl:attribute>
                                <set attributeName="display" to="inline" begin="click">
                                    <xsl:attribute name="xlink:href">
                                        <xsl:value-of select="concat('#slide_',position()+1)"/>
                                    </xsl:attribute>
                                </set>
                                <set attributeName="display" to="none" begin="click">
                                    <xsl:attribute name="xlink:href">
                                        <xsl:value-of select="concat('#slide_',position())"/>
                                    </xsl:attribute>
                                </set>
                            </use>
                        </xsl:if>
                    </g>
                    <xsl:call-template name="createSlideContent">
                        <xsl:with-param name="slide" select="."/>
                        <xsl:with-param name="pos" select="position()"/>
                    </xsl:call-template>
                    <!-- Add the tooltips; these should cover everything else, hence their position in the file -->
                    <xsl:call-template name="tooltips">
                        <xsl:with-param name="position" select="concat('translate(',$W - $sXDefault - 38,',60)')"/>
                        <xsl:with-param name="previous" select="preceding-sibling::x:div[position()=1]/x:h1"/>
                        <xsl:with-param name="next" select="following-sibling::x:div[position()=1]/x:h1"/>
                        <xsl:with-param name="back" select="$bw_a"/>
                        <xsl:with-param name="forward" select="$fw_a"/>
                    </xsl:call-template>
                </g>
            </xsl:for-each>
        </svg>
    </xsl:template>
</xsl:stylesheet>
