<?xml version="1.0" encoding="utf8"?>
<!--

$Id: multipages.xsl,v 1.11 2004/10/16 03:21:37 jmates Exp $

Handles conversion of eolas documents into a bunch of slides; use
something else to split out the different documents into separate
files:

"XSLT magic" | perl -ple 'BEGIN { $n=0; select $fh }' \
    -e 'open $fh, ">slide$n.html" and $n++ if /^\s*<html/i'
mv slide0.html index.html

-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">
  <xsl:import href="default.xsl"/>
  <xsl:output method="html" indent="yes"/>
  <xsl:strip-space elements="*"/>
  <xsl:preserve-space elements="info note warn li"/>
  <xsl:param name="stylesheet.version">
    <xsl:text>$Id: multipages.xsl,v 1.11 2004/10/16 03:21:37 jmates Exp $</xsl:text>
  </xsl:param>
  <xsl:template match="eolas">
    <xsl:apply-templates select="summary"/>
    <xsl:for-each select="section">
      <xsl:element name="html">
        <xsl:choose>
          <xsl:when test="@xml:lang">
            <xsl:attribute name="lang">
              <xsl:value-of select="@xml:lang"/>
            </xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute name="lang">
              <xsl:text>en-US</xsl:text>
            </xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
        <head>
          <title>
            <xsl:value-of select="title"/>
          </title>
<!-- figure out CSS stylesheet to use by param name passed in -->
          <xsl:element name="link">
            <xsl:attribute name="rel">stylesheet</xsl:attribute>
            <xsl:attribute name="type">text/css</xsl:attribute>
            <xsl:attribute name="href">
              <xsl:text>/_xs/eolas/</xsl:text>
              <xsl:choose>
                <xsl:when test="string-length($request.preferred_style) &gt; 0">
                  <xsl:value-of select="$request.preferred_style"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:text>default</xsl:text>
                </xsl:otherwise>
              </xsl:choose>
              <xsl:text>.css</xsl:text>
            </xsl:attribute>
          </xsl:element>
<!--          <link rel="P3Pv1" href="/w3c/p3p.xml"/> -->
          <meta name="MSSmartTagsPreventParsing" content="TRUE"/>
        </head>
        <body>
<!-- kluge links between docs -->
          <p align="right">
            <xsl:choose>
              <xsl:when test="position()=1">
                <a href="index.html">
                  <xsl:text>Previous</xsl:text>
                </a>
              </xsl:when>
              <xsl:otherwise>
                <a href="slide{position()-1}.html">
                  <xsl:text>Previous</xsl:text>
                </a>
              </xsl:otherwise>
            </xsl:choose>
            <xsl:text> | </xsl:text>
            <a href="{/eolas/summary/source/@xlink:href}">Index</a>
            <xsl:text> | </xsl:text>
            <xsl:choose>
              <xsl:when test="position()=last()">
                <xsl:text>Next</xsl:text>
              </xsl:when>
              <xsl:otherwise>
                <a href="slide{position()+1}.html">
                  <xsl:text>Next</xsl:text>
                </a>
              </xsl:otherwise>
            </xsl:choose>
          </p>
          <xsl:apply-templates/>
        </body>
      </xsl:element>
    </xsl:for-each>
  </xsl:template>
<!-- leading intro page from summary elements -->
  <xsl:template match="summary">
    <xsl:element name="html">
      <xsl:choose>
        <xsl:when test="@xml:lang">
          <xsl:attribute name="lang">
            <xsl:value-of select="@xml:lang"/>
          </xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="lang">
            <xsl:text>en-US</xsl:text>
          </xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <head>
        <title>
          <xsl:value-of select="title"/>
        </title>
