<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" version="4.0" encoding="iso-8859-1" indent="yes" />
	<!--
		Copyright (C) 2002  <MITH>
		This program is free software; you can redistribute it and/or modify
		it under the terms of the GNU General Public License as published by
		the Free Software Foundation; either version 2 of the License, or
		(at your option) any later version.
		
		This program is distributed in the hope that it will be useful,
		but WITHOUT ANY WARRANTY; without even the implied warranty of
		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
		GNU General Public License for more details.
		
		You should have received a copy of the GNU General Public License
		along with this program; if not, write to the Free Software
		Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
		
		@ author Amit Kumar/Jarom  15 th of Feb MITH <kumar@umd.edu>
		@ version draws heavily from the code orginaly written by jarom
		@ date-modified 1st of May 2003  both parallel and engine.xsl use same js
		@ date-modified 20th of May 2003  Min-Height style param added for div to 
		solve squishy div's problem
		@ modified 12-8-04 to add xsl output type, allowing for local machine support through firefox, mozilla, and netscape
	-->

	<!-- variables to parse witness list for XSL use -->
	<xsl:variable name="witnessList">
		<xsl:for-each select="//file">
			<xsl:value-of select="./@sigil" />
			<xsl:if test="position()!=last()">
				<xsl:text> </xsl:text>
			</xsl:if>
		</xsl:for-each>
	</xsl:variable>
	
	<xsl:variable name="imageTest">
		<xsl:for-each select="//file">
			<xsl:if test="document(@filename)[//figure]">
				yes
			</xsl:if>
		</xsl:for-each>
	</xsl:variable>

	<!-- current version being parsed -->
	<xsl:param name="version"></xsl:param>

	<xsl:variable name="indent">
		&#160;
	</xsl:variable>

	<xsl:variable name="witnumbers" select="//files/file" />
	<xsl:variable name="witlimit">
		<xsl:value-of select="count($witnumbers)" />
	</xsl:variable>
	
	<!-- rendering template for paragraph level styles -->
	<xsl:template name="render">
		<xsl:param name="style" />
		<xsl:choose>
			<!-- bold text -->
			<xsl:when test="$style='bold'">
				<strong><xsl:apply-templates /></strong>
			</xsl:when>
			<!-- italicized text -->
			<xsl:when test="$style='italic'">
				<em><xsl:apply-templates /></em>
			</xsl:when>
			<!-- small-caps text -->
			<xsl:when test="$style='small-caps'">
				<small><xsl:apply-templates /></small>
			</xsl:when>
			<!-- all-caps text -->
			<xsl:when test="$style='all-caps'">
				<span class="all-caps"><xsl:apply-templates /></span>
			</xsl:when>
			<!-- encase text in single quotes -->
			<xsl:when test="$style='singlequote'">
				'<xsl:apply-templates />'
			</xsl:when>
			<!-- encase text in double quotes -->
			<xsl:when test="$style='doublequote'">
				"<xsl:apply-templates />"
			</xsl:when>
			<!-- underline text -->
			<xsl:when test="$style='underline'">
				<span class="underline"><xsl:apply-templates /></span>
			</xsl:when>
			<!-- strikethrough text -->
			<xsl:when test="$style='strike'">
				<del><xsl:apply-templates /></del>
			</xsl:when>
			<xsl:when test="$style='strikethrough'">
				<del><xsl:apply-templates /></del>
			</xsl:when>
			<!-- place text in a blockquote -->
			<xsl:when test="$style='blockquote'">
				<blockquote><p><xsl:apply-templates /></p></blockquote>
			</xsl:when>
			<!-- big text -->
			<xsl:when test="$style='large'">
				<big><xsl:apply-templates /></big>
			</xsl:when>
			<!-- small text -->
			<xsl:when test="$style='small'">
				<small><xsl:apply-templates /></small>
			</xsl:when>
			<!-- indented text -->
			<xsl:when test="$style='indent'">
				&#09;<xsl:apply-templates />
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="figures">
		<xsl:param name="wit" />
		<xsl:param name="thefile" />
		<xsl:for-each select="document($thefile)//figure">
			<xsl:value-of select="$wit"/>[<xsl:value-of select="position()-1"/>] = '<xsl:call-template name="filenameClip">
				<xsl:with-param name="filestring" select="unparsed-entity-uri(@entity)" />
			</xsl:call-template>';
		</xsl:for-each>
	</xsl:template>
	
	<xsl:template match="/files">
		<html>
			<head>
				<title>The Versioning Machine 3.2</title>
				<link rel="stylesheet" href="../src/vmachine.css" type="text/css" />
				<script type="text/javascript" src="../src/vmachine.js"></script>
				<script type="text/javascript">
					<xsl:for-each select="file">
						witnesses[<xsl:value-of select="position()-1"/>] = '<xsl:value-of select="@sigil" />';
						<xsl:value-of select="@sigil" /> = new Array();
					</xsl:for-each>
					<xsl:for-each select="file">
						<xsl:call-template name="figures">
							<xsl:with-param name="wit" select="@sigil" />
							<xsl:with-param name="thefile" select="@filename" />
						</xsl:call-template>
					</xsl:for-each>
				</script>
			</head>
			<body onLoad="discreteInit(); createManuscript();" onresize="resizeManuscripts();">
				<div style="visibility: hidden;" oncontextmenu="return false;" id="panel_imageviewer">
					<div title="Click to drag panel." id="handle_imageviewer">
						<span class="viewerlt" id="title_imageviewer">Image Viewer</span>
						<span class="viewerrt" title="Close this image" onclick="return hidePanel('imageviewer');">X</span>
					</div>
					<p id="content_imageviewer"></p>
				</div>
				<div style="visibility: hidden;" id="panel_noteviewer">
					<div title="Click to drag panel." id="handle_noteviewer">
						<span class="viewerlt" id="title_noteviewer">Note</span>
						<span class="viewerrt" title="Close this image" onclick="return hidePanel('noteviewer');">X</span>
					</div>
					<div id="content_noteviewer"></div>
				</div>
				<div id="masterControl" class="maincontrol">
					<div class="leftcontrol">
						<img src="../vm-images/poweredby.gif" id="poweredby"
						alt="Powered by Versioning Machine v3" onclick="callHome()" />
					</div>
					<div class="middlecontrol">
						<div class="textinfo">
							This text has <span class="count"><xsl:value-of select="count($witnumbers)" /></span> versions
						</div>
						<div class="buttons">
							<img onclick="createManuscript();" alt="Display New Version"
							title="Evoke a new version of the text in a new vertical pane"
							src="../vm-images/newversion.png" onmousedown="this.src='../vm-images/newversion_dn.png'"
							onmouseup="this.src='../vm-images/newversion.png'" />
							<img onclick="document.location.href='browseindex.html';"
							alt="Back to List of Texts" title="Return to the main index of texts"
							src="../vm-images/returnindex.png" onmousedown="this.src='../vm-images/returnindex_dn.png'"
							onmouseup="this.src='../vm-images/returnindex.png'" />
							<img onclick="showBiblio(event);" alt="Bibliographic Information"
							title="View bibliographic/colophon information" src="../vm-images/biblioinfo.png"
							onmousedown="this.src='../vm-images/biblioinfo_dn.png'"
							onmouseup="this.src='../vm-images/biblioinfo.png'" />
						</div>
						<div>
							Note Format&#160;&#160;<select name="notesoption" id="notesoption" onchange="notesFormat(this);">
								<option value="hide">Hide Notes</option>
								<option value="popup" selected="selected">Show Popup Notes</option>
							</select>
						</div>
					</div>
					<div class="rightcontrol">
						<div class="poweruser">Need help?</div>
						<div class="popup" onclick="showPanel(event,'imageandnote',0,0);">Image and Note Viewer</div>
						<div class="popup" onclick="showPanel(event,'versioncontrols',0,0);">Version Controls</div>
						<div class="popup" onclick="showPanel(event,'notedisplay',0,0);">Note Display</div>
					</div>
					<br style="clear: both;" />
				</div>
				<div id="panel_biblioarea" class="panel">
					<div title="Click to drag panel." id="handle_biblioarea" class="handle">
						<span class="viewerlt" id="title_biblioarea">Bibliographic Information</span>
						<span class="viewerrt" title="Close this note" onclick="hideBiblio();">X</span>
					</div>
					<div id="content_biblioarea" class="content">
						<xsl:for-each select="file">
							<xsl:apply-templates select="document(@filename)//teiHeader" mode="docInfo" />
						</xsl:for-each>
					</div>
				</div>
				<!-- BODY COMES HERE -->
				<div id="manuscriptarea">
					<div id="manuscript" class="manuscript">
						<div id="controlpanel" class="control">
							<span class="remove" onclick="removeManuscript(this);">X</span>
							Version # <!-- <span id="msID" style="display: none;"
							title="The manuscript version number">initializing</span> -->
							<select id="idlist" onchange="showWitness(this.parentNode.parentNode,
							this.selectedIndex);"><option>Test</option></select>
							<script type="text/javascript">
								function addwitnesstolist(num,witness) {
									var selectbox = document.getElementById("idlist");
									selectbox.options.length = <xsl:value-of select="$witlimit" />;
									selectbox.options[num - 1] = new Option(witness, witness);
								}
								<xsl:for-each select="file">
									addwitnesstolist(<xsl:value-of select='position()' />,"<xsl:value-of select='@sigil' />");
								</xsl:for-each>
							</script>
						</div>
						<div class="paper" id="manuscriptpaper">
							<xsl:for-each select="file">
								<xsl:apply-templates select="document(@filename)//body">
									<xsl:with-param name="version"><xsl:value-of select="@sigil"/></xsl:with-param>
								</xsl:apply-templates>
							</xsl:for-each>
						</div>
					</div>
				</div>
				<!-- Help popup notes -->
				<div id="panel_imageandnote" class="panel">
					<div title="Click to drag panel." id="handle_imageandnote" class="handle">
						<span class="viewerlt" id="title_imageandnote">About the Image and Note Viewer</span>
						<span class="viewerrt" title="Close this note" onclick="return hidePanel('imageandnote');">X</span>
					</div>
					<div id="content_imageandnote" class="content">
						<p>The image and note viewer may be dragged anywhere within
						the browser window. It is closed by clicking on the
						<strong>X</strong> button. Only one image and one popup
						note can be viewed at a time.</p>
						<p>Because of a limitation in the way the browser handles
						XSLT transformations, users of Firefox and other
						Mozilla-based browsers cannot view images within
						untransformed XML documents. In order to view manuscript
						images in Firefox, it is recommended that readers use HTML
						versions of the text. This restriction applies only to the
						image viewer: the note viewer work across all browsers.</p>
					</div>
				</div>
				<div id="panel_versioncontrols" class="panel">
					<div title="Click to drag panel." id="handle_versioncontrols" class="handle">
						<span class="viewerlt" id="title_versioncontrols">About Version Controls</span>
						<span class="viewerrt" title="Close this note" onclick="return hidePanel('versioncontrols');">X</span>
					</div>
					<div id="content_versioncontrols" class="content">
						<p>Each witness functions independently of each other. The
						first two witnesses are opened in the VM by default and
						displayed according to the order established by the
						editor/encoder. Users can open further witnesses through
						the <strong>Display New Version</strong> button. Witnesses
						can then be displayed in any order via the pull down menu.
						The <strong>X</strong> button removes the current version
						and resizes the remaining versions to maximize available
						space. All but one version can be removed.</p>
					</div>
				</div>
				<div id="panel_notedisplay" class="panel">
					<div title="Click to drag panel." id="handle_notedisplay" class="handle">
						<span class="viewerlt" id="title_notedisplay">About Note Display</span>
						<span class="viewerrt" title="Close this note" onclick="return hidePanel('notedisplay');">X</span>
					</div>
					<div id="content_notedisplay" class="content">
						<p>The <strong>Display Notes</strong> menu provides three
						choices for viewing notes when viewing texts encoded using
						the parallel segmentation method, and two when viewing texts
						encoded as discrete witnesses. In both cases, the default
						displays notes in a JavaScript popup whenever the reader
						clicks upon the footnote icons. When viewing parallel
						segmentation-encoded texts in Internet Explorer and
						Firefox, there is also the option to display all notes
						simultaneously within an inline panel. Lastly, there is
						an option to hide all notes.</p>
					</div>
				</div>
			</body>
		</html>
	</xsl:template>




