<?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%">

       <!-- XXX can we dike the "title" block since it's bigger in the header?
            Seems pretty silly to have it in a row like this.
        -->
       <TR>
          <xsl:element name="TH" use-attribute-sets="left-column">
            <STRONG>Project Title</STRONG>
          </xsl:element>
          <TD><xsl:value-of select="@name"/>
          </TD>
       </TR>

       <!-- 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>Contact Information</STRONG>
          </xsl:element>
          <TD>
             Email:
             <A>
             <xsl:attribute name="HREF">mailto:<xsl:value-of select="contact/text()"/></xsl:attribute>
             <STRONG>
             <xsl:value-of select="contact/text()"/>
             </STRONG></A>
          </TD>
       </TR>

       <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>
              <xsl:apply-templates select="*|text()" /><BR/>
           </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>
