<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
  Copyright 2002-2004 The Apache Software Foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!--
A prototype Docbook-to-Forrest stylesheet.
Volunteers are needed to improve this!

Support for the range of Docbook tags is very patchy. If you need real
Docbook support, then use Norm Walsh's stylesheets - see Forrest FAQ.

Credit: original from the jakarta-avalon project

-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template match="document">
      <!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">-->
      
      <html xmlns="http://www.w3.org/1999/xhtml">
        <xsl:apply-templates/>
      </html>
    </xsl:template>
    
    <xsl:template match="body">
      <body>
        <xsl:call-template name="layout"/>     
        <div class="presentation"> 
          <xsl:call-template name="title-slide"/>
          <xsl:call-template name="overview"/>
          <xsl:for-each select="section[@class='topic']">
            <xsl:call-template name="topic"/>
            <xsl:call-template name="slides"/>
          </xsl:for-each>
        </div>      
      </body>
  </xsl:template>
  
  <xsl:template match="header">
    <head>
      <title><xsl:value-of select="title"/></title>
      <meta name="version" content="Apache Forrest Plugin S5 0.1" />
      <link rel="stylesheet" href="ui/slides.css" type="text/css" media="projection" id="slideProj" />
      <link rel="stylesheet" href="ui/opera.css" type="text/css" media="projection" id="operaFix" />
      <link rel="stylesheet" href="ui/print.css" type="text/css" media="print" id="slidePrint" />
      <script src="ui/slides.js" type="text/javascript"></script>
    </head>  
  </xsl:template>
  
  <xsl:template name="layout">
    <div class="layout">
      <div id="currentSlide"></div>
      <div id="running_title">
        <!-- should be separated, maybe someone wants the date in another place -->
        <xsl:value-of select="//document/header/title"/><xsl:text> | </xsl:text>
        <xsl:value-of select="//document/header/meta[@name='date']"/>
      </div>
      <div id="running_footer">
        <xsl:value-of select="//document/header/authors/person/@name"/><xsl:text> | </xsl:text>
        <xsl:value-of select="//document/header/meta[@name='company']"/>   
      </div>
      <div id="header"></div>
      <div id="footer">
        <div id="controls"></div>
      </div>
    </div>
  </xsl:template>
  
  <xsl:template name="title-slide">
    <div class="slide">
      <h1><xsl:value-of select="//document/header/title"/></h1>
      <h2><xsl:value-of select="//document/header/subtitle"/></h2>
      <xsl:for-each select="//document/header/authors/person">
        <h3><xsl:value-of select="@name"/></h3>
        <h4><kbd><xsl:value-of select="@email"/></kbd></h4>
      </xsl:for-each>
      <p><xsl:value-of select="//document/header/meta[@name='date']"/></p>
    </div>
  </xsl:template>

  <xsl:template name="overview">
    <div class="slide">
      <h1>Inhaltsübersicht</h1>
      <ul>
      <xsl:for-each select="section[@class='topic']">
        <li><xsl:value-of select="title"/></li>
      </xsl:for-each>
      </ul>
    </div>
  </xsl:template>

  <xsl:template name="topic">
    <div class="slide">
      <xsl:choose>
      <xsl:when test="section[@class='slide']">
        <h1>Inhaltsübersicht</h1>
        <ul>
          <!-- 
          <xsl:for-each select="preceding-sibling::node()">
            <li><xsl:value-of select="title"/></li>
          </xsl:for-each>
          -->
          <li><xsl:value-of select="title"/></li>
          <ul>
            <xsl:for-each select="section[@class='slide']">
              <li><xsl:value-of select="title"/></li>
            </xsl:for-each>
          </ul>
        </ul>
      </xsl:when>
      <xsl:otherwise>   <!-- no sub-sections -->
        <h1><xsl:value-of select="title"/></h1>
        <xsl:apply-templates/>
      </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>
  
  <xsl:template name="slides">
    <xsl:for-each select="section[@class='slide']">
        <div class="slide">
          <h1><xsl:value-of select="title"/></h1>
          <xsl:apply-templates/>
          <div class="handout">
            <!-- <xsl:apply-templates/> -->
          </div>
        </div>
    </xsl:for-each>
  </xsl:template>
  
<!--  <xsl:template match="section" mode="inSlide"> -->
  <xsl:template match="section">
    <h2><xsl:value-of select="title"/></h2> 
    <xsl:apply-templates/>
  </xsl:template>
  
  <xsl:template match="title">
    <!-- <h1><xsl:value-of select="."/></h1> -->
  </xsl:template>

  <xsl:template match="link">
    <a href="{@href}"><xsl:value-of select="."/></a>
  </xsl:template>

  <xsl:template match="source">
    <pre><xsl:value-of select="."/></pre>
  </xsl:template>
  
  <xsl:template match="@*|*|text()|processing-instruction()|comment()">
    <xsl:copy>
      <xsl:apply-templates select="@*|*|text()|processing-instruction()|comment()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