<xsl:template match="teiHeader" mode="docInfo">
<hr />
<xsl:apply-templates select=".//fileDesc"/>
Original Source:
<xsl:apply-templates select=".//sourceDesc"/>
<xsl:if test="//notesStmt/note[@type='not(image)']">
<b>Textual Notes</b>:
<xsl:apply-templates select="//fileDesc/notesStmt"/>
</xsl:if>
<b>Electronic Edition Information</b>
<br/>
<br/>
<xsl:if test="//resp">
<xsl:for-each select="//resp">
<xsl:value-of select="."/>
<br/>
</xsl:for-each>
</xsl:if>
<xsl:if test=".//publicationStmt/publisher | .//publicationStmt/address | .//fileDesc/seriesStmt | .//availability | //fileDesc/publicationStmt/date">
<br/>
<xsl:apply-templates select=".//publicationStmt/publisher"/>
<xsl:apply-templates select=".//publicationStmt/address"/>
<xsl:apply-templates select=".//fileDesc/seriesStmt"/>
<xsl:apply-templates select=".//availability"/>
<xsl:if test="//fileDesc/publicationStmt/date">
<xsl:value-of select="//fileDesc/publicationStmt/date"/>
<br/>
<br/>
</xsl:if>
</xsl:if>
<xsl:if test="//encodingDesc/editorialDecl | //fileDesc/editionStmt | //encodingDesc/projectDesc">
<b>Encoding Principles</b><br/>
<xsl:apply-templates select="//encodingDesc/projectDesc"/>
<xsl:apply-templates select="//encodingDesc/editorialDecl"/>
<xsl:apply-templates select="//fileDesc/editionStmt"/>
</xsl:if>
</xsl:template>

