<?xml version="1.0"?>

<!--
Classic stylesheet for Orion tutorials. It specifies the conversion of a
tutorial in XML format to an XHTML document that closely resembles the
original style of the Orion Primer, with some small changes and improvements.

Version:  $Revision: 1.24 $ $Date: 2001/05/15 14:59:42 $
Author:   Ernst de Haan <ernst@jollem.com>
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

   <xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>

   <xsl:strip-space elements="" />

   <xsl:template match="document">
      <html>
         <head>
            <title>
               <xsl:value-of select="@title" />
            </title>
            <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style" />
            <xsl:comment> Created with the "Classic" stylesheet: $Revision: 1.24 $ $Date: 2001/05/15 14:59:42 $ </xsl:comment>
         </head>
         <body bgcolor="#ffffff" link="#ff4444" alink="#4444ff" vlink="#ff4444">
            <table cellspacing="0" cellpadding="0" width="100%">
               <tr>
                  <td align="center" bgcolor="#980000" class="PageTitle">
                     <font color="#ffffff" size="24">
                        <b>
                           <xsl:value-of select="@title" />
                        </b>
                     </font>
                  </td>
               </tr>
               <tr>
                  <td align="right" class="RevisionHeader">
                     <small>
                        <xsl:value-of select="//@version" />
                     </small>
                  </td>
               </tr>
            </table>

            <xsl:apply-templates select="header" />
            <xsl:apply-templates select="lesson" />
            <xsl:apply-templates select="footer" />

            <p />
            <hr />
            <br />
            <br />
            <div align="center">
               <table width="90%" cellspacing="0" cellpadding="1" bgcolor="#980000" border="0">
                  <tr>
                     <td align="left"><font color="#ffffff"><b>&#160;Credits</b></font></td>
                  </tr>
                  <tr>
                     <td>
                        <table width="100%" cellspacing="0" cellpadding="3" bgcolor="#F4E5E5" border="0">
                           <tr>
                              <td align="left">This tutorial is written by:
                                 <p />
                                 <ul>
                                    <xsl:for-each select="//author">
                                       <li>
                                          <xsl:value-of select="@name" /><xsl:text> (</xsl:text>
                                          <a>
                                             <xsl:attribute name="href">
                                                <xsl:text>mailto:</xsl:text>
                                                <xsl:value-of select="@email" />
                                             </xsl:attribute>
                                             <xsl:value-of select="@email" />
                                          </a>
                                          <xsl:text>)</xsl:text>
                                       </li>
                                    </xsl:for-each>
                                 </ul>
                                 <p />Comments, additions, questions are welcome. Please include the revision number of this tutorial in your reply.  Please redirect your flames to <code>/dev/null</code>.
                                 <p />Thanks go to the following people for their invaluable comments, suggestions and improvements (in no particular order):
                                 <p />
                                 <ul>
                                    <xsl:for-each select="//contributor">
                                       <li>
                                          <xsl:value-of select="@name" /><xsl:text> (</xsl:text>
                                          <a>
                                             <xsl:attribute name="href">
                                                <xsl:text>mailto:</xsl:text>
                                                <xsl:value-of select="@email" />
                                             </xsl:attribute>
                                             <xsl:value-of select="@email" />
                                          </a>
                                          <xsl:text>)</xsl:text>
                                          <xsl:if test="@reviewer='true'">
                                             <i>
                                                <xsl:text> primary reviewer</xsl:text>
                                             </i>
                                          </xsl:if>
                                       </li>
                                    </xsl:for-each>
                                 </ul>
                                 <p />This document was generated from an XML document (<code><a href="tutorial.xml">tutorial.xml</a></code>) and then converted to HTML using an XSLT stylesheet (<a href="classic.xsl">classic.xsl</a>).
                              </td>
                           </tr>
                        </table>
                     </td>
                  </tr>
               </table>
            </div>

            <p />
            <hr />
            <table border="0" width="100%" cellspacing="0" cellpadding="0">
               <tr>
                  <td><i><xsl:value-of select="//document/@version" /><xsl:text> </xsl:text><xsl:value-of select="//document/@date" /></i></td>
                  <td align="right"><a href="http://jigsaw.w3.org/css-validator"><img border="0" width="88" height="31" src="images/vcss.gif" alt="Valid CSS!" /></a><a href="http://validator.w3.org/check/referer"><img border="0" src="images/vh40.gif" alt="Valid HTML 4.01!" height="31" width="88" /></a>
                     <a>
                        <xsl:attribute name="href">
                           <xsl:text>http://uk.nedstat.net/viewstat.asp?name=</xsl:text>
                           <xsl:value-of select="//document/@name" />
                        </xsl:attribute>
                        <img alt="Nedstat hitcounter" border="0" width="22" height="22">
                           <xsl:attribute name="src">http://uk.nedstat.net/scripts/nedstat.dll?name=<xsl:value-of select="//document/@name" /></xsl:attribute>
                        </img>
                     </a>
                  </td>
               </tr>
            </table>
         </body>
      </html>
   </xsl:template>

   <xsl:template match="lesson">
      <p />
      <table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#980000">
