<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:n1="http://www.ndltd.org/standards/metadata/etdms/1.0/"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<xsl:output method="html" />

<xsl:template match="n1:front">
		<xsl:for-each select="n1:title">
			<span style="font-size:x-large">
			<xsl:apply-templates />
				<br/>
			</span>
			<xsl:if test="position()!=last()">
				<br/>
			</xsl:if>
		</xsl:for-each><br/>
		<xsl:for-each select="n1:alternativeTitle">
			<span style="font-size:larger"><xsl:apply-templates />
				<br/>
				<br/>
			</span>
		</xsl:for-each>
		<xsl:for-each select="n1:creator">
			<xsl:if test="position()=1">
				<span style="text-decoration:underline">Author:</span>
				<xsl:text disable-output-escaping="yes">&lt;ul&gt;</xsl:text>
			</xsl:if>
			<li>
				<xsl:apply-templates />
			</li>
			<xsl:if test="position()=last()">
				<xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="n1:contributor">
			<xsl:if test="position()=1">
				<span style="text-decoration:underline">Committee:</span>
				<xsl:text disable-output-escaping="yes">&lt;ul&gt;</xsl:text>
			</xsl:if>
			<li>
				<xsl:apply-templates />
			</li>
			<xsl:if test="position()=last()">
				<xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="n1:subject">
			<xsl:if test="position()=1">
				<span style="text-decoration:underline">Subject:</span>
				<xsl:text disable-output-escaping="yes">&lt;ul&gt;</xsl:text>
			</xsl:if>
			<li>
				<xsl:apply-templates />
			</li>
			<xsl:if test="position()=last()">
				<xsl:text disable-output-escaping="yes">&lt;/ul&gt;</xsl:text>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="n1:description">
			<xsl:if test="position()=1">
				<span style="text-decoration:underline">Description:</span>
				<br/>
				<br/>
			</xsl:if>
			<div>
				<xsl:apply-templates />
			</div>
			<br/>
		</xsl:for-each><xsl:for-each select="n1:publisher">
			<xsl:if test="position()=1">
				<span style="text-decoration:underline">Publisher:</span>
				<br/>
			</xsl:if>
				<xsl:apply-templates />
			<br/>
			<xsl:if test="position()=last()">
				<br/>
			</xsl:if>
		</xsl:for-each>
<!--	AH HA!, there is only 1 date, so just grab the value. -->
<!--		<xsl:for-each select="n1:date"> -->
		<span style="text-decoration:underline">Date:</span><br/><xsl:value-of select="n1:date"/>
			<br/>
<!--		</xsl:for-each> -->
		<br/>
		<xsl:for-each select="n1:coverage">
			<xsl:if test="position()=1">
				<span style="text-decoration:underline">Coverage:</span>
			</xsl:if>
			<div>
				<xsl:apply-templates />
			</div>
		</xsl:for-each>
		
		<!-- <xsl:call-template name="degree" /> -->
		<xsl:for-each select="n1:degree">
			<xsl:if test="position()=1">
				Degree:
			</xsl:if>
			<br/>
			<table border="1">
				<xsl:for-each select="n1:name">
					<tr>
						<td>Name</td>
							<td>
								<xsl:apply-templates />
							</td>
					</tr>
				</xsl:for-each>
				<xsl:for-each select="n1:level">
					<tr>
						<td>Level</td>
							<td>
								<xsl:apply-templates />
							</td>
					</tr>
				</xsl:for-each>
				<xsl:for-each select="n1:discipline">
					<tr>
						<td>Discipline</td>
							<td>
								<xsl:apply-templates />
							</td>
					</tr>
				</xsl:for-each>
				<xsl:for-each select="n1:grantor">
					<tr>
						<td>Grantor</td>
							<td>
								<xsl:apply-templates />
							</td>
					</tr>
				</xsl:for-each>
			</table>
		</xsl:for-each>

		<xsl:for-each select="n1:table">
			<xsl:apply-templates />
		</xsl:for-each>