<xsl:template match="fileDesc">
<h3>
<xsl:apply-templates select="./titleStmt/title"/>
</h3>
<h4>
<xsl:apply-templates select="./titleStmt/author"/>
</h4>
<h4>
<xsl:apply-templates select="./titleStmt/editor"/>
</h4>
<xsl:if test="//note[@type='head']">
<xsl:apply-templates select="//note[@type='head']"/>
</xsl:if>
</xsl:template>

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

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

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

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

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

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

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

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

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

<xsl:template match="notesStmt">
<xsl:for-each select="note">
<xsl:if test="not(@type='image')">
<xsl:if test="not(@type='head')">
<xsl:choose>
<xsl:when test="@type='witness-specific'">
<xsl:for-each select="witDetail">
<i><xsl:value-of select="@wit"/></i><xsl:if test="@type">-<xsl:value-of select="@type"/></xsl:if>:<xsl:apply-templates/>
<br/>
</xsl:for-each>
<br/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="@type"><xsl:value-of select="@type"/>:</xsl:if> <xsl:apply-templates/>
<br/>
<br/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
</xsl:for-each>
<br/>
<br/>
</xsl:template>

<!-- basic body template, creating areas for manuscript display and help info, and selecting encoding mode -->

<xsl:template match="body">
	<xsl:param name="version"/>
	<xsl:apply-templates select="div0">
	<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
	</xsl:apply-templates>
