<!-- EAD Cookbook Style 6   Version 0.9   19 January 2004 -->

<!--  This stylesheet generates a Table of Contents in an HTML table cell
along the left side of the screen. It is an update to eadcbs2.xsl designed
to work with EAD 2002.-->

<!--This stylesheet does not format the <dsc> portion of a finding aid.   Users
need to select another stylesheet for the dsc and reference that file
in the <xsl:inlcude> statement that appears at the end of this file.-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:strip-space elements="*"/>
	<!--xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/-->
	<!-- Creates the body of the finding aid.-->
	<xsl:include href="/Web/Inc/MainTemplate.xsl"/>
	
	<xsl:variable name="title">
		<xsl:value-of select="ead/eadheader/filedesc/titlestmt/titleproper"/>
		<xsl:text>  </xsl:text>
		<xsl:value-of select="ead/eadheader/filedesc/titlestmt/subtitle"/>
	</xsl:variable>
	
	<xsl:template name="head-meta">
		<link rel="stylesheet" type="text/css" href="/Web/CSS/Advanced.asp?section=collections"/>
		<style type="text/css">
/*
ul {
	margin: 0 0 0 20px;
	padding: 0;
}

#TableOfContents {
	 width: 20%;
	 float: left;
	 margin: 0;
	 padding: 0.5em;
}
#ContentData {
	 margin: 0 0 0 22%;
	 padding: 0;
}
*/
@media print {
	#ContentData {
		margin: 0;
	}
}
/*table {
	border: 1px solid yellow;
	empty-cells: show;
}
td {
	border: 1px dashed red;
	}
th {
	border: 1px solid blue;
	background-color: yellow;
	}*/
</style>
		<!--[if IE]>
		<style type="text/css">
#LibContent {
	padding-left: 0 !important;
}
#TableOfContents {
	 border: 1px solid green;
	 position: relative;
	 left: 90px
}
#ContentData {
	 border: 1px solid red;
	 width: 50%;
	 margin: 0;
}
</style>
		<![endif]-->

	</xsl:template>
	
	<xsl:template name="libpage">
		
		<!--xsl:call-template name="metadata"/-->
		
		<!--This part of the template creates a table for the finding aid with
		two columns. -->
		<!--body-->
		<div class="Aside dontPrintMe">
			<!--In the left column is the table of contents.  -->
			
			<xsl:call-template name="toc"/>
		</div>
		
		<!--The body of the finding aid is in the right column.  -->	
		<div id="ContentData">
		
			<!--This part of template inserts a logo and title
			at the top of the display.  Insert the proper path ro
			your image in place of yourlogo.gif.
			
			If you do not want to include an image, delete the center
			element and its contents.-->
			<!--center>
			<img src="http://reach.ucf.edu/~wdr/themes/pegasus/peg_bfwt.gif"></img>
			</center-->
			
			<xsl:apply-templates select="ead/eadheader"/>
								
			
			<!--To change the order of display, adjust the sequence of
			the following apply-template statements which invoke the various
			templates that populate the finding aid.  Multiple statements
			are included to handle the possibility that descgrp has been used
			as a wrapper to replace add and admininfo.  In several cases where
			multiple elemnents are displayed together in the output, a call-template
			statement is used-->	
			
			<xsl:apply-templates select="ead/archdesc/did"/>
			<xsl:apply-templates select="ead/archdesc/bioghist"/>
			<xsl:apply-templates select="ead/archdesc/scopecontent"/>
			<xsl:apply-templates select="ead/archdesc/arrangement"/>
			<xsl:call-template name="archdesc-restrict"/>
			<xsl:apply-templates select="ead/archdesc/controlaccess"/>
			<xsl:call-template name="archdesc-relatedmaterial"/>
			<xsl:apply-templates select="ead/archdesc/odd"/>
			<xsl:apply-templates select="ead/archdesc/originalsloc"/>
			<xsl:apply-templates select="ead/archdesc/phystech"/>
			<xsl:call-template name="archdesc-admininfo"/>
			<xsl:apply-templates select="ead/archdesc/otherfindaid | ead/archdesc/*/otherfindaid"/>
			<xsl:apply-templates select="ead/archdesc/fileplan | ead/archdesc/*/fileplan"/>
			<xsl:apply-templates select="ead/archdesc/bibliography | ead/archdesc/*/bibliography"/>
			<xsl:apply-templates select="ead/archdesc/index | ead/archdesc/*/index"/>
			<xsl:apply-templates select="ead/archdesc/dsc"/>
		</div>
	</xsl:template>
	
<!--This template creates HTML meta tags that are inserted into the HTML ouput
for use by web search engines indexing this file.   The content of each
resulting META tag uses Dublin Core semantics and is drawn from the text of
the finding aid.-->
	<xsl:template name="metadata">
		<meta http-equiv="Content-Type" name="dc.title"
		content="{eadheader/filedesc/titlestmt/titleproper&#x20; }{eadheader/filedesc/titlestmt/subtitle}"/>
		<meta http-equiv="Content-Type" name="dc.author" content="{archdesc/did/origination}"/>
		
		<xsl:for-each select="//controlaccess/persname | //controlaccess/corpname">
			<xsl:choose>
				<xsl:when test="@encodinganalog='600'">
				<meta http-equiv="Content-Type" name="dc.subject" content="{.}"/>
				</xsl:when>

				<xsl:when test="//@encodinganalog='610'">
					<meta http-equiv="Content-Type" name="dc.subject" content="{.}"/>
				</xsl:when>

				<xsl:when test="//@encodinganalog='611'">
					<meta http-equiv="Content-Type" name="dc.subject" content="{.}"/>
				</xsl:when>

				<xsl:when test="//@encodinganalog='700'">
					<meta http-equiv="Content-Type" name="dc.contributor" content="{.}"/>
				</xsl:when>

				<xsl:when test="//@encodinganalog='710'">
					<meta http-equiv="Content-Type" name="dc.contributor" content="{.}"/>
				</xsl:when>

				<xsl:otherwise>
					<meta http-equiv="Content-Type" name="dc.contributor" content="{.}"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
		<xsl:for-each select="//controlaccess/subject">
			<meta http-equiv="Content-Type" name="dc.subject" content="{.}"/>
		</xsl:for-each>
		<xsl:for-each select="//controlaccess/geogname">
			<meta http-equiv="Content-Type" name="dc.subject" content="{.}"/>
		</xsl:for-each>
		
		<meta http-equiv="Content-Type" name="dc.title" content="{archdesc/did/unittitle}"/>
		<meta http-equiv="Content-Type" name="dc.type" content="text"/>
		<meta http-equiv="Content-Type" name="dc.format" content="manuscripts"/>
		<meta http-equiv="Content-Type" name="dc.format" content="finding aids"/>
		
	</xsl:template>


	<!--This template creates the Table of Contents column for the finding aid.-->
	<xsl:template name="toc">

		<h4>Table of Contents</h4>
		<ul>
		<!-- The Table of Contents template performs a series of tests to
