<?xml version='1.0' encoding='ISO-8859-1'?>

<xsl:stylesheet
   version='1.1'
   xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output omit-xml-declaration='yes'/>

<xsl:param name='basepath'>c:\\xml\documents\</xsl:param>
<xsl:param name='docname'>CSE_database.new</xsl:param>

<!-- ecu 660066
     fhs 008060 -->
<!-- for use in toc to reverse colors -->
<xsl:param name='backcolor'>#ffffff</xsl:param>

<xsl:variable name='framepath'>
        <xsl:value-of select='$basepath'/>
        <xsl:value-of select='$docname'/>
        <xsl:text>.frame.html</xsl:text>
</xsl:variable>

<xsl:variable name='tocpath'>
        <xsl:value-of select='$basepath'/>
        <xsl:value-of select='$docname'/>
        <xsl:text>.toc.html</xsl:text>
</xsl:variable>

<xsl:variable name='bodypath'>
        <xsl:value-of select='$basepath'/>
        <xsl:value-of select='$docname'/>
        <xsl:text>.body.html</xsl:text>
</xsl:variable>

<xsl:variable name='TOCpath'>
        <xsl:value-of select='$docname'/>
        <xsl:text>.body.html</xsl:text>
</xsl:variable>

<!-- BEGIN templates -->
<!-- Table of contents template -->
<xsl:template name='toc'>
	<h3><xsl:value-of select='//titleStmt/title'/></h3>
		<xsl:text>Table of Contents</xsl:text>
		<table>	
		<xsl:for-each select='//div0/head'>
		<tr><td colspan="3"><a href="{$TOCpath}#{@n}" target="body"><xsl:value-of select='.'/></a></td></tr>
		</xsl:for-each>
		<xsl:for-each select='//div1/head'>
			<tr><td valign="top"><xsl:value-of select='@n'/><xsl:text>.  </xsl:text></td>
			<td colspan="2"><a href="{$TOCpath}#{@n}" target="body"><xsl:value-of select='.'/></a></td></tr>
				<xsl:for-each select='../div2/head'>
					<tr><td><img src="blank_dot.gif" width="10" height="1"/></td><td valign="top"><xsl:value-of select='@n'/><xsl:text>.  </xsl:text></td>
					<td><a href="{$TOCpath}#{@n}" target="body"><xsl:value-of select='.'/></a></td></tr>
				</xsl:for-each>
		</xsl:for-each>
	</table><p></p>
</xsl:template>

<!-- body template: put body text in a table, to make it look nice -->
<xsl:template name='body'>
	<center><table border="0" cellpadding="0"><tr>
		<td>
			<xsl:apply-templates/>
			<xsl:call-template name='copyright'/>	
		</td>
	</tr></table></center>	
</xsl:template>

<!-- copyright info template -->
<xsl:template name='copyright'>
	<hr height="1"/><p><font size="-1">
			<xsl:value-of select='//date'/><xsl:text> </xsl:text>
			<xsl:value-of select='//publisher'/>
			<xsl:text> at the </xsl:text><xsl:value-of select='//pubPlace'/>
			<xsl:text>. All rights reserved.</xsl:text>
	</font></p>
</xsl:template>
<!-- END templates -->

<xsl:template match='/'>
<!-- BEGIN frame set-up -->
<xsl:document method='html' indent='yes' href='{$framepath}'>
	<xsl:element name='html'>
		<xsl:element name='head'>
			<xsl:element name='title'>
				<xsl:value-of select='//title'/>
			</xsl:element>
			<xsl:element name='frameset'>
				<xsl:attribute name='border'>0</xsl:attribute>
				<xsl:attribute name='cols'>250,*</xsl:attribute>
				<xsl:element name='frame'>
					<xsl:attribute name='name'>
						<xsl:text>toc</xsl:text>
					</xsl:attribute>
					<xsl:attribute name='src'>
						<!-- <xsl:value-of select='$basepath'/> -->
  					<xsl:value-of select='$docname'/>
						<xsl:text>.toc.html</xsl:text>
					</xsl:attribute>
				</xsl:element>
				<xsl:element name='frame'>
					<xsl:attribute name='name'>
						<xsl:text>body</xsl:text>
					</xsl:attribute>
					<xsl:attribute name='src'>
						<!-- <xsl:value-of select='$basepath'/> -->
						<xsl:value-of select='$docname'/>
						<xsl:text>.body.html</xsl:text> 
					</xsl:attribute>
				</xsl:element>
			</xsl:element><!-- frameset -->
		</xsl:element><!-- head -->
	</xsl:element><!-- html -->
