<?xml version="1.0" encoding="UTF-8"?>
<!-- Stylesheet used to generate HTML content and slides -->
<!-- I. Herman $Date: 2003/10/28 12:08:13 $ -->
<!--
     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="htmlCommon.xsl"/>
    <!-- *********************************************************************** -->
    <!-- FOR XSLT 2.0: the method should be xhtml                                -->
    <!-- *********************************************************************** -->
    <xsl:variable name="encoding">text/html; charset=utf-8</xsl:variable>
    <xsl:output method="saxon:xhtml" version="1.0" encoding="utf-8" indent="no" omit-xml-declaration="no"/>
    <!-- ======================================================= -->
    <!--     Parameters governing the behaviour of the script    -->
    <!-- ======================================================= -->
    <!-- 
        By default, the svg contents are not treated differently.
        If the parameter is set to true, the object references are
        changed to ./svgs/SVGFILE, and the svg file itself is
        copied to that directory.
    -->
    <xsl:param name="SVGMove" select="false"/>
    <!--
        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="'absolute'"/>
    <!-- can be 'extend' or 'replace' -->
    <xsl:param name="SVGtoImage" select="'none'"/>
    <!--
        Generate a separete title page or not
    -->
    <xsl:param name="TitlePage" select="'true'"/>
    <!-- this is meaningless here -->
    <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.
            -->
        <html xmlns="http://www.w3.org/1999/xhtml" lang="{$documentLanguage}" xml:lang="{$documentLanguage}">
            <head>
                <meta http-equiv="Content-Type" content="{$encoding}" />
                <title>
                    <xsl:value-of select="$OverallTitle"/>
                </title>
                <xsl:for-each select="/x:html/x:head/x:link">
                    <xsl:copy-of select="."/>
                </xsl:for-each>
                <xsl:for-each select="/x:html/x:head/x:style">
                    <xsl:copy-of select="."/>
                </xsl:for-each>
            </head>
            <body>
                <!-- Generation of the table of content -->
                <div class="toc">
                    <xsl:call-template name="UserLogo"/>
                    <div class="tocTitle">
                        <h1>
                            <xsl:value-of select="$OverallTitle"/>
                        </h1>
                        <h2>
                            <xsl:value-of select="$Author"/>
                            <br/>
                            <xsl:value-of select="$Date"/>
                        </h2>
                    </div>
                    <ol>
                        <xsl:if test="$TitlePage = 'true'">
                            <xsl:attribute name="start">0</xsl:attribute> 
                            <li>
                                <a href="#slide_0">Title Page</a>
                            </li>
                        </xsl:if>
                        <xsl:for-each select="x:div[@class='slide']">
                            <li>
                                <a>
                                    <xsl:attribute name="href">
                                        <xsl:value-of select="concat('#slide_',position())"/>
                                    </xsl:attribute>
                                    <xsl:value-of select="x:h1"/>
                                </a>
                            </li>
                        </xsl:for-each>
                    </ol>
                </div>
                <div class="projection">
                    <!-- Generation of a separate title page, if required -->
                    <xsl:if test="$TitlePage = 'true'">
                       <xsl:message>Generate Title Page</xsl:message>
                       <div class="projSlide" id="slide_0" name="slide_0">
                            <xsl:call-template name="UserLogo"/>
                            <xsl:call-template name="titlePageContent"/>                            
                       </div>
                    </xsl:if>                
                    <!-- Each slide body is copied and a signature added -->
                    <xsl:for-each select="x:div[@class='slide']">
                        <div class="projSlide">
                            <xsl:attribute name="id">
                                <xsl:value-of select="concat('slide_',position())"/>
                            </xsl:attribute>
                            <xsl:attribute name="name">
                                <xsl:value-of select="concat('slide_',position())"/>
                            </xsl:attribute>
                            <xsl:message>Generate slide #<xsl:value-of select="position()"/>
                            </xsl:message>
                            <div class="projHeader">
                              <xsl:call-template name="UserLogo"/>
                              <xsl:copy-of select="x:h1"/>
                            </div>
                            <div class="slideContent">
                                <xsl:apply-templates/>
                                <xsl:comment>An empty clear is put here to compensate for the possible floats!</xsl:comment>
                                <p style="clear:both"/>
                            </div>
                            <!-- Add the signature to the bottom -->
                            <xsl:call-template name="signature">
                                <xsl:with-param name="slideNumber" select="position()"/>
                            </xsl:call-template>
                        </div>
                    </xsl:for-each>
                </div>
            </body>
        </html>
        <!-- Copy the SVG files if necessary -->
        <xsl:if test="$SVGMove='true'">
            <xsl:for-each select="descendant::x:object[@type='image/svg+xml']">
                <xsl:call-template name="copySVG">
                    <xsl:with-param name="obj" select="."/>
                </xsl:call-template>
            </xsl:for-each>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>
