<?xml version='1.0'?>
<!--
 XSL HTML stylesheet for simple TEI Lite documents, for use only with IE5 XSL
 
 1.0   July 22nd 1999

 Sebastian Rahtz <sebastian.rahtz@oucs.ox.ac.uk>
 Lou Burnard <lou.burnard@oucs.ox.ac.uk>
-->

<!DOCTYPE xsl:stylesheet [
 <!ENTITY copy  "&#169;">
]>
<xsl:stylesheet 
 xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="text()"><xsl:value-of select="."/></xsl:template>


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

<xsl:template match="/">
   <xsl:apply-templates select="TEI.2"/>
</xsl:template>

<xsl:template match="TEI.2">
 <html> 
 <head>
 <title><xsl:apply-templates select="/TEI.2//front//docTitle//text()"/></title>
 </head>
 <body bgcolor="#ffffff">
<!-- try to make a table of contents of top-level divs or div1s -->
 <xsl:choose>
 <xsl:when test="//div">
  <ul>
   <xsl:for-each select="//body/div">
    <li>
     <a><xsl:attribute name="href">#<xsl:eval>uniqueID(this)</xsl:eval></xsl:attribute>
      <xsl:eval>formatIndex(childNumber(this), "1")</xsl:eval>.
      <xsl:apply-templates select="head">
       <xsl:template match="head">
        <xsl:apply-templates/>
       </xsl:template>
      </xsl:apply-templates>
    </a>
    </li>
   </xsl:for-each>
 </ul>
</xsl:when>
 <xsl:when test="//div1">
 <ul>
 <xsl:for-each select="//body/div1">
  <li><a>
   <xsl:attribute name="href">#<xsl:eval>uniqueID(this)</xsl:eval></xsl:attribute>
  <xsl:eval>formatIndex(childNumber(this), "1")</xsl:eval>.
  <xsl:apply-templates select="head">
   <xsl:template match="head">
     <xsl:apply-templates select="text()"/>
   </xsl:template>
  </xsl:apply-templates>
  </a>
  </li>
 </xsl:for-each>
 </ul>
 </xsl:when>
 </xsl:choose>
<!-- dont process the TEI header! -->
 <xsl:apply-templates select="//front"/>
 <xsl:apply-templates select="//body"/>
 <xsl:apply-templates select="//back"/>
 <hr/><address>
 Last updated: <xsl:value-of select="/TEI.2/teiHeader//revisionDesc//date[1]"/>
 </address>
 <hr/>
 <center>
 [<a href="http://www.ox.ac.uk/">Oxford University Home Page</a> |
  <a href="http://www.oucs.ox.ac.uk/">OUCS Home Page</a> ]
  </center>
 <hr/>
 </body>
 </html>
</xsl:template>


<!-- divs of various kinds -->

<xsl:template match="div1/head"/>
<xsl:template match="div2/head"/>
<xsl:template match="div/head"/>

<xsl:template match="div">
 <h2>
  <a><xsl:attribute name="name"><xsl:eval>uniqueID(this)</xsl:eval></xsl:attribute></a>
  <xsl:eval>formatIndex(childNumber(this), "1")</xsl:eval>.
  <xsl:value-of select="head"/>
 </h2>
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="div/div">
 <h3>
  <a><xsl:attribute name="name"><xsl:eval>uniqueID(this)</xsl:eval></xsl:attribute></a>
  <xsl:eval>formatIndex(childNumber(this), "1")</xsl:eval>.
  <xsl:value-of select="head"/>
 </h3>
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="div1">
 <h2>
  <a><xsl:attribute name="name"><xsl:eval>uniqueID(this)</xsl:eval></xsl:attribute></a>
  <xsl:eval>formatIndex(childNumber(this), "1")</xsl:eval>.
  <xsl:value-of select="head"/>
 </h2>
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="div2">
 <h3>
  <a><xsl:attribute name="name"><xsl:eval>uniqueID(this)</xsl:eval></xsl:attribute></a>
  <xsl:eval>formatIndex(childNumber(this), "1")</xsl:eval>.
  <xsl:value-of select="head"/>
 </h3>
 <xsl:apply-templates/>
</xsl:template>


<!-- lists -->

<xsl:template match="list">
<ul>
<xsl:for-each select="item">
  <li><xsl:apply-templates/></li>
</xsl:for-each>
</ul>
</xsl:template>

<xsl:template match="list[@type='ordered']">
<ol>
<xsl:for-each select="item">
  <li><xsl:apply-templates/></li>
</xsl:for-each>
</ol>
</xsl:template>

<xsl:template match="list[@type='gloss']">
<dl>
  <xsl:apply-templates/>
</dl>
</xsl:template>

<xsl:template match="list[@type='gloss']/label">
<dt><b><xsl:apply-templates/></b></dt>
</xsl:template>

<xsl:template match="list[@type='gloss']/item">
<dd><xsl:apply-templates/></dd>
</xsl:template>

<!-- other paragraph-level objects -->
<xsl:template match="p">
 <p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="eg">
<pre><xsl:apply-templates/>
</pre>
</xsl:template>

<!-- inline elements -->
<xsl:template match="gi">
 <tt>&lt;<xsl:apply-templates/>&gt;</tt>
</xsl:template>

<xsl:template match="hi">
 <i><xsl:apply-templates/></i>
</xsl:template>

<!-- cross-references -->
<xsl:template match="xref">
 <a>
 <xsl:attribute name="href">
  <xsl:value-of select="@doc"/>
 </xsl:attribute>
 <xsl:apply-templates/>
 </a>
</xsl:template>

<xsl:template match="ref">
 <a>
 <xsl:attribute name="href">
 #<xsl:apply-templates select="id(@target)">
   <xsl:template match="*">
     <xsl:eval>uniqueID(this)</xsl:eval>
   </xsl:template>
 </xsl:apply-templates>
 </xsl:attribute>
 <xsl:apply-templates/>
 </a>
</xsl:template>
<xsl:script><![CDATA[
  function sectionNum(e) {
    if (e)
    {
      // if element is a child of the back-matter use an appendix number
      if (e.parentNode.nodeName == "back")
        return formatIndex(absoluteChildNumber(e), "A") + ".";
      else
        return sectionNum(e.selectSingleNode("ancestor(inform-div1|div1|div2|div3|div4|div5)")) +
             formatIndex(childNumber(e), "1") + ".";
    }
    else
    {
      return "";
    }
  }
]]></xsl:script>


</xsl:stylesheet>