</xsl:template>

<xsl:template name="degree">
	<xsl:for-each select="n1:degree">
	<xsl:if test="position()=1">
		<hr/>Degree:
	</xsl:if>
		<br/>
			<table border="1">
				<xsl:for-each select="n1:name">
					<tr>
						<td>Name</td>
							<td>
								<xsl:apply-templates />
							</td>
					</tr>
				</xsl:for-each>
				<xsl:for-each select="n1:level">
					<tr>
						<td>Level</td>
							<td>
								<xsl:apply-templates />
							</td>
					</tr>
				</xsl:for-each>
				<xsl:for-each select="n1:discipline">
					<tr>
						<td>Discipline</td>
							<td>
								<xsl:apply-templates />
							</td>
					</tr>
				</xsl:for-each>
				<xsl:for-each select="n1:grantor">
					<tr>
						<td>Grantor</td>
							<td>
								<xsl:apply-templates />
							</td>
					</tr>
				</xsl:for-each>
			</table>
	</xsl:for-each>
</xsl:template>

<!--possibly make this a for loop-->
<!--match the 2'nd level <front><body><back> of the the thesis-->


<!-- SHOULD BE ABLE TO NOT HAVE A TITLE IN CASES OF PRAG, QUOTE, PRAG
           <complexType name = "section" mixed="true" >
           <annotation>
           </annotation>
               <sequence>

                    <element name = "sectionTitle"      type ="ETD_MS:freeTextType" minOccurs="0" maxOccurs="1" />
                    <element ref = "ETD_MS:section"    minOccurs="0" maxOccurs="unbounded" /> 
                    <element name = "paragraph"  type ="ETD_MS:freeTextType" minOccurs="0" maxOccurs="unbounded" />
                    <element name = "table"      type ="ETD_MS:freeTextType" minOccurs="0" maxOccurs="unbounded" />
                    <element name = "quote"      type ="ETD_MS:freeTextType" minOccurs="0" maxOccurs="unbounded" />
                    <element name = "figure"     type ="ETD_MS:freeTextType" minOccurs="0" maxOccurs="unbounded" />
               </sequence>
           </complexType>
           
           <complexType name="chapter">

             <annotation>
               <documentation>
					XML spy doesn't know how to "ref=Section"
					Think about pulling this out and making it global so that It can just be pulled in
					as needed
					
					this makes the recursion work (at least it isn't producing a warning by XML spy
               </documentation>
             </annotation>

               <sequence>	
                   <element name = "chapterTitle" type="ETD_MS:freeTextType" minOccurs="1" maxOccurs="1" />
                   <element name = "section" type="ETD_MS:section"  minOccurs="1" maxOccurs="unbounded" /> 
                </sequence>
           </complexType>

-->
<xsl:template match="n1:picture">
</xsl:template>
<xsl:template match="n1:width">
</xsl:template>
<xsl:template match="n1:height">
</xsl:template>

<xsl:template match="n1:image">
	<xsl:apply-templates />
	<xsl:text disable-output-escaping="yes">&lt;img </xsl:text><!--need the space before end of tag -->
		<xsl:for-each select="n1:width">
			<xsl:if test="position()=1">
				width="<xsl:value-of select="." />"
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="n1:height">
			<xsl:if test="position()=1">
				height="<xsl:value-of select="." />"
			</xsl:if>
		</xsl:for-each>
	<xsl:text disable-output-escaping="yes">src=&quot;</xsl:text>
	<xsl:value-of select="n1:picture" />
	<xsl:text disable-output-escaping="yes">&quot;&gt;</xsl:text>
</xsl:template>

<xsl:template match="n1:forename">
	<xsl:apply-templates />
</xsl:template>
<xsl:template match="n1:surname">
	<xsl:apply-templates /><xsl:text disable-output-escaping="yes">, </xsl:text>
</xsl:template>
<xsl:template match="n1:title">
	<xsl:apply-templates />
</xsl:template>
<xsl:template match="n1:suffix">
	<xsl:apply-templates />
</xsl:template>
<xsl:template match="n1:initials">
	<xsl:apply-templates />
</xsl:template>
<xsl:template match="n1:email">
	<xsl:apply-templates />
</xsl:template>

<xsl:template match="n1:Reference.publication">
	<xsl:apply-templates /><xsl:text disable-output-escaping="yes">, </xsl:text>
</xsl:template>
<xsl:template match="n1:Reference.publicationLocation">
	<xsl:apply-templates /><xsl:text disable-output-escaping="yes">: </xsl:text>
</xsl:template>

<xsl:template match="n1:Reference.author">
	<xsl:apply-templates /><xsl:text disable-output-escaping="yes">. </xsl:text>
</xsl:template>
<xsl:template match="n1:Reference.editor">
	<xsl:apply-templates /><xsl:text disable-output-escaping="yes">. </xsl:text>
</xsl:template>
<xsl:template match="n1:Reference.title">
	"<xsl:apply-templates /><xsl:text disable-output-escaping="yes">," </xsl:text>
</xsl:template>
<xsl:template match="n1:Reference.publication">
	<i><xsl:apply-templates /></i><xsl:text disable-output-escaping="yes">, </xsl:text>
</xsl:template>
<xsl:template match="n1:Pages">
	<xsl:apply-templates />
</xsl:template>
<xsl:template match="n1:publicationDate">
	(<xsl:apply-templates />)
</xsl:template>

<xsl:template match="n1:Reference">
	<xsl:apply-templates />.
	<br/>
</xsl:template>


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

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

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

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

<xsl:template match="n1:cell">
<td>
	<xsl:apply-templates />
</td>
</xsl:template>

<xsl:template match="n1:bold_cell">
<td><b>
	<xsl:apply-templates />
</b></td>
</xsl:template>

<xsl:template match="n1:bold_row">
	<xsl:apply-templates />
</xsl:template>
<xsl:template match="n1:tablebody">
	<table border="1">
		<xsl:apply-templates />
	</table>
</xsl:template>

<xsl:template match="n1:label">
<p>
<b>
	<xsl:apply-templates />
</b>
</p>
</xsl:template>

<xsl:template match="n1:caption">
<font size="3">
	<xsl:apply-templates />
</font>
</xsl:template>

<xsl:template match="n1:quote" >
	<center>
		<table width="80%">
			<xsl:apply-templates />
		</table>
	</center>
</xsl:template >

<xsl:template match="n1:sectionTitle" >
	<p>
	<font size="5"><xsl:apply-templates /></font>
	</p>
</xsl:template >

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

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

<xsl:template match="n1:body" >
<hr />
	<xsl:for-each select="n1:chapter">
		<font size="6"><xsl:apply-templates select="n1:chapterTitle" /></font>
		<br/><br/>
		<xsl:for-each select="n1:section">
			<xsl:apply-templates />
		</xsl:for-each>
	</xsl:for-each>
</xsl:template>

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

<!--step into the first level <thesis> -->
<xsl:template match="n1:thesis">
	<xsl:apply-templates select="n1:front" />
	<xsl:apply-templates select="n1:body" />
	<xsl:apply-templates select="n1:back" />
</xsl:template>


<xsl:template match="n1:appendixTitle">
	<p>
	<font size="5"><xsl:apply-templates /></font>
	</p>
</xsl:template>
<xsl:template match="n1:bibliography">
	<h1>References</h1>
	<xsl:apply-templates />
</xsl:template>

<xsl:template match="n1:apendix">
	<xsl:apply-templates />
</xsl:template>
<xsl:template match="/">
	<html>
		<head/>
			<body>
			<!-- will match against the thesis tag defined above -->
			<xsl:apply-templates />
		</body>
	</html>
</xsl:template>

</xsl:stylesheet>
