home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / html-slides.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  6.0 KB  |  173 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <!--
  19.     Generate the HTML for one or many slides
  20.     $Id: html-slides.xsl,v 1.6 2004/03/06 02:26:04 antonio Exp $
  21. -->
  22. <xsl:stylesheet
  23.     version="1.0"
  24.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  25. >
  26.     <!-- heading templates -->
  27.     <xsl:import href="heading.xsl"/>
  28.  
  29.     <!-- path to images -->
  30.     <xsl:variable name="imagePath" select="concat('../../',normalize-space(/yapt-presentation/heading/image-directory),'/')"/>
  31.  
  32.     <!-- single or multi-slide display? -->
  33.     <xsl:variable name="slideCount" select="count(/yapt-presentation/content/slide)"/>
  34.  
  35.     <!-- setup CSS stylesheets, javascript for "next slide" click and output content -->
  36.     <xsl:template match="/">
  37.         <html>
  38.             <head>
  39.                 <link rel="stylesheet" type="text/css" href="css/yapt-style.css"/>
  40.                 <link rel="stylesheet" type="text/css" href="css/yapt-images.css"/>
  41.             </head>
  42.             <body>
  43.                 <xsl:if test="$slideCount < 2">
  44.                     <!-- single slide: click body to go to next slide -->
  45.                     <xsl:variable name="nextId" select="//navigation/slide-ref[@offset-from-current=1]/@slide-id"/>
  46.                     <xsl:if test="$nextId">
  47.                         <xsl:attribute name="onClick">document.location='slide-<xsl:value-of select="$nextId"/>'</xsl:attribute>
  48.                     </xsl:if>
  49.                 </xsl:if>
  50.  
  51.                 <!-- indicate if multiple or single slides (boy is XSLT painful for this) -->
  52.                 <xsl:variable name="typeId">
  53.                     <xsl:choose>
  54.                         <xsl:when test="$slideCount > 1">multipleSlides</xsl:when>
  55.                         <xsl:otherwise>singleSlide</xsl:otherwise>
  56.                     </xsl:choose>
  57.                 </xsl:variable>
  58.  
  59.                 <div id="content">
  60.                     <div id="{$typeId}">
  61.                         <xsl:apply-templates select="yapt-presentation"/>
  62.                     </div>
  63.                 </div>
  64.             </body>
  65.         </html>
  66.     </xsl:template>
  67.  
  68.     <xsl:template match="yapt-presentation">
  69.  
  70.         <!-- if multiple slides, output presentation heading -->
  71.         <xsl:if test="$slideCount > 1">
  72.             <div id="presHeading">
  73.                 <xsl:apply-templates select="heading/*" mode="heading"/>
  74.             </div>
  75.         </xsl:if>
  76.  
  77.         <!-- output slides -->
  78.         <div id="slides">
  79.             <xsl:apply-templates mode="content" select="content/slide"/>
  80.         </div>
  81.  
  82.         <!-- for single slide, output navigation -->
  83.         <xsl:if test="$slideCount < 2">
  84.             <div id="navigation">
  85.                 <xsl:apply-templates select="navigation" mode="navigation"/>
  86.             </div>
  87.         </xsl:if>
  88.  
  89.     </xsl:template>
  90.  
  91.     <!-- navigation: link to previous slide, table of contents and next slide -->
  92.     <xsl:template match="navigation" mode="navigation">
  93.         <xsl:variable name="prev" select="slide-ref[@offset-from-current = -1]/@slide-id"/>
  94.         <xsl:variable name="next" select="slide-ref[@offset-from-current = 1]/@slide-id"/>
  95.  
  96.         <xsl:if test="$prev">
  97.             <div class="navItem">
  98.                 <a href="{concat('slide-',$prev)}">previous</a>
  99.             </div>
  100.         </xsl:if>
  101.  
  102.         <div class="navItem">
  103.             <a href="index">index</a>
  104.         </div>
  105.  
  106.         <xsl:if test="$next">
  107.             <div class="navItem">
  108.                 <a href="{concat('slide-',$next)}">next</a>
  109.             </div>
  110.         </xsl:if>
  111.  
  112.     </xsl:template>
  113.  
  114.     <!-- in content, float images according to their CSS classes -->
  115.     <xsl:template mode="content" match="img">
  116.         <div class="{@class}">
  117.             <img src="{concat($imagePath,@src)}" alt="{@alt}" class="scaledImage"/>
  118.         </div>
  119.     </xsl:template>
  120.  
  121.     <!-- subtitle in content -->
  122.     <xsl:template mode="content" match="subtitle">
  123.         <h2><xsl:value-of select="."/></h2>
  124.     </xsl:template>
  125.  
  126.     <!-- note in content -->
  127.     <xsl:template mode="content" match="note">
  128.         <p class="note">
  129.             <xsl:value-of select="."/>
  130.         </p>
  131.     </xsl:template>
  132.  
  133.     <!-- slide in content -->
  134.     <xsl:template mode="content" match="slide">
  135.         <div class="singleSlide">
  136.             <div class="singleSlideHeading">
  137.                 <xsl:apply-templates mode="content" select="slide-head/*"/>
  138.             </div>
  139.  
  140.             <!-- use style hints if any (but not if generating multiple slides for printing) -->
  141.             <xsl:variable name="hintClass">
  142.                 <xsl:choose>
  143.                     <xsl:when test="$slideCount > 1">slideHint</xsl:when>
  144.                     <xsl:otherwise><xsl:value-of select="concat('slideHint',slide-hints/style)"/></xsl:otherwise>
  145.                 </xsl:choose>
  146.             </xsl:variable>
  147.  
  148.             <div class="{$hintClass}">
  149.                 <div class="singleSlideContent">
  150.                     <xsl:apply-templates mode="content" select="slide-content/*"/>
  151.                 </div>
  152.             </div>
  153.         </div>
  154.     </xsl:template>
  155.  
  156.     <!-- slide title in content -->
  157.     <xsl:template mode="content" match="title">
  158.         <h1>
  159.             <xsl:value-of select="ancestor::slide/@slide-id"/>.
  160.             <xsl:value-of select="."/>
  161.         </h1>
  162.     </xsl:template>
  163.  
  164.     <!-- copy other content elements -->
  165.     <xsl:template mode="content" match="*" priority="-1">
  166.         <xsl:element name="{name()}">
  167.             <xsl:copy-of select="@*"/>
  168.             <xsl:apply-templates mode="content"/>
  169.         </xsl:element>
  170.     </xsl:template>
  171.  
  172. </xsl:stylesheet>
  173.