<?xml version="1.0" encoding="UTF-8"?>
<!-- Stylesheet used to generate HTML content and 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="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" 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.
    -->
	<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>
				<link rel="Copyright" href="{$CopyrightLink}" title="W3C Copyrights"/>
				<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>
					<xsl:if test="/x:html/x:body/x:div[@class = 'prologue']">
						<xsl:copy-of select="/x:html/x:body/x:div[@class = 'prologue']"/>
					</xsl:if>
					<ol>
						<xsl:if test="$TitlePage = 'true'">
							<xsl:attribute name="start">0</xsl:attribute>
							<li>
								<a href="0.html">[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(position(),'.html')"/>
									</xsl:attribute>
									<xsl:value-of select="x:h1"/>
								</a>
							</li>
						</xsl:for-each>
					</ol>
				</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>
        <!-- Generation of a separate title page, if required -->
		<xsl:if test="$TitlePage = 'true'">
			<xsl:message>Generate Title Page</xsl:message>
            <!-- FOR XSLT: the element should be <xsl:result-document href="0.svg"> -->
			<saxon:output href="0.html">
				<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>
						<link rel="Copyright" href="{$CopyrightLink}" title="W3C Copyrights"/>
						<link rel="contents" href="{$indexPageHTML}" title="Contents"/>
						<link rel="top" href="{$indexPageHTML}" title="Top"/>
						<link rel="up" href="{$indexPageHTML}" title="Up"/>
						<link  rel="first" href="0.html" title="First"/>
						<link rel="last" title="Last">
							<xsl:attribute name="href">
								<xsl:value-of select="concat(count(x:div[@class='slide']),'.html')"/>
							</xsl:attribute>
						</link>
						<link rel="next" href="1.html" title="Next"/>
						<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>
						<div class="genSlide">
							<div class="header">
								<table summary="table for two elements: left one is the logo, right one the navigation arrows">
									<tr>
										<td class="logoHd">
											<xsl:call-template name="UserLogo"/>
										</td>
										<td class="navigationHd">
											<xsl:choose>
												<xsl:when test="position()!=last()">
													<a accesskey="N" href="1.html">
														<img src="{$RightA}" alt="Right Arrow, linking to the next slide"/>
													</a>
												</xsl:when>
											</xsl:choose>
										</td>
									</tr>
								</table>
							</div>
							<xsl:call-template name="titlePageContent"/>
						</div>
					</body>
				</html>
			</saxon:output>
		</xsl:if>
        <!-- Generation of each separate slide file through a cycle on all slide div-s -->
		<xsl:for-each select="x:div[@class='slide']">
            <!-- 
                First the possible svg files are copied by a call to a special function (see below),
                but only if the governing SVGMove parameter demands it
            -->
            <!-- Now the output file can be generated -->
			<xsl:variable name="outfile" select="concat(position(),'.html')"/>
			<xsl:message>Generate <xsl:value-of select="$outfile"/>
			</xsl:message>
            <!-- ******************************************************************************** -->
            <!-- FOR XSLT 2.0: the element below should be <xsl:result-document href="{$outfile}>" -->   
            <!-- ******************************************************************************** -->
			<saxon:output href="{$outfile}">
				<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"/>: <xsl:value-of select="x:h1"/>
						</title>
						<link rel="Copyright" href="{$CopyrightLink}" title="W3C Copyrights"/>
						<link rel="contents" href="{$indexPageHTML}" title="Contents"/>
						<link rel="top" href="{$indexPageHTML}" title="Top"/>
						<link rel="up" href="{$indexPageHTML}" title="Up"/>
						<xsl:choose>
							<xsl:when test="$TitlePage = 'true'">
								<link  rel="first" href="0.html" title="First"/>
								<link rel="prev" title="Previous">
									<xsl:attribute name="href">
										<xsl:value-of select="concat(position()-1,'.html')"/>
									</xsl:attribute>
								</link>
							</xsl:when>
							<xsl:otherwise>
								<link  rel="first" href="1.html" title="First"/>
								<xsl:if test="position()!=1">
									<link rel="prev" title="Previous">
										<xsl:attribute name="href">
											<xsl:value-of select="concat(position()-1,'.html')"/>
										</xsl:attribute>
									</link>
								</xsl:if>
							</xsl:otherwise>
						</xsl:choose>
						<link rel="last" title="Last">
							<xsl:attribute name="href">
								<xsl:value-of select="concat(last(),'.html')"/>
							</xsl:attribute>
						</link>
						<xsl:if test="position()!=last()">
							<link rel="next" title="Next">
								<xsl:attribute name="href">
									<xsl:value-of select="concat(position()+1,'.html')"/>
								</xsl:attribute>
							</link>
						</xsl:if>
						<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>
                        <!-- Placement of the arrows with links; it is in a separate div; one can
                        then style it via the style files
                        -->
						<div class="genSlide">
							<div class="header">
								<table summary="table for two elements: left one is the logo, right one the navigation arrows">
									<tr>
										<td class="logoHd">
											<xsl:call-template name="UserLogo"/>
										</td>
										<td class="navigationHd">
											<xsl:choose>
												<xsl:when test="position()!=1">
													<a accesskey="B">
														<xsl:attribute name="href">
															<xsl:value-of select="concat(position()-1,'.html')"/>
														</xsl:attribute>
														<img src="{$LeftA}" alt="Left Arrow, linking to the previous slide"/>
													</a>
												</xsl:when>
												<xsl:otherwise>
													<xsl:choose>
														<xsl:when test="$TitlePage = 'true'">
															<a accesskey="B" href="0.html">
																<img src="{$LeftA}" alt="Left Arrow, linking to the previous slide"/>
															</a>
														</xsl:when>
														<xsl:otherwise>
															<img src="{$LeftA}" alt="Left Arrow"/>
														</xsl:otherwise>
													</xsl:choose>
												</xsl:otherwise>
											</xsl:choose>
											<a href="{$indexPageHTML}" accesskey="U">
												<img src="{$UpA}" alt="Up arrow, linking to the overview page"/>
											</a>
											<xsl:if test="position()!=last()">
												<a accesskey="N">
													<xsl:attribute name="href">
														<xsl:value-of select="concat(position()+1,'.html')"/>
													</xsl:attribute>
													<img src="{$RightA}" alt="Right Arrow, linkink to the next slide"/>
												</a>
											</xsl:if>
										</td>
									</tr>
								</table>
							</div>
                            <!-- Simply copy everything -->
							<xsl:copy-of select="x:h1"/>
							<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>
					</body>
				</html>
            <!-- ******************************************************************************* -->
            <!-- FOR XSLT 2.0: the element below should be </xsl:result-document>"               -->
            <!-- ******************************************************************************* -->
			</saxon:output>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>
