<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://icl.com/saxon"
extension-element-prefixes="saxon">

<xsl:output method="html" indent="yes" />

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

      <head>
        <title><xsl:value-of select="//teiHeader/title"/></title>
        <style>
          body       { margin-left:50px; background-color: #F9EEDC; margin-right: 50px; font-family: Times, serif;}
          list		{font-family: Times, serif; color: blue}
          p          { margin-top: .5em; margin-bottom: .25em; }
          hr         { color: #663300; }
	  .dedicat {text-align: center}
	  .catchword {margin-left: 380px}
	  .collation {margin-top:14px; color:brown; margin-bottom: 12px; text-align:center}
	  .titlePage {text-align:center}
	.unclear {color: red}
    .indent {margin-left: 20px}
        </style>
      </head>

      <body bgcolor="#FFFFFF">
	<div CLASS="body">

        <xsl:apply-templates />

	</div>
     </body>
    </html>

  </xsl:template>

<!-- main sections -->

	<xsl:template match="div1[@type='dedicatory epistle']">
		<div CLASS="dedicat"><xsl:apply-templates/></div>
	</xsl:template>

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

	<xsl:template match="front">
        <hr/><center>The Folio Works of Ben Jonson.</center><xsl:apply-templates/>
	</xsl:template>

<!-- titlepages -->

<xsl:template match="titlePage">
      <div CLASS="titlePage">
        <xsl:apply-templates/>
      </div>
</xsl:template>

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

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

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

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

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

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

<!-- Images (assumes files in "images" directory) -->

<xsl:template match="figure">
	<xsl:choose>
		<xsl:when test="@rend='inline'">
			<img><xsl:attribute name="src"><xsl:text>images/</xsl:text><xsl:value-of select="@entity"/><xsl:text>.jpg</xsl:text></xsl:attribute></img>
		</xsl:when>
		<xsl:otherwise>
	<br/><a target="_wblank"><xsl:attribute name="HREF">images/<xsl:value-of select="@entity"/>.jpg
	</xsl:attribute>Image</a><br/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

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

      <xsl:template match="figure[@rend='orn']">
         <font size="+2"><b><xsl:apply-templates/></b></font>
        </xsl:template>


<!-- Verse -->

 	<xsl:template match="lg">

  	<blockquote><xsl:apply-templates/></blockquote>
  	</xsl:template>

 	<xsl:template match="l">
	<xsl:choose>
		<xsl:when test="rend='catchword'">
		<div CLASS="catchword"><xsl:apply-templates/></div>
		</xsl:when>
		<xsl:otherwise>

  	<xsl:apply-templates/><br/>
		</xsl:otherwise>
	</xsl:choose>
 	</xsl:template>

<!-- UNCLEARS -->

	<xsl:template match="unclear">
  	<span CLASS="unclear">?<xsl:apply-templates/>?</span>

  	</xsl:template>


<!-- DRAMA -->

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


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

  </xsl:template>

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

<xsl:template match="speaker">
        <font color="#993300;"><xsl:apply-templates/></font>
</xsl:template>

<xsl:template match="sp/p">
 <xsl:apply-templates/><lb/><lb/>
  </xsl:template>

<xsl:template match="sp/lg">
 <blockquote><xsl:apply-templates/></blockquote>
  </xsl:template>


<!-- Notes -->

<xsl:template match="note">

	<a><xsl:attribute name="HREF">#<xsl:value-of select="@target"/>
	</xsl:attribute><sup><font color="red"><xsl:value-of select="@n"/></font></sup></a>

 	<a><xsl:attribute name="NAME">
	<xsl:value-of select="@id"/></xsl:attribute></a>
	<xsl:apply-templates/>

</xsl:template>
	

	<xsl:template match="body/div1/note">
      <xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="body/div1/note">

      <xsl:apply-templates/>
	</xsl:template>

<!-- Page layout -->

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

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

  	</xsl:template>

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

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

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

	<xsl:template match="pb">
      <hr width="50%"/>
      <center><i>--<xsl:value-of select="@n"/>--</i>
<br/><a target="_wblank"><xsl:attribute name="HREF">images/<xsl:value-of select="@id"/>.jpg</xsl:attribute>Image</a><br/><br/></center>

	</xsl:template>

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

	<xsl:template match="fw">
		<br/>[<xsl:apply-templates/>]
	</xsl:template>
	
	<xsl:template match="milestone">
      <div CLASS="collation"><xsl:value-of select="@n"/></div>
	</xsl:template>
	
	<xsl:template match="//seg">
		<p class="indent"><xsl:apply-templates/></p>
	</xsl:template>

<!-- letters -->

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

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

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

 	</xsl:template>

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

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

	<xsl:template match="opener/dateline/name">
	<br/><xsl:apply-templates/>
 	</xsl:template>

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

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

	</xsl:template>

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

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

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

	<xsl:template match="seg">
	<xsl:choose>
		<xsl:when test="@type='catchword'">
		<div CLASS="catchword"><xsl:apply-templates/></div>
		</xsl:when>

		<xsl:otherwise>
	      <br/><xsl:apply-templates/>
		</xsl:otherwise>
	</xsl:choose>
	</xsl:template>

<!-- head -->

	<xsl:template match="head">
     <center><h3><xsl:apply-templates/></h3></center>

	</xsl:template>

<!-- tables -->


	<xsl:template match="table">
      <table><xsl:apply-templates/></table>
	</xsl:template>
	
	<xsl:template match="row">
      <tr><xsl:apply-templates/></tr>
	</xsl:template>

	<xsl:template match="cell">
		<xsl:choose>
		<xsl:when test="@role='section head'">
      <td><h3 align="center"><xsl:apply-templates/></h3></td>
		</xsl:when>
		<xsl:when test="@role='label'">
			<td><b><xsl:apply-templates/></b></td>
		</xsl:when>
			<xsl:when test="@role='data'">
				<td><xsl:apply-templates/></td>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
	
<!-- lists -->

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

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

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

<!-- typography -->

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

	<xsl:template match="hi[@rend='bold']">
		<b><xsl:apply-templates/></b></xsl:template>

	<xsl:template match="hi[@rend='italic']">
		<i><xsl:apply-templates/></i></xsl:template>

	<xsl:template match="hi[@rend='underline']">
		<u><xsl:apply-templates/></u></xsl:template>

	<xsl:template match="hi[@rend='sup']">

		<sup><xsl:apply-templates/></sup></xsl:template>

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

	<xsl:template match="emph[@rend='bold']">
		<b><xsl:apply-templates/></b></xsl:template>

	<xsl:template match="emph[@rend='italic']">
		<i><xsl:apply-templates/></i></xsl:template>

	<xsl:template match="emph[@rend='underline']">
		<u><xsl:apply-templates/></u></xsl:template>

	<xsl:template match="emph[@rend='sup']">
		<sup><xsl:apply-templates/></sup></xsl:template>

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

<!-- links -->

<xsl:template match="//xref">
  <a href="{@to}">
    <xsl:apply-templates/>
  </a>
</xsl:template>


<!-- Press Variants -->

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

<xsl:template match="rdg">
	<li>
		<font color="red">
			<xsl:apply-templates/>
		</font>
	</li>
</xsl:template>
	
	
</xsl:stylesheet>