</xsl:template>

<xsl:template match="div0">
	<xsl:param name="version" />
	<xsl:for-each select="//figure">
		<xsl:call-template name="showImageMS">
			<xsl:with-param name="wit" select="@entity" />
			<xsl:with-param name="version">
				<xsl:value-of select="$version" />
			</xsl:with-param>
		</xsl:call-template>
	</xsl:for-each>
	<xsl:apply-templates>
		<xsl:with-param name="version">
			<xsl:value-of select="$version" />
		</xsl:with-param>
	</xsl:apply-templates>
</xsl:template>

<xsl:template match="div1|div2|div3|div4|div5|div6|div7|div">
	<xsl:param name="version"/>
<xsl:apply-templates>
	<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="l">
<xsl:param name="version"/>
<xsl:choose>
<xsl:when test="@rend='indent'">
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">line</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="indent">Y</xsl:with-param>
<xsl:with-param name="poem">Y</xsl:with-param>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">line</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="indent">N</xsl:with-param>
<xsl:with-param name="poem">Y</xsl:with-param>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template match="ab">
<xsl:param name="version"/>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">AB</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="body//p">
<xsl:param name="version"/>
<span>
<xsl:attribute name="id">stanza</xsl:attribute>
<xsl:attribute name="wit"><xsl:value-of select="$version"/></xsl:attribute>
<br/>
</span>
<xsl:choose>
<xsl:when test="@rend='indent'">
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">para</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="indent">Y</xsl:with-param>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">para</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="indent">N</xsl:with-param>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="seg">
<xsl:param name="version"/>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">seg</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="s">
<xsl:param name="version"/>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">sentence</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="word">
<xsl:param name="version"/>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">word</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="closer">
<xsl:param name="version"/>
<span>
<xsl:attribute name="id">stanza</xsl:attribute>
<xsl:attribute name="wit"><xsl:value-of select="$version"/></xsl:attribute>
<br/>
</span>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">closer</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="opener">
<xsl:param name="version"/>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">opener</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="epigraph">
<xsl:param name="version"/>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">epigraph</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="head">
<xsl:param name="version"/>
<xsl:call-template name="witParse">
<xsl:with-param name="texttype">head</xsl:with-param>
<xsl:with-param name="num" select="generate-id()"/>
<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template match="lg">
	<xsl:param name="version"/>