determine which elements will be included in the table
of contents.  Each if statement tests to see if there is
a matching element with content in the finding aid.-->
		<xsl:if test="string(ead/archdesc/did/head)">
			<li>
				<a href="#{generate-id(ead/archdesc/did/head)}">
					<xsl:value-of select="ead/archdesc/did/head"/>
				</a>
			</li>
		</xsl:if>
		<xsl:if test="string(ead/archdesc/bioghist/head)">
			<li>
				<a href="#{generate-id(ead/archdesc/bioghist/head)}">
					<xsl:value-of select="ead/archdesc/bioghist/head"/>
				</a>
			</li>
		</xsl:if>
		<xsl:if test="string(ead/archdesc/scopecontent/head)">
			<li>
				<a href="#{generate-id(ead/archdesc/scopecontent/head)}">
					<xsl:value-of select="ead/archdesc/scopecontent/head"/>
				</a>
			</li>
		</xsl:if>
		<xsl:if test="string(ead/archdesc/arrangement/head)">
			<li>
				<a href="#{generate-id(ead/archdesc/arrangement/head)}">
					<xsl:value-of select="ead/archdesc/arrangement/head"/>
				</a>
			</li>
		</xsl:if>
		
		<xsl:if test="string(ead/archdesc/userestrict/head)
		
		or string(ead/archdesc/*/userestrict/head)
		">
			<li>
				<a href="#restrictlink">
					<xsl:text>Restrictions</xsl:text>
				</a>
			</li>
		</xsl:if>
		<xsl:if test="string(ead/archdesc/controlaccess/head)">
			<li>
				<a href="#{generate-id(ead/archdesc/controlaccess/head)}">
					<xsl:value-of select="ead/archdesc/controlaccess/head"/>
				</a>
			</li>
		</xsl:if>
		<xsl:if test="string(ead/archdesc/relatedmaterial)
		or string(ead/archdesc/separatedmaterial)
		or string(ead/archdesc/*/relatedmaterial)
		or string(ead/archdesc/*/separatedmaterial)">
			<li>
				<a href="#relatedmatlink">
					<xsl:text>Related Material</xsl:text>
				</a>
			</li>
		</xsl:if>
		<xsl:if test="string(ead/archdesc/acqinfo/*)
		
		or string(ead/archdesc/prefercite/*)
		or string(ead/archdesc/custodialhist/*)
		or string(ead/archdesc/*/accessrestrict/*)
		or string(ead/archdesc/appraisal/*)
		or string(ead/archdesc/accruals/*)
		or string(ead/archdesc/*/acqinfo/*)
		or string(ead/archdesc/*/processinfo/*)
		or string(ead/archdesc/*/prefercite/*)
		or string(ead/archdesc/*/custodialhist/*)
		or string(ead/archdesc/*/processinfo/*)
		or string(ead/archdesc/*/appraisal/*)
		or string(ead/archdesc/accessrestrict/*)
		or string(ead/archdesc/*/accruals/*)">
			<li>
				<a href="#adminlink">
				<xsl:text>Administrative Information</xsl:text>
				</a>
			</li>
		</xsl:if>
		
		<xsl:if test="string(ead/archdesc/otherfindaid/head)
			or string(ead/archdesc/*/otherfindaid/head)">
			<li>
				<xsl:choose>
					<xsl:when test="ead/archdesc/otherfindaid/head">
						<a href="#{generate-id(ead/archdesc/otherfindaid/head)}">
							<xsl:value-of select="ead/archdesc/otherfindaid/head"/>
						</a>
					</xsl:when>
					<xsl:when test="ead/archdesc/*/otherfindaid/head">
						<a href="#{generate-id(ead/archdesc/*/otherfindaid/head)}">
							<xsl:value-of select="ead/archdesc/*/otherfindaid/head"/>
						</a>
					</xsl:when>
				</xsl:choose>
			</li>
		</xsl:if>
		
		<!--The next test covers the situation where there is more than one odd element
			in the document.-->
		<xsl:if test="string(ead/archdesc/odd/head)">
			<xsl:for-each select="ead/archdesc/odd">
				<li>
					<a href="#{generate-id(ead/head)}">
						<xsl:value-of select="ead/head"/>
					</a>
				</li>
			</xsl:for-each>
		</xsl:if>
		
		<xsl:if test="string(ead/archdesc/bibliography/head)
			or string(ead/archdesc/*/bibliography/head)">
			<li>
				<xsl:choose>
					<xsl:when test="ead/archdesc/bibliography/head">
						<a href="#{generate-id(ead/archdesc/bibliography/head)}">
							<xsl:value-of select="ead/archdesc/bibliography/head"/>
						</a>
					</xsl:when>
					<xsl:when test="ead/archdesc/*/bibliography/head">
						<a href="#{generate-id(ead/archdesc/*/bibliography/head)}">
							<xsl:value-of select="ead/archdesc/*/bibliography/head"/>
						</a>
					</xsl:when>
				</xsl:choose>
			</li>
		</xsl:if>
		
		<xsl:if test="string(ead/archdesc/index/head)
			or string(ead/archdesc/*/index/head)">
			<li>
				<xsl:choose>
					<xsl:when test="ead/archdesc/index/head">
						<a href="#{generate-id(ead/archdesc/index/head)}">
							<xsl:value-of select="ead/archdesc/index/head"/>
						</a>
					</xsl:when>
					<xsl:when test="ead/archdesc/*/index/head">
						<a href="#{generate-id(ead/archdesc/*/index/head)}">
							<xsl:value-of select="ead/archdesc/*/index/head"/>
						</a>
					</xsl:when>
				</xsl:choose>
			</li>
		</xsl:if>
		
		<xsl:if test="string(ead/archdesc/dsc/head)">
			<li>
				<a href="#{generate-id(ead/archdesc/dsc/head)}">
					<xsl:value-of select="ead/archdesc/dsc/head"/>
				</a>
				<!-- Displays the unittitle and unitdates for a c01 if it is a
				subgrp, subcollection,series or subseries (as
				evidenced by the value of @level) and numbers them
				to form a hyperlink to each.   Delete this section if you do not
				wish the c01 titles that are so identified
				to appear in the table of contents.-->
				<ul>
				<xsl:for-each select="ead/archdesc/dsc/c01[@level='series' or @level='subseries'
				or @level='subgrp' or @level='subcollection']">
					<li>
						<a>
							<xsl:attribute name="href">
								<xsl:text>#series</xsl:text>
								<xsl:number count="c01" from="dsc"/>
							</xsl:attribute>
		
							<xsl:choose>
								<xsl:when test="did/unittitle/unitdate">
									<xsl:for-each select="did/unittitle">
										<xsl:value-of select="text()"/>
										<xsl:text> </xsl:text>
										<xsl:apply-templates select="./unitdate"/>
									</xsl:for-each>
								</xsl:when>

								<xsl:otherwise>
									<xsl:apply-templates select="did/unittitle"/>
									<xsl:text> </xsl:text>
									<xsl:apply-templates select="did/unitdate"/>
								</xsl:otherwise>
							</xsl:choose>
						</a>
					</li>
				</xsl:for-each>
				</ul>
			</li>
			<!--This ends the section that causes the c01 titles to appear in the table of contents.-->
		</xsl:if>
		</ul>
		<!--End of the table of contents. -->
	</xsl:template>
	
	<!-- The following general templates format the display of various RENDER
	 attributes.-->
	<xsl:template match="emph[@render='bold']">
		<b>
			<xsl:apply-templates/>
		</b>
	</xsl:template>
	<xsl:template match="emph[@render='italic']">
		<i>
			<xsl:apply-templates/>
		</i>
	</xsl:template>
	<xsl:template match="emph[@render='underline']">
		<u>
			<xsl:apply-templates/>
		</u>
	</xsl:template>
	<xsl:template match="emph[@render='sub']">
		<sub>
			<xsl:apply-templates/>
		</sub>
	</xsl:template>
	<xsl:template match="emph[@render='super']">
		<super>
			<xsl:apply-templates/>
		</super>
	</xsl:template>
	
	<xsl:template match="emph[@render='quoted']">
		<xsl:text>"</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>"</xsl:text>
	</xsl:template>
	
	<xsl:template match="emph[@render='doublequote']">
		<xsl:text>"</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>"</xsl:text>
	</xsl:template>
	<xsl:template match="emph[@render='singlequote']">
		<xsl:text>'</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>'</xsl:text>
	</xsl:template>
	<xsl:template match="emph[@render='bolddoublequote']">
		<b>
			<xsl:text>"</xsl:text>
			<xsl:apply-templates/>
			<xsl:text>"</xsl:text>
		</b>
	</xsl:template>
	<xsl:template match="emph[@render='boldsinglequote']">
		<b>
			<xsl:text>'</xsl:text>
			<xsl:apply-templates/>
			<xsl:text>'</xsl:text>
		</b>
	</xsl:template>
	<xsl:template match="emph[@render='boldunderline']">
		<b>
			<u>
				<xsl:apply-templates/>
			</u>
		</b>
	</xsl:template>
	<xsl:template match="emph[@render='bolditalic']">
		<b>
			<i>
				<xsl:apply-templates/>
			</i>
		</b>
	</xsl:template>
	<xsl:template match="emph[@render='boldsmcaps']">
		<span style="font-variant: small-caps">
			<b>
				<xsl:apply-templates/>
			</b>
		</span>
	</xsl:template>
	<xsl:template match="emph[@render='smcaps']">
		<span style="font-variant: small-caps">
			<xsl:apply-templates/>
		</span>
	</xsl:template>
	<xsl:template match="title[@render='bold']">
		<b>
			<xsl:apply-templates/>
		</b>
	</xsl:template>
	<xsl:template match="title[@render='italic']">
		<i>
			<xsl:apply-templates/>
		</i>
	</xsl:template>
	<xsl:template match="title[@render='underline']">
		<u>
			<xsl:apply-templates/>
		</u>
	</xsl:template>
	<xsl:template match="title[@render='sub']">
		<sub>
			<xsl:apply-templates/>
		</sub>
	</xsl:template>
	<xsl:template match="title[@render='super']">
		<super>
			<xsl:apply-templates/>
		</super>
	</xsl:template>

	<xsl:template match="title[@render='quoted']">
		<xsl:text>"</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>"</xsl:text>
	</xsl:template>

	<xsl:template match="title[@render='doublequote']">
		<xsl:text>"</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>"</xsl:text>
	</xsl:template>
	
	<xsl:template match="title[@render='singlequote']">
		<xsl:text>'</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>'</xsl:text>
	</xsl:template>
	<xsl:template match="title[@render='bolddoublequote']">
		<b>
			<xsl:text>"</xsl:text>
			<xsl:apply-templates/>
			<xsl:text>"</xsl:text>
		</b>
	</xsl:template>
	<xsl:template match="title[@render='boldsinglequote']">
		<b>
			<xsl:text>'</xsl:text>
			<xsl:apply-templates/>
			<xsl:text>'</xsl:text>
		</b>
	</xsl:template>

	<xsl:template match="title[@render='boldunderline']">
		<b>
			<u>
				<xsl:apply-templates/>
			</u>
		</b>
	</xsl:template>
	<xsl:template match="title[@render='bolditalic']">
		<b>
			<i>
				<xsl:apply-templates/>
			</i>
		</b>
	</xsl:template>
	<xsl:template match="title[@render='boldsmcaps']">
		<font style="font-variant: small-caps">
			<b>
				<xsl:apply-templates/>
			</b>
		</font>
	</xsl:template>
	<xsl:template match="title[@render='smcaps']">
		<font style="font-variant: small-caps">
			<xsl:apply-templates/>
		</font>
	</xsl:template>
	<!-- This template converts a Ref element into an HTML anchor.-->
	<xsl:template match="ref">
		<a href="#{@target}">
			<xsl:apply-templates/>
		</a>
	</xsl:template>
	
	<!--This template rule formats a list element anywhere
	except in arrangement.-->
	<xsl:template match="list[parent::*[not(self::arrangement)]]/head">
		<div style="margin-left: 1em">
			<b>
				<xsl:apply-templates/>
			</b>
		</div>
	</xsl:template>
		
	<xsl:template match="list[parent::*[not(self::arrangement)]]/item">
			<div style="margin-left: 40pt">
				<xsl:apply-templates/>
			</div>
	</xsl:template>

<!--This template allows you to insert html links to other web pages.-->

<xsl:template match="extref[@show='new']">
<a href="{@href}">
<xsl:apply-templates/>
</a>
</xsl:template>

	
	<!--Formats a simple table. The width of each column is defined by the colwidth attribute in a colspec element.-->
	<xsl:template match="table">
		<table width="75%" style="margin-left: 1em">
			<tr>
				<td colspan="3">
					<h4>
						<xsl:apply-templates select="head"/>
					</h4>
				</td>
			</tr>
			<xsl:for-each select="tgroup">
				<tr>
					<xsl:for-each select="colspec">
						<td width="{@colwidth}"></td>
					</xsl:for-each>
				</tr>
				<xsl:for-each select="thead">
					<xsl:for-each select="row">
						<tr>
							<xsl:for-each select="entry">
								<td valign="top">
									<b>
										<xsl:apply-templates/>
									</b>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</xsl:for-each>

				<xsl:for-each select="tbody">
					<xsl:for-each select="row">
						<tr>
							<xsl:for-each select="entry">
								<td valign="top">
									<xsl:apply-templates/>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</xsl:for-each>
			</xsl:for-each>
		</table>
	</xsl:template>

	<!--This template rule formats a chronlist element.-->
	<xsl:template match="chronlist">
		<table width="100%" style="margin-left:1em">
			<tr>
				<td width="5%"> </td>
				<td width="15%"> </td>
				<td width="80%"> </td>
			</tr>
			<xsl:apply-templates/>
		</table>
	</xsl:template>
	
	<xsl:template match="chronlist/head">
		<tr>
			<td colspan="3">
				<h4>
					<xsl:apply-templates/>			
				</h4>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="chronlist/listhead">
		<tr>
			<td> </td>
			<td>
				<b>
					<xsl:apply-templates select="head01"/>
				</b>
			</td>
			<td>
				<b>
					<xsl:apply-templates select="head02"/>
				</b>
			</td>
		</tr>
	</xsl:template>

	<xsl:template match="chronitem">
		<!--Determine if there are event groups.-->
		<xsl:choose>
			<xsl:when test="eventgrp">
				<!--Put the date and first event on the first line.-->
				<tr>
					<td> </td>
					<td valign="top">
						<xsl:apply-templates select="date"/>
					</td>
					<td valign="top">
						<xsl:apply-templates select="eventgrp/event[position()=1]"/>
					</td>
				</tr>
				<!--Put each successive event on another line.-->
				<xsl:for-each select="eventgrp/event[not(position()=1)]">
					<tr>
						<td> </td>
						<td> </td>
						<td valign="top">
							<xsl:apply-templates select="."/>
						</td>
					</tr>
				</xsl:for-each>
			</xsl:when>
			<!--Put the date and event on a single line.-->
			<xsl:otherwise>
				<tr>
					<td> </td>
					<td valign="top">
						<xsl:apply-templates select="date"/>
					</td>
					<td valign="top">
						<xsl:apply-templates select="event"/>
					</td>
				</tr>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<!--Suppreses all other elements of eadheader.-->
	<xsl:template match="eadheader">
	<h1>
		<a name="{generate-id(titlestmt/titleproper)}"></a>
		<xsl:value-of select="filedesc/titlestmt/titleproper"/>
	</h1>
	<xsl:if test="filedesc/titlestmt/subtitle">
		<h2><xsl:value-of select="filedesc/titlestmt/subtitle"/></h2>
	</xsl:if>
	</xsl:template>

<!--This template creates a table for the did, inserts the head and then
each of the other did elements.  To change the order of appearance of these
elements, change the sequence of the apply-templates statements.-->
	<xsl:template match= "ead/archdesc/did">
		<h3>
			<a name="{generate-id(head)}"></a>
			<xsl:apply-templates select="head"/>
		</h3>
		<table class="DataTable">
			<!--tr>
				<td width="25%"> </td>
				<td width="75%"> </td>
			</tr>
			<tr>
				<td colspan="2">
				</td>
			</tr-->	

	<!--One can change the order of appearance for the children of did
				by changing the order of the following statements.-->	
			<xsl:apply-templates select="origination"/>	
			<xsl:apply-templates select="unittitle"/>	
			<xsl:apply-templates select="unitdate"/>		
			<xsl:apply-templates select="physdesc"/>	
			<xsl:apply-templates select="abstract"/>	
			<xsl:apply-templates select="langmaterial"/>
			<xsl:apply-templates select="unitid"/>	
			<xsl:apply-templates select="physloc"/>
			<xsl:apply-templates select="repository"/>			
			<xsl:apply-templates select="materialspec"/>
			<xsl:apply-templates select="note"/>
		</table>
	</xsl:template>
	


	<!--This template formats the repostory, origination, physdesc, abstract,
	unitid, physloc and materialspec elements of archdesc/did which share a common presentaiton.
	The sequence of their appearance is governed by the previous template.-->
	<xsl:template match="ead/archdesc/did/repository
	| ead/archdesc/did/origination
	| ead/archdesc/did/physdesc
	| ead/archdesc/did/unitid
	| ead/archdesc/did/physloc
	| ead/archdesc/did/abstract
	| ead/archdesc/did/langmaterial
	| ead/archdesc/did/materialspec">
		<!--The template tests to see if there is a label attribute,
		inserting the contents if there is or adding display textif there isn't.
		The content of the supplied label depends on the element.  To change the
		supplied label, simply alter the template below.-->
		<xsl:choose>
			<xsl:when test="@label">
				<tr>
				
					<td valign="top" style="white-space: nowrap;">
						<b>
							<xsl:value-of select="@label"/>
						</b>
					</td>
					<td>
						<xsl:apply-templates/>
					</td>
				</tr>
			</xsl:when>
			<xsl:otherwise>
				<tr>
					<td valign="top">
						<b>
							<xsl:choose>
								<xsl:when test="self::repository">
									<xsl:text>Repository: </xsl:text>
								</xsl:when>
								<xsl:when test="self::origination">
									<xsl:text>Creator: </xsl:text>
								</xsl:when>
								<xsl:when test="self::physdesc">
									<xsl:text>Quantity: </xsl:text>
								</xsl:when>
								<xsl:when test="self::physloc">
									<xsl:text>Location: </xsl:text>
								</xsl:when>
								<xsl:when test="self::unitid">
									<xsl:text>Identification: </xsl:text>
								</xsl:when>
								<xsl:when test="self::abstract">
									<xsl:text>Abstract:</xsl:text>
								</xsl:when>
								<xsl:when test="self::langmaterial">
									<xsl:text>Language: </xsl:text>
								</xsl:when>
								<xsl:when test="self::materialspec">
									<xsl:text>Technical: </xsl:text>
								</xsl:when>
							</xsl:choose>
						</b>
					</td>
					<td>
						<xsl:apply-templates/>
					</td>
				</tr>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	

	<!-- The following two templates test for and processes various permutations
of unittitle and unitdate.-->
	<xsl:template match= "ead/archdesc/did/unittitle">
		<!--The template tests to see if there is a label attribute for unittitle,
inserting the contents if there is or adding one if there isn't. -->
		<xsl:choose>
			<xsl:when test="@label">
				<tr>
					
					<td valign="top">
						<b>
							<xsl:value-of select="@label"/>
						</b>
					</td>
					<td>
						<!--Inserts the text of unittitle and any children other that unitdate.-->	
						<xsl:apply-templates select="text() |* [not(self::unitdate)]"/>
					</td>
				</tr>
			</xsl:when>
		
			<xsl:otherwise>
				<tr>
					
					<td valign="top">
						<b>
							<xsl:text>Title: </xsl:text>
						</b>
					</td>
					<td>
						<xsl:apply-templates select="text() |* [not(self::unitdate)]"/>
					</td>
				</tr>
			</xsl:otherwise>
		</xsl:choose>
		<!--If unitdate is a child of unittitle, it inserts unitdate on a new line.  -->
		<xsl:if test="child::unitdate">
			<!--The template tests to see if there is a label attribute for unittitle,
			inserting the contents if there is or adding one if there isn't. -->
			<xsl:choose>
				<xsl:when test="unitdate/@label">
					<tr>
						
						<td valign="top">
							<b>
								<xsl:value-of select="unitdate/@label"/>
							</b>
						</td>
						<td>
							<xsl:apply-templates select="unitdate"/>
						</td>
					</tr>
				</xsl:when>
	
				<xsl:otherwise>
					<tr>
						
						<td valign="top">
							<b>
								<xsl:text>Dates: </xsl:text>
							</b>
						</td>
						<td>
							<xsl:apply-templates select="unitdate"/>
						</td>
					</tr>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
	<!-- Processes the unit date if it is not a child of unit title but a child of did, the current context.-->
	<xsl:template match= "ead/archdesc/did/unitdate">

		<!--The template tests to see if there is a label attribute for a unittitle that is the
	child of did and not unittitle, inserting the contents if there is or adding one if there isn't.-->
		<xsl:choose>
			<xsl:when test="@label">
				<tr>
					
					<td valign="top">
						<b>
							<xsl:value-of select="@label"/>
						</b>
					</td>
					<td>
						<xsl:apply-templates/>
					</td>
				</tr>
			</xsl:when>
		
			<xsl:otherwise>
				<tr>
				
					<td valign="top">
						<b>
							<xsl:text>Dates: </xsl:text>
						</b>
					</td>
					<td>
						<xsl:apply-templates/>
					</td>
				</tr>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	


	<!--This template processes the note element.-->
	<xsl:template match= "ead/archdesc/did/note">
		<xsl:for-each select="p">
			<!--The template tests to see if there is a label attribute,
inserting the contents if there is or adding one if there isn't. -->
			<xsl:choose>
				<xsl:when test="parent::note[@label]">
					<!--This nested choose tests for and processes the first paragraph. Additional paragraphs do not get a label.-->
					<xsl:choose>
						<xsl:when test="position()=1">
							<tr>
							
								<td valign="top">
									<b>
										<xsl:value-of select="@label"/>
									</b>
								</td>
								<td valign="top">
									<xsl:apply-templates/>
								</td>
							</tr>
						</xsl:when>

						<xsl:otherwise>
							<tr>
								
								<td valign="top"></td>
								<td valign="top">
									<xsl:apply-templates/>
								</td>
							</tr>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<!--Processes situations where there is no
					label attribute by supplying default text.-->
				<xsl:otherwise>
					<!--This nested choose tests for and processes the first paragraph. Additional paragraphs do not get a label.-->
					<xsl:choose>
						<xsl:when test="position()=1">
							<tr>
								
								<td valign="top">
									<b>
										<xsl:text>Note: </xsl:text>
									</b>
								</td>
								<td>
									<xsl:apply-templates/>
								</td>
							</tr>
						</xsl:when>
		
						<xsl:otherwise>
							<tr>
								<td valign="top"></td>
								<td>
									<xsl:apply-templates/>
								</td>
							</tr>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:otherwise>
			</xsl:choose>
			<!--Closes each paragraph-->
		</xsl:for-each>
	</xsl:template>

	<!--This template rule formats the top-level bioghist element and
		creates a link back to the top of the page after the display of the element.-->
	<xsl:template match="ead/archdesc/bioghist |
			archdesc/scopecontent |
			archdesc/phystech |
			archdesc/odd   |
			archdesc/arrangement">
		<xsl:if test="string(child::*)">	
			<xsl:apply-templates/>
			<p class="TopLink dontPrintMe">
				<a href="#">Return to the Table of Contents</a>
			</p>
		</xsl:if>
	</xsl:template>
	
	<!--This template formats various head elements and makes them targets for
		links from the Table of Contents.-->
	<xsl:template match="ead/archdesc/bioghist/head  |
			archdesc/scopecontent/head |
			archdesc/arrangement/head |
			archdesc/phystech/head |
			archdesc/controlaccess/head |
			archdesc/odd/head">
		<h3>
			<a name="{generate-id()}"></a>
			<xsl:apply-templates/>
		</h3>
	</xsl:template>

	<xsl:template match="ead/archdesc/bioghist/p |
			archdesc/scopecontent/p |
			archdesc/arrangement/p |
			archdesc/phystech/p |
			archdesc/controlaccess/p |
			archdesc/odd/p |
			archdesc/bioghist/note/p |
			archdesc/scopecontent/note/p |
			archdesc/arrangement/note/p |
			archdesc/phystech/note/p |
			archdesc/controlaccess/note/p |
			archdesc/odd/note/p">
		<p style="margin-left:1em">
			<xsl:apply-templates/>
		</p>
	</xsl:template>
	
	<xsl:template match="ead/archdesc/bioghist/bioghist/head |
		archdesc/scopecontent/scopecontent/head">
		<h3 style="margin-left:1em">
			<xsl:apply-templates/>
		</h3>
	</xsl:template>
	
	<xsl:template match="ead/archdesc/bioghist/bioghist/p |
		archdesc/scopecontent/scopecontent/p |
		archdesc/bioghist/bioghist/note/p |
		archdesc/scopecontent/scopecontent/note/p">
		<p style="margin-left: 2em">
			<xsl:apply-templates/>
		</p>
	</xsl:template>
	
	<!-- The next two templates format an arrangement
	statement embedded in <scopecontent>.-->
		
	<xsl:template match="ead/archdesc/scopecontent/arrangement/head">
		<h4 style="margin-left:1em">
			<a name="{generate-id(head)}"></a>
			<xsl:apply-templates/>
		</h4>
	</xsl:template>
	
		
	<xsl:template match="ead/archdesc/scopecontent/arrangement/p
	| ead/archdesc/scopecontent/arrangement/note/p">
		<p style="margin-left:2em">
			<xsl:apply-templates/>
		</p>
	</xsl:template>
	
	<!-- The next three templates format a list within an arrangement
	statement whether it is directly within <archdesc> or embedded in
	<scopecontent>.-->
	
	<xsl:template match="ead/archdesc/scopecontent/arrangement/list/head">
		<div style="margin-left:1em">
			<a name="{generate-id(head)}"></a>
			<xsl:apply-templates/>
		</div>
	</xsl:template>
	
	<xsl:template match="ead/archdesc/arrangement/list/head">
		<div style="margin-left:1em">
			<a name="{generate-id()}"></a>
			<xsl:apply-templates/>
		</div>
	</xsl:template>
	
	<xsl:template match="ead/archdesc/scopecontent/arrangement/list/item
	| ead/archdesc/arrangement/list/item">
		<div style="margin-left:2em">
			<a>
				<xsl:attribute name="href">#series<xsl:number/>
				</xsl:attribute>
				<xsl:apply-templates/>
			</a>
		</div>
	</xsl:template>
	
	<!--This template rule formats the top-level related material
	elements by combining any related or separated materials
	elements. It begins by testing to see if there related or separated
	materials elements with content.-->
	<xsl:template name="archdesc-relatedmaterial">
		<xsl:if test="string(ead/archdesc/relatedmaterial) or
		string(ead/archdesc/*/relatedmaterial) or
		string(ead/archdesc/separatedmaterial) or
		string(ead/archdesc/*/separatedmaterial)">
			<h3>
				<a name="relatedmatlink"></a>
				<xsl:text>Related Material</xsl:text>
			</h3>
			<xsl:apply-templates select="ead/archdesc/relatedmaterial/p
				| ead/archdesc/*/relatedmaterial/p
				| ead/archdesc/relatedmaterial/note/p
				| ead/archdesc/*/relatedmaterial/note/p"/>
			<xsl:apply-templates select="ead/archdesc/separatedmaterial/p
				| ead/archdesc/*/separatedmaterial/p
				| ead/archdesc/separatedmaterial/note/p
				| ead/archdesc/*/separatedmaterial/note/p"/>
			<p class="TopLink dontPrintMe">
				<a href="#">Return to the Table of Contents</a>
			</p>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="ead/archdesc/relatedmaterial/p
		| ead/archdesc/*/relatedmaterial/p
		| ead/archdesc/separatedmaterial/p
		| ead/archdesc/*/separatedmaterial/p
		| ead/archdesc/relatedmaterial/note/p
		| ead/archdesc/*/relatedmaterial/note/p
		| ead/archdesc/separatedmaterial/note/p
		| ead/archdesc/*/separatedmaterial/note/p">
		<p style="margin-left: 1em">
			<xsl:apply-templates/>
		</p>
	</xsl:template>
	
	<!--This template formats the top-level controlaccess element.
	It begins by testing to see if there is any controlled
	access element with content. It then invokes one of two templates
	for the children of controlaccess.  -->
	<xsl:template match="ead/archdesc/controlaccess">
		<xsl:if test="string(child::*)">
			<a name="{generate-id(head)}"></a>
			<xsl:apply-templates select="head"/>
			<p style="text-indent:1em">
				<xsl:apply-templates select="p | note/p"/>
			</p>	
			<xsl:choose>
				<!--Apply this template when there are recursive controlaccess
				elements.-->
				<xsl:when test="controlaccess">
					<xsl:apply-templates mode="recursive" select="."/>
				</xsl:when>
				<!--Apply this template when the controlled terms are entered
				directly under the controlaccess element.-->
				<xsl:otherwise>
					<xsl:apply-templates mode="direct" select="."/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
		
	<!--This template formats controlled terms that are entered
	directly under the controlaccess element.  Elements are alphabetized.-->
	<xsl:template mode="direct" match="ead/archdesc/controlaccess">
		<xsl:for-each select="subject |corpname | famname | persname | genreform | title | geogname | occupation">
			<xsl:sort select="." data-type="text" order="ascending"/>
			<div style="margin-left:2em">
				<xsl:apply-templates/>
			</div>
		</xsl:for-each>
		<p class="TopLink dontPrintMe">	
			<a href="#">
				Return to the Table of Contents
			</a>
		</p>
	</xsl:template>
	
	<!--When controlled terms are nested within recursive
	controlaccess elements, the template for controlaccess/controlaccess
	is applied.-->
	<xsl:template mode="recursive" match="ead/archdesc/controlaccess">
			<xsl:apply-templates select="controlaccess"/>
		<p class="TopLink dontPrintMe">
			<a href="#">
				Return to the Table of Contents
			</a>
		</p>
	</xsl:template>

	<!--This template formats controlled terms that are nested within recursive
	controlaccess elements.   Terms are alphabetized within each grouping.-->
	<xsl:template match="ead/archdesc/controlaccess/controlaccess">
		<h4 style="margin-left:1em">
			<xsl:apply-templates select="head"/>
		</h4>
		<xsl:for-each select="subject |corpname | famname | persname | genreform | title | geogname | occupation">
			<xsl:sort select="." data-type="text" order="ascending"/>
			<div style="margin-left:2em">
				<xsl:apply-templates/>
			</div>
		</xsl:for-each>
	</xsl:template>

	<!--This template rule formats a top-level access and use retriction elements.
	They are displayed under a common heading.
	It begins by testing to see if there are any restriction elements with content.--><xsl:template name="archdesc-restrict">
		<xsl:if test="string(ead/archdesc/userestrict/*)
		
		or string(ead/archdesc/*/userestrict/*)
		">
			<h3>
				<a name="restrictlink"></a>
				<xsl:text>Restrictions</xsl:text>
			</h3>
			<xsl:apply-templates select="ead/archdesc/userestrict
				| ead/archdesc/*/userestrict"/>
			<p class="TopLink dontPrintMe">
				<a href="#">Return to the Table of Contents</a>
			</p>
		</xsl:if>
	</xsl:template>

	<xsl:template match="ead/archdesc/userestrict/head
	
	| ead/archdesc/*/userestrict/head">
		<h4 style="margin-left: 1em">
			<xsl:apply-templates/>
		</h4>
	</xsl:template>

	<xsl:template match="ead/archdesc/userestrict/p
	
	| ead/archdesc/*/userestrict/p
	
	| ead/archdesc/userestrict/note/p
	
	| ead/archdesc/*/userestrict/note/p">
		<p style="margin-left:2em">
			<xsl:apply-templates/>
		</p>
	</xsl:template>

	
	<!--This templates consolidates all the other administrative information
	 elements into one block under a common heading.  It formats these elements
	 regardless of which of three encodings has been utilized.  They may be
	 children of archdesc, admininfo, or descgrp.
	 It begins by testing to see if there are any elements of this type
	 with content.-->
	 
	<xsl:template name="archdesc-admininfo">
		<xsl:if test="string(ead/archdesc/admininfo/custodhist/*)
		or string(ead/archdesc/altformavail/*)
		or string(ead/archdesc/prefercite/*)
		or string(ead/archdesc/acqinfo/*)
		or string(ead/archdesc/accessrestrict/*)
		or string(ead/archdesc/*/accessrestrict/*)		
		or string(ead/archdesc/appraisal/*)
		or string(ead/archdesc/accruals/*)
		or string(ead/archdesc/*/custodhist/*)
		or string(ead/archdesc/*/altformavail/*)
		or string(ead/archdesc/*/prefercite/*)
		or string(ead/archdesc/*/acqinfo/*)
		or string(ead/archdesc/*/processinfo/*)
		or string(ead/archdesc/*/appraisal/*)
		or string(ead/archdesc/*/accruals/*)or string(archdesc/userestrict/*)
		or string(ead/archdesc/*/userestrict/*)		
		">
			<h3>
				<a name="adminlink"></a>
				<xsl:text>Administrative Information</xsl:text>
			</h3>
			<xsl:apply-templates select="ead/archdesc/custodhist
				| ead/archdesc/*/custodhist"/>
			<xsl:apply-templates select="ead/archdesc/altformavail
				| ead/archdesc/*/altformavail"/>
			<xsl:apply-templates select="ead/archdesc/prefercite
				| ead/archdesc/*/prefercite"/>
			<xsl:apply-templates select="ead/archdesc/acqinfo
				| ead/archdesc/*/acqinfo"/>
			<xsl:apply-templates select="ead/archdesc/accessrestrict
				| ead/archdesc/*/accessrestrict"/>
			<xsl:apply-templates select="ead/archdesc/admininfo/appraisal
				| ead/archdesc/*/appraisal"/>
			<xsl:apply-templates select="ead/archdesc/admininfo/accruals
				| ead/archdesc/*/accruals"/>
			<p class="TopLink dontPrintMe">
				<a href="#">Return to the Table of Contents</a>
			</p>
		</xsl:if>
	</xsl:template>
	

	<!--This template rule formats the head element of top-level elements of
	administrative information.-->
		<xsl:template match="custodhist/head
		| ead/archdesc/altformavail/head
		| ead/archdesc/prefercite/head
		| ead/archdesc/acqinfo/head
		| ead/archdesc/accessrestrict/head
		| ead/archdesc/processinfo/head
		| ead/archdesc/appraisal/head
		| ead/archdesc/accruals/head
		| ead/archdesc/*/custodhist/head
		| ead/archdesc/*/altformavail/head
		| ead/archdesc/*/prefercite/head
		| ead/archdesc/*/acqinfo/head
		| ead/archdesc/*/processinfo/head
		| ead/archdesc/*/appraisal/head
		| ead/archdesc/*/accessrestrict/head
		| ead/archdesc/*/accruals/head">
		<h4 style="margin-left:1em">
			<a name="{generate-id()}"></a>
			<xsl:apply-templates/>
		</h4>
	</xsl:template>	
		
	<xsl:template match="custodhist/p
		| ead/archdesc/altformavail/p
		| ead/archdesc/prefercite/p
		| ead/archdesc/acqinfo/p
		| ead/archdesc/processinfo/p
		| ead/archdesc/accessrestrict/p
		| ead/archdesc/*/accessrestrict/p
		| ead/archdesc/accessrestrict/note/p
		| ead/archdesc/*/accessrestrict/note/p
		| ead/archdesc/appraisal/p
		| ead/archdesc/accruals/p
		| ead/archdesc/*/custodhist/p
		| ead/archdesc/*/altformavail/p
		| ead/archdesc/*/prefercite/p
		| ead/archdesc/*/acqinfo/p
		| ead/archdesc/*/processinfo/p
		| ead/archdesc/*/appraisal/p
		| ead/archdesc/*/accruals/p
		| ead/archdesc/custodhist/note/p
		| ead/archdesc/altformavail/note/p
		| ead/archdesc/prefercite/note/p
		| ead/archdesc/acqinfo/note/p
		| ead/archdesc/processinfo/note/p
		| ead/archdesc/appraisal/note/p
		| ead/archdesc/accruals/note/p
		| ead/archdesc/*/custodhist/note/p
		| ead/archdesc/*/altformavail/note/p
		| ead/archdesc/*/prefercite/note/p
		| ead/archdesc/*/acqinfo/note/p
		| ead/archdesc/*/processinfo/note/p
		| ead/archdesc/*/appraisal/note/p
		| ead/archdesc/*/accruals/note/p">
		
		<p style="margin-left:2em;">
			<xsl:apply-templates/>
		</p>
	</xsl:template>
		
	<xsl:template match="ead/archdesc/otherfindaid
		| ead/archdesc/*/otherfindaid
		| ead/archdesc/bibliography
		| ead/archdesc/*/bibliography
		| ead/archdesc/originalsloc
		| ead/archdesc/phystech">
			<xsl:apply-templates/>
			<p class="TopLink dontPrintMe">
				<a href="#">Return to the Table of Contents</a>
			</p>
		</xsl:template>
		
	<xsl:template match="ead/archdesc/otherfindaid/head
		| ead/archdesc/*/otherfindaid/head
		| ead/archdesc/bibliography/head
		| ead/archdesc/*/bibliography/head
		| ead/archdesc/fileplan/head
		| ead/archdesc/*/fileplan/head
		| ead/archdesc/phystech/head
		| ead/archdesc/originalsloc/head">
		<h3>
			<a name="{generate-id()}"></a>
			<xsl:apply-templates/>
		</h3>
	</xsl:template>

	<xsl:template match="ead/archdesc/otherfindaid/p
		| ead/archdesc/*/otherfindaid/p
		| ead/archdesc/bibliography/p
		| ead/archdesc/*/bibliography/p
		| ead/archdesc/otherfindaid/note/p
		| ead/archdesc/*/otherfindaid/note/p
		| ead/archdesc/bibliography/note/p
		| ead/archdesc/*/bibliography/note/p
		| ead/archdesc/fileplan/p
		| ead/archdesc/*/fileplan/p
		| ead/archdesc/fileplan/note/p
		| ead/archdesc/*/fileplan/note/p
		| ead/archdesc/phystech/p
		| ead/archdesc/phystechc/note/p
		| ead/archdesc/originalsloc/p
		| ead/archdesc/originalsloc/note/p">
		<p style="margin-left:1em">
			<xsl:apply-templates/>
		</p>
	</xsl:template>

	<!--This template rule tests for and formats the top-level index element. It begins
	by testing to see if there is an index element with content.-->
	<xsl:template match="ead/archdesc/index
		| ead/archdesc/*/index">
			<table>
				<!--tr>
					<td width="5%"> </td>
					<td width="45%"> </td>
					<td width="50%"> </td>
				</tr-->
				<tr>
					<td colspan="3">
						<h3>
							<a name="{generate-id(head)}"></a>
							<xsl:apply-templates select="head"/>
						</h3>
					</td>
				</tr>
				<xsl:for-each select="p | note/p">
					<tr>
						<td></td>
						<td colspan="2">
							<xsl:apply-templates/>
						</td>
					</tr>
				</xsl:for-each>

				<!--Processes each index entry.-->
				<xsl:for-each select="indexentry">

				<!--Sorts each entry term.-->
					<xsl:sort select="corpname | famname | function | genreform | geogname | name | occupation | persname | subject"/>
					<tr>
						<td></td>
						<td>
							<xsl:apply-templates select="corpname | famname | function | genreform | geogname | name | occupation | persname | subject"/>
						</td>
						<!--Supplies whitespace and punctuation if there is a pointer
						group with multiple entries.-->

						<xsl:choose>
							<xsl:when test="ptrgrp">
								<td>
									<xsl:for-each select="ptrgrp">
										<xsl:for-each select="ref | ptr">
											<xsl:apply-templates/>
											<xsl:if test="preceding-sibling::ref or preceding-sibling::ptr">
												<xsl:text>, </xsl:text>
											</xsl:if>
										</xsl:for-each>
									</xsl:for-each>
								</td>
							</xsl:when>
							<!--If there is no pointer group, process each reference or pointer.-->
							<xsl:otherwise>
								<td>
									<xsl:for-each select="ref | ptr">
										<xsl:apply-templates/>
									</xsl:for-each>
								</td>
							</xsl:otherwise>
						</xsl:choose>
					</tr>
					<!--Closes the indexentry.-->
				</xsl:for-each>
			</table>
			<p class="TopLink dontPrintMe">
				<a href="#">Return to the Table of Contents</a>
			</p>
	</xsl:template>

<!--Insert the address for the dsc stylesheet of your choice here.-->
	<xsl:include href="dsc15.xsl"/>
</xsl:stylesheet>
