<?xml version='1.0'?>
<!DOCTYPE xsl:stylesheet
 [ <!ENTITY xnbsp "&amp;nbsp;">
   <!ENTITY nbsp "&#160;"> ]>
<xsl:stylesheet version="1.0"
                xmlns="http://www.w3.org/TR/xhtml1/transitional"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- Project Notebook XSLT translator stylesheet.

     Project Misc page - generates projdocs.html

      get "subname" from page attribute of project, e.g.
      <project name="cargo cult programming" page="map resources">

     Below that, structure is <section caption="blah"> for main table section,
     and within each section is free HTML/text.

     This is a *very rough* first cut at translating the Project Notebook
     XML document into HTML automatically.
-->

<xsl:output method="html" indent="yes" media-type="text/html"/>

<xsl:include href="shared.xsl" /> <!-- shared definitions for I/S Project -->

<xsl:template match="/project">
    <HTML xmlns="http://www.w3.org/TR/xhtml1/transitional">

    <xsl:call-template name="head-element">
        <xsl:with-param name="title"><xsl:value-of select="@name"/> -- <xsl:value-of select="@page"/></xsl:with-param>
    </xsl:call-template>

    <xsl:element name="BODY" use-attribute-sets="body-attrs">

    <xsl:call-template name="title-block">
        <xsl:with-param name="title"><xsl:value-of select="@page"/></xsl:with-param>
        <xsl:with-param name="subtitle"><xsl:value-of select="/project/@name"/></xsl:with-param>
    </xsl:call-template>

    <TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3" WIDTH="100%">

       <!-- TOC row, links to section elements -->
       <TR>
         <TH WIDTH="141" ALIGN="right">On this page:</TH>
         <TD>
           <xsl:for-each select="section">
              <A><xsl:attribute name="HREF">#<xsl:value-of select="generate-id()"/></xsl:attribute>
                <xsl:value-of select="@caption"/>
              </A>
              <xsl:if test="not(position()=last())"> | </xsl:if>
           </xsl:for-each>

           <xsl:if test="document[@category='basic']"><A href="#basic">Basic Documents</A></xsl:if>
           <xsl:if test="document[@category='communication']"> | <A href="#communication">Communications</A></xsl:if>
           <xsl:if test="document[@category='output']"> | <A href="#output">Project Outputs</A></xsl:if>
           <xsl:if test="document[@category='other']"> | <A href="#other">Other Documents</A></xsl:if>
         </TD>
       </TR>


       <!-- Table row with nothing but a horizontal rule -->
       <TR><TD COLSPAN="2"><HR/></TD></TR>

       <xsl:call-template name="title-row"/>

       <xsl:if test="description">
         <!-- Table row with nothing but a horizontal rule -->
         <TR><TD COLSPAN="2"><P><HR/></P></TD></TR>

         <TR>
            <xsl:element name="TH" use-attribute-sets="left-column">
            <STRONG>Description</STRONG>
            </xsl:element>
            <TD>
            <xsl:apply-templates select="description/*|description/text()" />
            </TD>
         </TR>
       </xsl:if>

       <xsl:for-each select="section">
         <!-- Table row with nothing but a horizontal rule -->
         <TR><TD COLSPAN="2"><P><HR/></P></TD></TR>
          
         <TR>
           <xsl:element name="TH" use-attribute-sets="left-column">
              <STRONG><xsl:value-of select="@caption"/></STRONG><BR/>
           </xsl:element>
           <TD>
             <A><xsl:attribute name="NAME"><xsl:value-of select="generate-id()"/>
                 </xsl:attribute>
               <xsl:apply-templates select="*|text()" /><BR/>
             </A>
           </TD>
         </TR>
       </xsl:for-each>
    </TABLE>
         
    <xsl:call-template name="trailer-block"/>

    </xsl:element> <!-- /body -->
    </HTML>
</xsl:template>

 <!-- If there is no text content, use HREF itself as the text. -->
<xsl:template match="A|a">
 <A HREF="{@href}">
 <xsl:choose>
   <xsl:when test="*|text()">
     <xsl:apply-templates select="*|text()"/>
   </xsl:when>
   <xsl:otherwise>
     <xsl:value-of select="@href"/>
   </xsl:otherwise>
 </xsl:choose>
 </A>
</xsl:template>


</xsl:stylesheet>
