<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		version="1.0">


<!-- strip leading and trailing whitespace from all elements ... -->
<xsl:strip-space elements="*"/>

<xsl:param name="expandID">empty</xsl:param>
<xsl:param name="backID">blort</xsl:param>
<xsl:param name="contentID">foo</xsl:param>

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

<!-- ******************************************************* -->
<!-- ******************************************************* -->

<!-- root template: controls overall page layout --> 

<xsl:template match="/">
  <tr>
    <td width="25%" valign="top"><!-- cell for TOC -->
      <table border="0" cellspacing="4" cellpadding="0">
        <tr><td><h2>
          <a href="itDecShowText.php?myID={$backID}&amp;expand={$expandID}">[back]</a>
        </h2></td></tr>
      </table>
    </td>
    <td align="left" valign="top"><!-- cell for main content -->
      <div>
       <xsl:apply-templates select="//p[descendant::milestone/@id = $contentID] | //lg[descendant::milestone/@id = $contentID]"/>
      </div>
    </td>
  </tr>
</xsl:template>


<!-- ******************************************************* -->
<!-- ******************************************************* -->

<!-- templates for content -->

<xsl:template match="milestone">
 <xsl:variable name="selfID" select="@id"/>
 <xsl:choose>
  <xsl:when test="@id = $contentID">
   <span class="hilit">[<xsl:value-of select="substring($selfID, 7, 3)"/>]</span>
  </xsl:when>
  <xsl:otherwise>
   [<xsl:value-of select="substring($selfID, 7, 3)"/>]
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="p">
 <xsl:variable name="nearID" select="ancestor::*[@id][1]/@id"/>
 <xsl:variable name="farID" select="ancestor::*[@id][2]/@id"/>
 <xsl:variable name="nearHead" select="ancestor::*[@id][1]/head"/>
 <xsl:variable name="farHead">
  <xsl:choose>
   <xsl:when test="ancestor::*[@id][2]">
   <xsl:value-of select="ancestor::*[@id][2]/head"/>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="//fileDesc"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
  <h3>
   <a href="engDecShowText.php?myID={$nearID}&amp;expand={$farID}"><xsl:value-of select="$farHead"/>, <xsl:value-of select="$nearHead"/></a>
  </h3>
  <p>
   <xsl:apply-templates/>
  </p>
</xsl:template>

<xsl:template match="lg">
 <xsl:variable name="nearID" select="ancestor::*[@id][1]/@id"/>
 <xsl:variable name="farID" select="ancestor::*[@id][2]/@id"/>
 <xsl:variable name="nearHead" select="ancestor::*[@id][1]/head"/>
 <xsl:variable name="farHead">
  <xsl:choose>
   <xsl:when test="ancestor::*[@id][2]">
   <xsl:value-of select="ancestor::*[@id][2]/head"/>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="//fileDesc"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
  <h3>
   <a href="engDecShowText.php?myID={$nearID}&amp;expand={$farID}"><xsl:value-of select="$farHead"/>, <xsl:value-of select="$nearHead"/></a>
  </h3>
  <p>
  <xsl:if test="position()= 1">
   <span class="framing">[Voice: <xsl:value-of select="parent::div3/@who"/>]</span><br/>
  </xsl:if>
   <xsl:apply-templates/>
  </p>
</xsl:template>

<xsl:template match="l">
 <xsl:apply-templates/>
 <br/>
</xsl:template>

<xsl:template match="note">
</xsl:template>

<xsl:template match="q">
 <xsl:text>"</xsl:text><xsl:apply-templates/><xsl:text>"</xsl:text>
</xsl:template>

<xsl:template match="title">
 <em>
  <xsl:apply-templates/>
 </em>
</xsl:template>

<!-- ******************************************************* -->
<!-- ******************************************************* -->



<!-- COMMENTED OUT





 -->

</xsl:stylesheet>