<!--
         <tr>
            <td height="1">
               <img src="images/dot.gif" height="1" width="100%" alt="" />
            </td>
         </tr>
-->
         <tr>
            <td align="center">
               <a>
                  <xsl:attribute name="name">
                     <xsl:value-of select="@name" />
                  </xsl:attribute>
               </a>
               <font size="+2" color="#ffffff">
                  <b>
                     <xsl:value-of select="@title" />
                  </b>
               </font>
            </td>
         </tr>
<!--
         <tr>
            <td height="1">
               <img src="images/dot.gif" height="1" width="100%" alt="" />
            </td>
         </tr>
-->
      </table>
    <xsl:apply-templates select="section" />
  </xsl:template>

   <xsl:template match="section">
      <p />
      <a>
         <xsl:attribute name="name">
            <xsl:value-of select="ancestor::lesson/@name" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="@name" />
         </xsl:attribute>
      </a>
      <table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#980000">
         <tr><td height="1"><img src="images/dot.gif" height="1" width="100%" alt="" /></td></tr>
         <tr>
            <td bgcolor="#f4e5e5" class="Header">
               <font size="+1">
                  <b>
                     <i>
                        <xsl:value-of select="@title" />
                     </i>
                  </b>
               </font>
            </td>
         </tr>
      </table>
      <xsl:apply-templates />
   </xsl:template>

   <xsl:template match="subsection">
      <p />
      <a>
         <xsl:attribute name="name">
            <xsl:value-of select="ancestor::lesson/@name" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="ancestor::section/@name" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="@name" />
         </xsl:attribute>
      </a>
      <table border="0" cellspacing="0" cellpadding="0" bgcolor="#980000">
         <tr>
            <td height="1">
               <img src="images/dot.gif" height="1" width="100%" alt="" />
            </td>
         </tr>
         <tr>
            <td bgcolor="#ffffff">
               <b>
                  <xsl:value-of select="@title" />
               </b>
            </td>
         </tr>
      </table>
      <xsl:apply-templates />
   </xsl:template>
  
   <xsl:template match="paragraph/paragraph[not (@type)]">
      <blockquote>
         <xsl:apply-templates />
      </blockquote>
   </xsl:template>

   <xsl:template match="paragraph">
      <p />
      <xsl:apply-templates />
   </xsl:template>

   <xsl:template match="paragraph[@type='preformatted']" priority="1">
      <p />
      <blockquote><pre><xsl:apply-templates /></pre></blockquote>
   </xsl:template>

   <xsl:template match="paragraph[@type='note']">
      <p />
      <div align="center">
         <table width="90%" cellspacing="0" cellpadding="1" bgcolor="#980000" border="0">
            <tr>
               <td align="left"><font color="#ffffff"><b>&#160;Note</b></font></td>
            </tr>
            <tr>
               <td><table width="100%" cellspacing="0" cellpadding="3" bgcolor="#f4e5e5" border="0">
                  <tr>
                     <td class="Note">
                        <i><xsl:apply-templates /></i>
                     </td>
                  </tr>
               </table></td>
            </tr>
         </table>
      </div>
   </xsl:template>

   <xsl:template match="paragraph[@type='save']">
      <p />
      <div align="center">
         <table bgcolor="#980000" border="0" cellspacing="1" cellpadding="1" width="90%">
            <tr>
               <td><table bgcolor="#f4e5e5" border="0" cellspacing="0" cellpadding="0" width="100%">
                  <tr>
                     <td valign="top"><img src="images/Save24.gif" width="24" height="24" alt="Save" /></td>
                     <td width="100%">
                        <b>
                           <xsl:text>Save to your computer</xsl:text>
                        </b>
                        <br />
                        <xsl:apply-templates />
                     </td>
                  </tr>
               </table></td>
            </tr>
         </table>
      </div>
   </xsl:template>

   <xsl:template match="paragraph[@type='zoom']">
      <p />
      <div align="center">
         <table bgcolor="#980000" border="0" cellspacing="1" cellpadding="1" width="90%">
            <tr>
               <td><table bgcolor="#f4e5e5" border="0" cellspacing="0" cellpadding="0" width="100%">
                  <tr>
                     <td valign="top"><img src="images/ZoomIn24.gif" width="24" height="24" alt="Zoom in" /></td>
                     <td width="100%">
                        <b>
                           <xsl:text>Zoom in: </xsl:text>
                           <xsl:value-of select="@title" />
                        </b>
                        <br />
                        <xsl:apply-templates />
                     </td>
                  </tr>
               </table></td>
            </tr>
         </table>
      </div>
   </xsl:template>

   <xsl:template match="paragraph[@type='troubleshoot']">
      <p />
      <div align="center">
         <table bgcolor="#980000" border="0" cellspacing="1" cellpadding="1" width="90%">
            <tr>
               <td><table bgcolor="#f4e5e5" border="0" cellspacing="0" cellpadding="0" width="100%">
                  <tr>
                     <td valign="top"><img src="images/Help24.gif" width="24" height="24" alt="Troubleshooting" /></td>
                     <td width="100%">
                        <b>
                           <xsl:text>Troubleshooting: </xsl:text>
                           <xsl:value-of select="@title" />
                        </b>
                        <br />
                        <xsl:apply-templates />
                     </td>
                  </tr>
               </table></td>
            </tr>
         </table>
      </div>
   </xsl:template>

   <xsl:template match="paragraph[@type='fast-forward']">
      <p />
      <div align="center">
         <table bgcolor="#980000" border="0" cellspacing="1" cellpadding="1" width="90%">
            <tr>
               <td><table bgcolor="#F4E5E5" border="0" cellspacing="0" cellpadding="0" width="100%">
                  <tr>
                     <td valign="top">
                        <img src="images/FastForward24.gif" width="24" height="24" alt="Zoom in" />
                     </td>
                     <td width="100%">
                        <b>
                           <xsl:text>Fast forward: </xsl:text>
                           <xsl:value-of select="@title" />
                        </b>
                        <br />
                        <xsl:apply-templates />
                     </td>
                  </tr>
               </table></td>
            </tr>
         </table>
      </div>
   </xsl:template>

   <xsl:template match="paragraph[@type='tip']">
      <p />
      <div align="center">
         <table bgcolor="#980000" border="0" cellspacing="0" cellpadding="1" width="90%">
            <tr>
               <td><table bgcolor="#f4e5e5" border="0" cellspacing="0" cellpadding="0" width="100%">
                  <tr>
                     <td valign="top"><img src="images/TipOfTheDay24.gif" width="24" height="24" alt="Tip" /></td>
                     <td width="100%">
                        <b>
                           <xsl:text>Tip: </xsl:text>
                           <xsl:value-of select="@title" />
                        </b>
                        <br />
                        <xsl:apply-templates />
                     </td>
                  </tr>
               </table></td>
            </tr>
         </table>
      </div>
   </xsl:template>

   <xsl:template match="paragraph[@type='java-code']">
      <p />
      <blockquote>
         <code><xsl:apply-templates /></code>
      </blockquote>
   </xsl:template>

   <xsl:template match="lesson-listing">
      <p />
      <ul>
         <xsl:for-each select="//lesson">
            <li>
               <a>
                  <xsl:attribute name="href">#<xsl:value-of select="@name" /></xsl:attribute>
                  <xsl:value-of select="@title" /><br />
               </a>
            </li>
         </xsl:for-each>
      </ul>
   </xsl:template>

   <xsl:template match="section-listing">
      <p />
      <ul>
         <xsl:for-each select="//lesson/section">
            <li>
               <a>
                  <xsl:attribute name="href">
                     <xsl:text>#</xsl:text>
                     <xsl:value-of select="../@name" />
                     <xsl:text>-</xsl:text>
                     <xsl:value-of select="@name" />
                  </xsl:attribute>
                  <xsl:value-of select="@title" />
               </a>
            </li>
         </xsl:for-each>
      </ul>
   </xsl:template>

   <xsl:template match="list[@ordered='true']">
      <ol>
         <xsl:apply-templates />
      </ol>
   </xsl:template>

   <xsl:template match="table">
      <p />
      <blockquote>
         <table bgcolor="#980000" border="0" cellspacing="0" cellpadding="0">
            <tr>
               <td width="100%">
                  <table bgcolor="#ffffff" border="0" cellspacing="1" cellpadding="3" width="100%">
                     <xsl:apply-templates select="columns" />
                     <xsl:apply-templates select="rows" />
                  </table>
               </td>
            </tr>
         </table>
      </blockquote>
   </xsl:template>

   <xsl:template match="columns">
      <tr>
         <xsl:apply-templates select="column" />
      </tr>
   </xsl:template>

   <xsl:template match="column">
      <td bgcolor="#f4e5e5">
         <b>
            <xsl:value-of select="@title" />
         </b>
      </td>
   </xsl:template>

   <xsl:template match="rows">
      <xsl:apply-templates select="row" />
   </xsl:template>

   <xsl:template match="row">
      <tr>
         <xsl:apply-templates select="cell" />
      </tr>
   </xsl:template>

   <xsl:template match="cell">
      <td>
         <xsl:apply-templates />
      </td>
   </xsl:template>

   <xsl:template match="list" priority="-1">
      <p />
      <ul>
         <xsl:apply-templates select="list-item" />
      </ul>
   </xsl:template>

   <xsl:template match="list[@ordered='false']">
      <p />
      <ul>
         <xsl:apply-templates select="list-item" />
      </ul>
   </xsl:template>

   <xsl:template match="list/list-item">
      <li>
         <xsl:apply-templates />
      </li>
   </xsl:template>

  <xsl:template match="bold">
    <b>
      <xsl:apply-templates />
    </b>
  </xsl:template>

   <xsl:template match="italics">
      <i>
         <xsl:apply-templates />
      </i>
   </xsl:template>

   <xsl:template match="fixed-width">
      <code>
         <xsl:apply-templates />
      </code>
   </xsl:template>

   <xsl:template match="image [@url]">
      <image>
         <xsl:attribute name="src">
            <xsl:value-of select="@url" />
         </xsl:attribute>
      </image>
   </xsl:template>

   <xsl:template match="return">
      <br />
   </xsl:template>

   <xsl:template match="indent/return">
      <br /><xsl:text>&#160;&#160;&#160;</xsl:text>
   </xsl:template>

   <xsl:template match="indent">
      <br /><xsl:text>&#160;&#160;&#160;</xsl:text><xsl:apply-templates /><br />
   </xsl:template>

   <xsl:template match="internal-link[@subsection and(@section) and (@lesson)]" priority="2">
      <a>
         <xsl:attribute name="href">
            <xsl:text>#</xsl:text>
            <xsl:value-of select="@lesson" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="@section" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="@subsection" />
         </xsl:attribute>
         <xsl:apply-templates />
      </a>
   </xsl:template>

   <xsl:template match="internal-link[@section and(@lesson)]" priority="1">
      <a>
         <xsl:attribute name="href">
            <xsl:text>#</xsl:text>
            <xsl:value-of select="@lesson" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="@section" />
         </xsl:attribute>
         <xsl:apply-templates />
      </a>
   </xsl:template>

   <xsl:template match="internal-link[@section]">
      <a>
         <xsl:attribute name="href">
            <xsl:text>#</xsl:text>
            <xsl:value-of select="ancestor::lesson//@name" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="@section" />
         </xsl:attribute>
         <xsl:apply-templates />
      </a>
   </xsl:template>

   <xsl:template match="internal-link[@subsection]">
      <a>
         <xsl:attribute name="href">
            <xsl:text>#</xsl:text>
            <xsl:value-of select="ancestor::lesson//@name" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="ancestor::section//@name" />
            <xsl:text>-</xsl:text>
            <xsl:value-of select="@subsection" />
         </xsl:attribute>
         <xsl:apply-templates />
      </a>
   </xsl:template>

   <xsl:template match="web-link">
      <a>
         <xsl:attribute name="href"><xsl:value-of select="@url" /></xsl:attribute>
         <xsl:apply-templates />
      </a>
   </xsl:template>

   <xsl:template match="src-link">
      <code>
         <a>
            <xsl:attribute name="href"><xsl:value-of select="@url" /></xsl:attribute>
            <xsl:apply-templates />
         </a>
      </code>
   </xsl:template>

   <xsl:template match="javadoc-link[@package and @class]">
      <code>
         <a>
         <xsl:attribute name="href">
            <xsl:value-of select="//javadoc-location[@package=current()/@package]/@url" />
            <xsl:value-of select="@package" />
            <xsl:text>/</xsl:text>
            <xsl:value-of select="@class" />
            <xsl:text>.html</xsl:text>
         </xsl:attribute>
         <xsl:value-of select="@class" />
         </a>
      </code>
   </xsl:template>

</xsl:stylesheet>