<span>
<xsl:attribute name="id">stanza</xsl:attribute>
<xsl:attribute name="wit"><xsl:value-of select="$version"/></xsl:attribute>
<br/>
</span>
<xsl:apply-templates>
	<xsl:with-param name="version"><xsl:value-of select="$version"/></xsl:with-param>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="div[@type='dedication']">
<xsl:param name="version"/>
<span>
<xsl:attribute name="id">stanza</xsl:attribute>
<xsl:attribute name="wit"><xsl:value-of select="$version"/></xsl:attribute>
<br/>
</span>
</xsl:template>

<!-- select out the text of each current witness and transform it -->

<xsl:template name="witParse">
<xsl:param name="texttype"/>
<xsl:param name="num"/>
<xsl:param name="indent"/>
<xsl:param name="poem"/>
<xsl:param name="current" select="1"/>
<xsl:param name="whichwitness"><xsl:value-of select="/files/file[position()=$current]/@sigil"/></xsl:param>
<xsl:param name="version"/>
<xsl:if test="$poem='Y'">
<br/>
</xsl:if>
<span>
<xsl:attribute name="wit"><xsl:value-of select="$version"/></xsl:attribute>
<xsl:call-template name="parsingWits">
<xsl:with-param name="currentwit" select="$whichwitness"/>
<xsl:with-param name="indent" select="$indent"/>
</xsl:call-template>

</span>


</xsl:template>

<xsl:template name="parsingWits">
<xsl:param name="currentwit"/>
<xsl:param name="indent"/>
<xsl:param name="style"/>
<xsl:for-each select="./node()">
<xsl:choose>
<xsl:when test="self::*">
<xsl:if test="$indent='Y'">
&#160;&#160;&#160;&#160;&#160;
</xsl:if>
<xsl:apply-templates select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="$indent='Y'">
&#160;&#160;&#160;&#160;&#160;
</xsl:if>
<xsl:text> </xsl:text> <xsl:value-of select="normalize-space(.)"/> <xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>


<!-- miscellaneous paragraph level elements, all default (when differing based on encoding method, see that mode) -->

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

<xsl:template match="hi">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <b><xsl:apply-templates/></b>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="emph">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <b><xsl:apply-templates/></b>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="soCalled">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   "<xsl:apply-templates/>"
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="p">
<xsl:param name="version"/>
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <p><xsl:apply-templates><xsl:with-param name="version" select="$version"/></xsl:apply-templates></p>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="title">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="author">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="name">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="foreign">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="mentioned">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="rs">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="term">
 <xsl:choose>
  <xsl:when test="@rend">
   <xsl:call-template name="render">