</xsl:document>
<!-- END frame set-up -->

<!-- BEGIN toc page -->
<xsl:document method='html' indent='yes' href='{$tocpath}'>
	<xsl:element name='html'>
		<xsl:element name='head'>
			<xsl:element name='style'>
				<xsl:text>h1, h2, h3, h4, h5, h6 {font-family:arial; color:black}</xsl:text>
			</xsl:element>
		</xsl:element>
		<xsl:element name='body'>
			<xsl:attribute name='style'>
				<xsl:text>margin-top:0.1in; margin-left:0.15in; margin-right:0.1in; margin-bottom:0in; background-color:#ffffff; font-family: arial</xsl:text>
			</xsl:attribute>
			<xsl:call-template name='toc'/>
		</xsl:element>
	</xsl:element>
</xsl:document>
<!-- END toc page -->

<!-- BEGIN body page -->
<xsl:document method='html' indent='yes' href='{$bodypath}'>
	<xsl:element name='html'>
		<xsl:element name='head'>
			<xsl:element name='style'>
				<xsl:text>h1, h2, h3, h4, h5, h6 {font-family:arial; color:navy}
p {text-align:justify}</xsl:text>
			</xsl:element>
		</xsl:element>
		<xsl:element name='body'>
			<xsl:attribute name='style'>
				<xsl:text>margin-top:0.25in; margin-left:0.25in; margin-right:0.25in; margin-bottom:3.0in; font-family: century</xsl:text>
			</xsl:attribute>
			<xsl:call-template name='body'/>
		</xsl:element>
	</xsl:element>
</xsl:document>
<!-- END body page -->
</xsl:template>

<!-- remainder of stylesheet -->
<!-- indent div2 text in a dl list -->
<xsl:template match='div2'>
	<dl><dd><xsl:apply-templates/></dd></dl>
</xsl:template>
<xsl:template match='div2/p'>
	<p><xsl:apply-templates/></p>
</xsl:template>

<!-- puts div0 heads in h3 assign name anchors -->
<xsl:template match='body//div0/head'>
	<h3><xsl:value-of select='.'/></h3>
</xsl:template>

<!-- puts div1 heads h3 and assign name anchors -->
<xsl:template match='body//div1/head'>
	<hr width="60%" size="2" align="left"/>
	<xsl:if test='(@n)'>
		<a name="{@n}"></a>
	</xsl:if>
	<h3><xsl:value-of select='@n'/><xsl:text>.  </xsl:text>
  <xsl:value-of select='.'/></h3>
</xsl:template>

<!-- put div2 heads in h3 and assign name anchors -->
<xsl:template match='body//div2/head'>
	<h3><a name="{@n}"></a>
	<xsl:value-of select='@n'/><xsl:text>.  </xsl:text>
	<xsl:apply-templates/></h3>
</xsl:template>

<!-- put href tags in -->
<xsl:template match='body//xref'>
	<a href="{unparsed-entity-uri(@doc)}" target="_blank">	
	<xsl:apply-templates/>
	</a>
</xsl:template>

<!-- figure illustrations and captions -->
<xsl:template match='body//figure'>
	<p><table border="0" cellpadding="0" cellspacing="3">
		<tr><td>
			<img src="{unparsed-entity-uri(@entity)}" border="1"/>
		</td></tr>
		<tr><td>
			<font face="arial"><xsl:text>Figure </xsl:text><xsl:value-of select='@n'/>
			<xsl:text>: </xsl:text><xsl:value-of select='figDesc'/></font>
		</td></tr></table></p>
</xsl:template>

<!-- <xsl:template match='figDesc'>
	<p><xsl:apply-templates/></p>
</xsl:template> -->

<!-- put <P> in -->
<xsl:template match='p'>
	<p><xsl:apply-templates/></p>
</xsl:template>

<!-- lists -->
<xsl:template match='list[@type="numbered"]'>
	<ol><xsl:apply-templates/></ol>
</xsl:template>
<xsl:template match='list[@type="numbered"]/item'>
	<p><li><xsl:apply-templates/></li></p>
</xsl:template>

<!-- typeface -->
<xsl:template match='hi[@rend]'>
	<xsl:if test='(@rend="italics")'>
		<em><xsl:apply-templates/></em>
	</xsl:if>
</xsl:template>

<!-- gets rid of unwanted stuff and things that duplicate-->
<xsl:template match='titleStmt | sourceDesc | publicationStmt | docAuthor | docTitle | back'>
</xsl:template>

</xsl:stylesheet>