<!-- figure out CSS stylesheet to use by param name passed in -->
        <xsl:element name="link">
          <xsl:attribute name="rel">stylesheet</xsl:attribute>
          <xsl:attribute name="type">text/css</xsl:attribute>
          <xsl:attribute name="href">
            <xsl:text>/_xs/eolas/</xsl:text>
            <xsl:choose>
              <xsl:when test="string-length($request.preferred_style) &gt; 0">
                <xsl:value-of select="$request.preferred_style"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text>default</xsl:text>
              </xsl:otherwise>
            </xsl:choose>
            <xsl:text>.css</xsl:text>
          </xsl:attribute>
        </xsl:element>
        <link rel="P3Pv1" href="/w3c/p3p.xml"/>
        <meta name="MSSmartTagsPreventParsing" content="TRUE"/>
      </head>
      <body>
<!-- kluge links between docs -->
        <p align="right">
          <xsl:text>Previous | </xsl:text>
          <a href="{/eolas/summary/source/@xlink:href}">Index</a>
          <xsl:text> | </xsl:text>
          <a href="slide1.html">
            <xsl:text>Next</xsl:text>
          </a>
        </p>
        <h1 align="center">
          <xsl:value-of select="title"/>
        </h1>
        <xsl:if test="description">
          <p align="center">
            <xsl:value-of select="description"/>
          </p>
        </xsl:if>
        <xsl:if test="author">
          <p align="center">
            <big>
              <xsl:for-each select="author">
                <xsl:sort select="first-name"/>
                <xsl:sort select="last-name"/>
<!-- more elegant way of doing this? -->
                <xsl:choose>
                  <xsl:when test="contact/@xlink:href">
                    <a href="{contact/@xlink:href}">
                      <xsl:value-of select="first-name"/>
                      <xsl:if test="last-name">
                        <xsl:text> </xsl:text>
                        <xsl:value-of select="last-name"/>
                      </xsl:if>
                    </a>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="first-name"/>
                    <xsl:if test="last-name">
                      <xsl:text> </xsl:text>
                      <xsl:value-of select="last-name"/>
                    </xsl:if>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:if test="not(position()=last())">
                  <xsl:text>, </xsl:text>
                </xsl:if>
              </xsl:for-each>
            </big>
          </p>
        </xsl:if>
        <xsl:if test="contributor">
          <p align="center">
            <xsl:text>(</xsl:text>
            <xsl:for-each select="contributor">
              <xsl:sort select="first-name"/>
              <xsl:sort select="last-name"/>
<!-- more elegant way of doing this? -->
              <xsl:choose>
                <xsl:when test="contact/@xlink:href">
                  <a href="{contact/@xlink:href}">
                    <xsl:value-of select="first-name"/>
                    <xsl:if test="last-name">
                      <xsl:text> </xsl:text>
                      <xsl:value-of select="last-name"/>
                    </xsl:if>
                  </a>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="first-name"/>
                  <xsl:if test="last-name">
                    <xsl:text> </xsl:text>
                    <xsl:value-of select="last-name"/>
                  </xsl:if>
                </xsl:otherwise>
              </xsl:choose>
              <xsl:if test="not(position()=last())">
                <xsl:text>, </xsl:text>
              </xsl:if>
            </xsl:for-each>
            <xsl:text>)</xsl:text>
          </p>
        </xsl:if>
        <xsl:if test="date">
          <p align="center">
            <small>
              <xsl:value-of select="date"/>
            </small>
          </p>
        </xsl:if>
        <xsl:if test="rights">
          <p align="center">
            <small>
              <xsl:value-of select="rights"/>
            </small>
          </p>
        </xsl:if>
        <xsl:if test="source">
          <p align="center">
            <small>
              <a href="{source/@xlink:href}">
                <xsl:choose>
                  <xsl:when test="source/text()">
                    <xsl:value-of select="source"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="source/@xlink:href"/>
                  </xsl:otherwise>
                </xsl:choose>
              </a>
            </small>
          </p>
        </xsl:if>
        <xsl:if test="version">
          <p align="center">
            <small>
              <code>
                <xsl:value-of select="version"/>
              </code>
            </small>
          </p>
        </xsl:if>
      </body>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