<xsl:with-param name="style" select="@rend"/>
</xsl:call-template>
  </xsl:when>
  <xsl:otherwise>
   <xsl:apply-templates/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

	<xsl:template match="q">
		<xsl:choose>
			<xsl:when test="@rend">
				<xsl:call-template name="render">
					<xsl:with-param name="style" select="@rend" />
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates />
			</xsl:otherwise>
		</xsl:choose>
		</xsl:template>

	<xsl:template match="lb">
		<br />
	</xsl:template>

	<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="pb">
		<xsl:param name="version" />
		<span>
			<xsl:attribute name="id">
				page<xsl:value-of select="@n" />
			</xsl:attribute>
			<xsl:attribute name="wit">
				<xsl:value-of select="$version" />
			</xsl:attribute>
			<span color="#999999">
				[begin page <xsl:value-of select="@n"/>]
			</span>
		</span>
	</xsl:template>


	<xsl:template match="note|witDetail">
		<span id="noteicon" class="noteicon">
			<xsl:attribute name="onClick">
				displayNote('note.<xsl:value-of select="generate-id()" />','<xsl:value-of select="@type" />',event, 'noteviewer','0','0');
			</xsl:attribute>
			<xsl:choose>
				<xsl:when test="@type='physical'">
					<span title="Physical object note">
						<xsl:attribute name="id">note<xsl:value-of
						select="generate-id()" /></xsl:attribute>
					</span>
				</xsl:when>
				<xsl:when test="@type='biographical'">
					<span title="Biographical note">
						<xsl:attribute name="id">note<xsl:value-of
						select="generate-id()" /></xsl:attribute>b
					</span>
				</xsl:when>
				<xsl:when test="@type='gloss'">
					<span title="Gloss/definition note">
						<xsl:attribute name="id">note<xsl:value-of
						select="generate-id()" /></xsl:attribute>g
					</span>
				</xsl:when>
				<xsl:when test="@type='critical'">
					<span title="Critical note">
						<xsl:attribute name="id">note<xsl:value-of
						select="generate-id()" /></xsl:attribute>c
					</span>
				</xsl:when>
				<xsl:when test="@type='contextual'">
					<span title="Contextual note">
						<xsl:attribute name="id">note<xsl:value-of
						select="generate-id()" /></xsl:attribute>c
					</span>
				</xsl:when>
				<xsl:otherwise>
					<span title="Generic note">
						<xsl:attribute name="id">note<xsl:value-of
						select="generate-id()" /></xsl:attribute>n
					</span>
				</xsl:otherwise>
			</xsl:choose>
		</span>
		<span class="notearea">
			<xsl:attribute name="id">note.<xsl:value-of select="generate-id()"/></xsl:attribute>
			<xsl:apply-templates />
		</span>
	</xsl:template>

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

	<xsl:template match="note[@type='head']">
		<xsl:apply-templates />
		<br />
		<br />
	</xsl:template>

	<xsl:template match="space">
		<xsl:choose>
			<xsl:when test="@dim='horizontal'">
				<xsl:call-template name="spacer">
					<xsl:with-param name="num" select="@n" />
					<xsl:with-param name="dimen">hor</xsl:with-param>
					<xsl:with-param name="starting">1</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="@dim='vertical'">
				<xsl:call-template name="spacer">
					<xsl:with-param name="num" select="@n" />
					<xsl:with-param name="dimen">vert</xsl:with-param>
					<xsl:with-param name="starting">1</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
		</xsl:choose>
		<xsl:apply-templates />
	</xsl:template>

	<xsl:template name="spacer">
		<xsl:param name="num" />
		<xsl:param name="dimen" />
		<xsl:param name="starting" />
		<xsl:if test="$starting&lt;=$num">
			<xsl:choose>
				<xsl:when test="$dimen='hor'"> &#160;</xsl:when>
				<xsl:when test="$dimen='vert'">
					<br />
				</xsl:when>
			</xsl:choose>
			<xsl:call-template name="spacer">
				<xsl:with-param name="num" select="$num" />
				<xsl:with-param name="dimen" select="$dimen" />
				<xsl:with-param name="starting" select="$starting + 1" />
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<xsl:template match="note/lg/l | witDetail/lg/l">
		<xsl:apply-templates />
		<br />
	</xsl:template>

	<xsl:template match="del">
		<xsl:choose>
			<xsl:when test="@rend='superscript'">
				<xsl:element name="del">
					<xsl:element name="sup">
						<xsl:choose>
							<xsl:when test="@rend">
								<xsl:call-template name="render">
									<xsl:with-param name="style" select="@rend" />
								</xsl:call-template>
							</xsl:when>
							<xsl:otherwise>
								<xsl:apply-templates />
							</xsl:otherwise>
						</xsl:choose>
					</xsl:element>
				</xsl:element>
			</xsl:when>
			<xsl:when test="@rend='subscript'">
				<xsl:element name="del">
					<xsl:element name="sub">
						<xsl:choose>
							<xsl:when test="@rend">
								<xsl:call-template name="render">
									<xsl:with-param name="style" select="@rend" />
								</xsl:call-template>
							</xsl:when>
							<xsl:otherwise>
								<xsl:apply-templates />
							</xsl:otherwise>
						</xsl:choose>
					</xsl:element>
				</xsl:element>
			</xsl:when>
			<xsl:when test="'del'">
				<xsl:element name="del">
					<xsl:choose>
						<xsl:when test="@rend">
							<xsl:call-template name="render">
								<xsl:with-param name="style" select="@rend" />
							</xsl:call-template>
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates />
						</xsl:otherwise>
					</xsl:choose>
				</xsl:element>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="add">
		<xsl:choose>
			<xsl:when test="@rend='superscript'">
				<xsl:element name="sup">
					<xsl:attribute name="class">add</xsl:attribute>
					<xsl:choose>
						<xsl:when test="@rend">
							<xsl:call-template name="render">
								<xsl:with-param name="style" select="@rend" />
							</xsl:call-template>
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates />
						</xsl:otherwise>
					</xsl:choose>
				</xsl:element>
			</xsl:when>
			<xsl:when test="@rend='subscript'">
				<xsl:element name="sub">
					<xsl:attribute name="class">add</xsl:attribute>
					<xsl:choose>
						<xsl:when test="@rend">
							<xsl:call-template name="render">
								<xsl:with-param name="style" select="@rend" />
							</xsl:call-template>
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates />
						</xsl:otherwise>
					</xsl:choose>
				</xsl:element>
			</xsl:when>
			<xsl:when test="'add'">
				<xsl:element name="span">
					<xsl:attribute name="class">add</xsl:attribute>
					<xsl:choose>
						<xsl:when test="@rend">
							<xsl:call-template name="render">
								<xsl:with-param name="style" select="@rend" />
							</xsl:call-template>
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates />
						</xsl:otherwise>
					</xsl:choose>
				</xsl:element>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="sic">
		<span class="sic">
			<xsl:choose>
				<xsl:when test="@rend">
					<xsl:call-template name="render">
						<xsl:with-param name="style" select="@rend" />
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates />
				</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>

	<xsl:template match="corr">
		<span class="corr">
			<xsl:choose>
				<xsl:when test="@rend">
					<xsl:call-template name="render">
						<xsl:with-param name="style" select="@rend" />
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates />
				</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>

	<xsl:template match="gap">
		<span class="gap">
			<xsl:choose>
				<xsl:when test="@rend">
					<xsl:call-template name="render">
						<xsl:with-param name="style" select="@rend" />
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates />
				</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>

	<xsl:template match="damage">
		<span class="damage">
			<xsl:choose>
				<xsl:when test="@rend">
					<xsl:call-template name="render">
						<xsl:with-param name="style" select="@rend" />
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates />
				</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>

	<xsl:template match="unclear">
		<span class="unclear">
			<xsl:choose>
				<xsl:when test="@rend">
					<xsl:call-template name="render">
						<xsl:with-param name="style" select="@rend" />
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates />
				</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>

	<xsl:template match="supplied">
		<span class="supplied">
			<xsl:choose>
				<xsl:when test="@rend">
					<xsl:call-template name="render">
						<xsl:with-param name="style" select="@rend" />
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates />
				</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>

	<xsl:template match="restore">
		<span class="restore">
			<xsl:choose>
				<xsl:when test="@rend">
					<xsl:call-template name="render">
						<xsl:with-param name="style" select="@rend" />
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates />
				</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>

	<xsl:template match="handShift">
		<span class="handShift">
			<xsl:choose>
				<xsl:when test="@rend">
					<xsl:call-template name="render">
						<xsl:with-param name="style" select="@rend" />
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates />
				</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>

	<xsl:template match="quote">
		<xsl:param name="version" />
		<xsl:apply-templates>
			<xsl:with-param name="version" select="$version" />
		</xsl:apply-templates>
	</xsl:template>

	<xsl:template match="milestone[@unit='stanza']">
		<br />
		<br />
	</xsl:template>

	<xsl:template name="showImageMS">
		<xsl:param name="wit" />
		<xsl:param name="version" />
		<span class="imageicon">
			<xsl:attribute name="wit">
				<xsl:value-of select="$version" />
			</xsl:attribute>
			<xsl:variable name="file">
				<xsl:call-template name="filenameClip">
					<xsl:with-param name="filestring" select="unparsed-entity-uri($wit)" />
				</xsl:call-template>
			</xsl:variable>
			<xsl:attribute name="onClick">return imageView(event, 'imageviewer','images/<xsl:value-of select="$file" />','0','0',window.location,'<xsl:value-of
			select="$wit" />');</xsl:attribute>
			<img src="../vm-images/view.gif" class="viewimages" alt="View Images" title="View associated image" />
		</span>
	</xsl:template>

	<xsl:template name="filenameClip">
		<xsl:param name="filestring" />
		<xsl:choose>
			<xsl:when test="contains($filestring,'/')">
				<xsl:call-template name="filenameClip">
					<xsl:with-param name="filestring" select="substring-after($filestring,'/')" />
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$filestring" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>

