<?xml version="1.0" encoding="UTF-8" ?>
<!--
	===========================================================================
	TEI header TO HTML conversion
	===========================================================================
	
	This stylesheet generates an HTML report for the TEI header.  
    
    Given TEI's byzantine complexity, it is non-trivial to write generic style 
    sheets that produce high-quality reports for every possible document.
    This stylesheet does NOT pretend to do that. It is a practical conversion 
    for a specific set of documents. Not every single item in the header is 
    supported and some templates expect a subset of what is allowed in TEI, 
    reflecting local policies or choices. But it might produce acceptable 
    output for other documents, and it can be extended.
     
	Revision history:
	[2004-03-12] First draft
	[2004-03-17] Substantially revised draft
	[2006-09-26] Minor changes to the output HTML
	[2026-02-05] Adapted for TEI P5 and HTML5
	[2026-02-19] Minor tweaks; revision date; diff-types list
	[2026-03-20] Removed redundant @class="title" from HTML cite
	[2026-04-27] Fixed broken link (thanks, Ilya!)
	[2026-06-25] Updated file links
	
	Tom De Herdt
	https://www.wulfila.be/
	
	===========================================================================
--> 
<xsl:stylesheet 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xpath-default-namespace="http://www.tei-c.org/ns/1.0"
	version="3.0">

	<xsl:output 
		method="html"
		html-version="5.0"
		encoding="UTF-8"
		omit-xml-declaration="yes"
		include-content-type="no"
		indent="yes"
	/>
	
	<xsl:param name="doc">https://www.wulfila.be/gothic/text/data/edition.xml</xsl:param>
	
	<xsl:template match="/">
		<html lang="en">
			<head>
				<meta charset="UTF-8"/>
				<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
				<title>TEI header: <xsl:value-of select="TEI/teiHeader/fileDesc/titleStmt/title"/></title>
				<style>
body {
	margin: 4%;
	max-width: 80em;
	font-family: Georgia, serif;
	line-height: 1.3;
}
h1, h2, h3, h4 {
	font-weight: normal;
}
h1 {
	text-align: center;
}
h3 {
	margin-bottom: 0em;
	background-color: #EEEEEE;
	padding: 0.2em;
}
h4 {
	margin-bottom: 0em;
}
div p {
	margin-left: 0.4em;
	margin-top: 0.5em;
}
td p {
	margin-left: 0em;
	margin-top: 0.5em;
}
div div {
	margin-bottom: 2em;
}
table {
	width: 100%;
	border: 0;
	border-spacing: 0;
}
tr.head td {
	border: none;
}
td {
	border-bottom: 1px dashed #FF5200;
	vertical-align: top;
	text-align: left;
	line-height: 1.3;
	padding: 0.4em;
}
td.label {
	width: 25%;
	color: navy;
	text-align: left;
}
td p {
	margin-top: 0em;
	margin-bottom: 0em;
	line-height: 1.3;
}
p {
	text-align: left;
	line-height: 1.3;
}
#diff-types {
	list-style-type: none;
}
a img {
	border: none;
}
header {
	border-top: 1px solid #ddd;
	border-bottom: 1px solid #ddd;
	margin-left: 0;
	margin-bottom: 2em;
	padding-left: 0;
}
header p {
	margin-left: 0;
}
footer {
	margin-top: 4em;
	font-size: smaller;
	border-top: 1px solid #ddd;
}
q {
	font-style: italic;
}
.title {
	font-style: italic;
}
.index {
	color: #FF5200;
}
.major {
	font-weight: bold;
}
code {
	font-family: Consolas, monospace;
}
a:link, a:active, a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
	color: navy;
}
@media print {
	body {
		margin-left: 5%;
		margin-top: 2%;
		margin-right: 2%;
		margin-bottom: 2%;
		font-size: small;
	}
	h3 {
		margin-top: 0em;
	}
}
</style>
			</head>
			<body>
				<h1>TEI Header</h1>
				<header>
					<p>Document: <a href="{$doc}"><xsl:value-of select="$doc"/></a></p>
					<p>Revision: <a href="#revisionDesc"><xsl:value-of select="TEI/teiHeader/revisionDesc/change[last()]/@when"/></a></p>
					<p>Encoding: <a href="https://tei-c.org/guidelines/p5/" title="Text Encoding Initiative P5 Guidelines">TEI P5</a><xsl:apply-templates select="TEI/@version"/></p>
					<p>Derived and related files: <a href="https://www.wulfila.be/gothic/download/">https://www.wulfila.be/gothic/download</a></p>
				</header>
				<main>
					<xsl:apply-templates select="TEI/teiHeader"/>
				</main>
				<footer>
					<p>
						<xsl:text>This document was generated from the original TEI document with </xsl:text>
						<a href="https://www.wulfila.be/code/xslt/derived/TEI2header.xsl">this XSLT stylesheet</a>
						<xsl:text> on </xsl:text>
						<xsl:value-of select="current-dateTime()"/>
						<xsl:text>.</xsl:text>
					</p>
				</footer>
			</body>
		</html>
	</xsl:template>
	
	<xsl:template match="TEI/@version"> (<xsl:value-of select="."/>)</xsl:template>
	
<!-- ========================================================================== -->
<!-- [1] FILE DESCRIPTION <fileDesc> -->
<!-- ========================================================================== -->

	<xsl:template match="fileDesc">
		<div id="{local-name(.)}" class="level2">
			<h2><xsl:call-template name="title-attribute"/>1. File description</h2>
			<xsl:apply-templates/>
		</div>
	</xsl:template>

<!-- .......................................................................... -->
<!-- [1.1] <titleStmt> -->
	
	<xsl:template match="fileDesc/titleStmt">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Title statement</h3>
			<table>
				<!-- Process the children in this particular order: -->
				<xsl:apply-templates select="title" mode="titleStmt"/>
				<xsl:apply-templates select="author" mode="titleStmt"/>
				<xsl:apply-templates select="editor" mode="titleStmt"/>
				<xsl:apply-templates select="sponsor" mode="titleStmt"/>
				<xsl:apply-templates select="funder" mode="titleStmt"/>
				<xsl:apply-templates select="principal" mode="titleStmt"/>
				<xsl:apply-templates select="respStmt" mode="titleStmt"/>
			</table>
		</div>
	</xsl:template>

	<xsl:template match="author|editor|sponsor|funder|principal" mode="titleStmt">
		<xsl:variable name="label">
			<xsl:choose>
				<xsl:when test="self::title">Title</xsl:when>
				<xsl:when test="self::author">Author</xsl:when>
				<xsl:when test="self::editor">Editor</xsl:when>
				<xsl:when test="self::sponsor">Sponsor</xsl:when>
				<xsl:when test="self::funder">Funder</xsl:when>
				<xsl:when test="self::principal">Principal researcher</xsl:when>
				<xsl:when test="self::respStmt">Responsibility</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<tr>
			<td class="label">
				<xsl:call-template name="title-attribute"/>
				<xsl:value-of select="$label"/>
				<xsl:if test="last()&gt;1">
					<xsl:text> </xsl:text>
					<span class="index">[<xsl:value-of select="position()"/>]</span>
				</xsl:if>
			</td>
			<td><xsl:apply-templates/></td>
		</tr>
	</xsl:template>
	
	<xsl:template match="title" mode="titleStmt">
		<tr>
			<td class="label">
				<xsl:call-template name="title-attribute"/>
				<xsl:text>Title</xsl:text>
				<xsl:if test="last()&gt;1">
					<xsl:text> </xsl:text>
					<span class="index">[<xsl:value-of select="position()"/>]</span>
				</xsl:if>
			</td>
			<td><strong><xsl:apply-templates/></strong></td>
		</tr>
	</xsl:template>
		
	<xsl:template match="respStmt" mode="titleStmt">
		<xsl:variable name="label" select="'Responsibility'"/>
		<tr>
			<td class="label">
				<xsl:call-template name="title-attribute"/>
				<xsl:value-of select="$label"/>
				<xsl:if test="last()&gt;1">
					<xsl:text> </xsl:text>
					<span class="index">[<xsl:value-of select="position()"/>]</span>
				</xsl:if>
			</td>
			<td>
				<xsl:value-of select="resp"/>
				<xsl:text>: </xsl:text>
				<xsl:for-each select="name">
					<xsl:apply-templates/>
					<xsl:choose>
						<xsl:when test="position() eq (last() - 1)"> &amp; </xsl:when>
						<xsl:when test="position() ne last()">, </xsl:when>
					</xsl:choose>
				</xsl:for-each>
			</td>
		</tr>
	</xsl:template>


<!-- .......................................................................... -->
<!-- [1.2] <editionStmt> -->

	<xsl:template match="fileDesc/editionStmt">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Edition statement</h3>
			<table>
				<tr>
					<td class="label"><xsl:call-template name="title-attribute"/>Edition</td>
					<td><xsl:apply-templates/></td>
				</tr>
			</table>
		</div>
	</xsl:template>
	
	<xsl:template match="fileDesc/editionStmt/edition">
		<xsl:apply-templates/>
		<xsl:if test="not(substring(normalize-space(.), string-length(normalize-space(.)))='.')">.</xsl:if>
		<xsl:text> </xsl:text>
	</xsl:template>
	<xsl:template match="fileDesc/editionStmt/respStmt"><xsl:apply-templates/><xsl:text> </xsl:text></xsl:template>


<!-- .......................................................................... -->
<!-- [1.3] <extent> -->

	<xsl:template match="extent">		
		<div>
			<h3><xsl:call-template name="title-attribute"/>Extent</h3>
			<table>
				<tr>
					<td class="label">Size</td>
					<td><xsl:apply-templates/></td>
				</tr>
			</table>
		</div>
	</xsl:template>
	
	<xsl:template match="measure">
		<xsl:value-of select="concat(., ' ', @type)"/>
	</xsl:template>


<!-- .......................................................................... -->
<!-- [1.4] <publicationStmt> -->

	<xsl:template match="fileDesc/publicationStmt">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Publication statement</h3>
			<xsl:choose>
				<xsl:when test="p">
					<xsl:apply-templates/>
				</xsl:when>
				<xsl:otherwise>
					<table>
						<xsl:apply-templates mode="publicationStmt"/>
					</table>
				</xsl:otherwise>
			</xsl:choose>
		</div>
	</xsl:template>
	
	<xsl:template match="publisher|distributor|authority|pubPlace|idno|date" mode="publicationStmt">
		<xsl:variable name="label">
			<xsl:choose>
				<xsl:when test="self::publisher">Publisher</xsl:when>
				<xsl:when test="self::distributor">Distributor</xsl:when>
				<xsl:when test="self::authority">Authority</xsl:when>
				<xsl:when test="self::pubPlace">Publication place</xsl:when>
				<xsl:when test="self::idno">
					<xsl:choose>
						<xsl:when test="@type"><xsl:value-of select="@type"/></xsl:when>
						<xsl:otherwise>Identification number</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:when test="self::date">Date</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<tr>
			<td class="label">
				<xsl:call-template name="title-attribute"/>
				<xsl:value-of select="$label"/>
			</td>
			<td><xsl:apply-templates/></td>
		</tr>
	</xsl:template>

	<xsl:template match="availability" mode="publicationStmt">
		<!-- ATTRIBUTE: status -->
		<xsl:variable name="status">
			<xsl:value-of select="@status"/>
			<xsl:if test="not(@status)">unknown</xsl:if>
		</xsl:variable>
		<xsl:variable name="status-tooltip">
			<xsl:choose>
				<xsl:when test="$status='free'">the text is freely available</xsl:when>
				<xsl:when test="$status='unknown'">the status of the text is unknown</xsl:when>
				<xsl:when test="$status='restricted'">the text is not freely available</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Availability</td>
			<td>
				<p class="attributes">
					<var class="attribute">status</var>
					<xsl:text> = </xsl:text>
					<span class="attribute-value" title="{$status-tooltip}"><xsl:value-of select="$status"/></span>
				</p>
				<xsl:apply-templates/>
			</td>
		</tr>
	</xsl:template>

	<xsl:template match="address" mode="publicationStmt">
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Address</td>
			<td>
				<address>
					<xsl:for-each select="addrLine|name|street|postCode|postBox">
						<xsl:apply-templates/><xsl:if test="not(position()=last())">, </xsl:if>
					</xsl:for-each>
				</address>
			</td>
		</tr>
	</xsl:template>

<!-- .......................................................................... -->
<!-- [1.5] <seriesStmt> *** NOT (YET) IMPLEMENTED *** -->
	
	<xsl:template match="seriesStmt"/>


<!-- .......................................................................... -->
<!-- [1.6] <notesStmt> -->
	
	<xsl:template match="fileDesc/notesStmt">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Notes</h3>
			<table>
				<xsl:for-each select="note">
					<tr>
						<td class="label" style="text-align: right;">[<xsl:value-of select="position()"/>]</td>
						<td><xsl:apply-templates/></td>
					</tr>
				</xsl:for-each>
			</table>
		</div>
	</xsl:template>

<!-- .......................................................................... -->
<!-- [1.7] <sourceDesc> -->

	<xsl:template match="fileDesc/sourceDesc">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Source description</h3>
			<xsl:apply-templates select="biblStruct"/>
		</div>
	</xsl:template>
	
<!-- ========================================================================== -->
<!-- [2] ENCODING DESCRIPTION <encodingDesc> -->
<!-- ========================================================================== -->

	<xsl:template match="encodingDesc">
		<div id="{local-name(.)}" class="level2">
			<h2><xsl:call-template name="title-attribute"/>2. Encoding</h2>
			<xsl:apply-templates select="*[not(self::p)]"/>
			<xsl:if test="p">
				<div>
					<h3>Additional notes</h3>
					<xsl:apply-templates select="p"/>
				</div>
			</xsl:if>
		</div>
	</xsl:template>

<!-- <!ELEMENT encodingDesc %om.RR; (projectDesc*, samplingDecl*, editorialDecl*, 
                                     tagsDecl?, refsDecl*, classDecl*, metDecl*, 
                                     fsdDecl*, variantEncoding*, p* )>  -->

<!-- .......................................................................... -->
<!-- [2.1] <projectDesc> -->

	<xsl:template match="projectDesc">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Project description<!--(*)--></h3>
			<xsl:apply-templates/>
		</div>
	</xsl:template>

<!-- .......................................................................... -->
<!-- [2.2] <samplingDecl> -->

	<xsl:template match="samplingDecl">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Sampling declaration</h3>
			<xsl:apply-templates/>
		</div>
	</xsl:template>

<!-- .......................................................................... -->
<!-- [2.3] <editorialDecl> -->

	<xsl:template match="editorialDecl">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Editorial declarations</h3>
			<xsl:choose>
				<xsl:when test="not(correction | normalization | quotation | hyphenation | interpretation | segmentation | punctuation | stdVals)">
				<!-- contains paragraphs only: -->
					<xsl:apply-templates select="p"/>
				</xsl:when>
				<xsl:otherwise>
				<!-- contains specific items and optionally paragraphs at the end: -->
					<table>
						<xsl:apply-templates select="correction | normalization | quotation | hyphenation | interpretation | segmentation | punctuation | stdVals"/>
					</table>
					<xsl:apply-templates select="p"/>
				</xsl:otherwise>
			</xsl:choose>
		</div>
	</xsl:template>
	
	<xsl:template match="correction">
		<!-- ATTRIBUTE: status -->
		<xsl:variable name="status">
			<xsl:value-of select="@status"/>
			<xsl:if test="not(@status)">unknown</xsl:if><!-- apply default value when using a non-validating parser -->
		</xsl:variable>
		<xsl:variable name="status-tooltip">
			<xsl:choose>
				<xsl:when test="$status='high'">the text has been thoroughly checked and proofread</xsl:when>
				<xsl:when test="$status='medium'">the text has been checked at least once</xsl:when>
				<xsl:when test="$status='low'">the text has not been checked</xsl:when>
				<xsl:when test="$status='unknown'">the correction status of the text is unknown</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<!-- ATTRIBUTE: method -->
		<xsl:variable name="method">
			<xsl:value-of select="@method"/>
			<xsl:if test="not(@method)">silent</xsl:if>
		</xsl:variable>
		<xsl:variable name="method-tooltip">
			<xsl:choose>
				<xsl:when test="$method='silent'">corrections have been made silently</xsl:when>
				<xsl:when test="$method='tags'">corrections have been represented using editorial tags</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Corrections</td>
			<td>
				<p class="attributes">
					<var class="attribute">status</var>
					<xsl:text> = </xsl:text>
					<span class="attribute-value" title="{$status-tooltip}"><xsl:value-of select="$status"/></span>
					<xsl:text>, </xsl:text>
					<var class="attribute">method</var>
					<xsl:text> = </xsl:text>
					<span class="attribute-value" title="{$method-tooltip}"><xsl:value-of select="$method"/></span>
				</p>
				<xsl:apply-templates/>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="normalization">
		<!-- ATTRIBUTE: method -->
		<xsl:variable name="method">
			<xsl:value-of select="@method"/>
			<xsl:if test="not(@method)">silent</xsl:if>
		</xsl:variable>
		<xsl:variable name="method-tooltip">
			<xsl:choose>
				<xsl:when test="$method='silent'">normalization made silently</xsl:when>
				<xsl:when test="$method='tags'">normalization represented using editorial tags</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Normalization</td>
			<td>
				<p class="attributes"> 
					<xsl:if test="@source">
						<var class="attribute">source</var>
						<xsl:text> = </xsl:text>
						<span class="attribute-value" title="indicates the authority for any normalization carried out"><xsl:value-of select="@source"/></span>
						<xsl:text>, </xsl:text>
					</xsl:if>
					<var class="attribute">method</var>
					<xsl:text> = </xsl:text>
					<span class="attribute-value" title="{$method-tooltip}"><xsl:value-of select="$method"/></span>
				</p>
				<xsl:apply-templates/>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="quotation">
		<!-- ATTRIBUTE: marks -->
		<xsl:variable name="marks">
			<xsl:value-of select="@marks"/>
			<xsl:if test="not(@marks)">all</xsl:if><!-- apply default value when using a non-validating parser -->
		</xsl:variable>
		<xsl:variable name="marks-tooltip">
			<xsl:choose>
				<xsl:when test="$marks='none'">no quotation marks have been retained</xsl:when>
				<xsl:when test="$marks='some'">some quotation marks have been retained</xsl:when>
				<xsl:when test="$marks='all'">all quotation marks have been retained</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<!-- ATTRIBUTE: form -->
		<xsl:variable name="form">
			<xsl:value-of select="@form"/>
			<xsl:if test="not(@form)">unknown</xsl:if>
		</xsl:variable>
		<xsl:variable name="form-tooltip">
			<xsl:choose>
				<xsl:when test="$form='data'">quotation marks are retained as data</xsl:when>
				<xsl:when test="$form='rend'">the rendition attribute is consistently used to indicate the form of quotation marks</xsl:when>
				<xsl:when test="$form='std'">use of quotation marks has been standardized</xsl:when>
				<xsl:when test="$form='nonstd'">quotation marks are represented inconsistently</xsl:when>
				<xsl:when test="$form='unknown'">use of quotation marks is unknown</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Quotations</td>
			<td>
				<p class="attributes">
					<var class="attribute">marks</var>
					<xsl:text> = </xsl:text>
					<span class="attribute-value" title="{$marks-tooltip}"><xsl:value-of select="$marks"/></span>
					<xsl:text>, </xsl:text>
					<var class="attribute">form</var>
					<xsl:text> = </xsl:text>
					<span class="attribute-value" title="{$form-tooltip}"><xsl:value-of select="$form"/></span>
				</p>
				<xsl:apply-templates/>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="hyphenation">
		<!-- ATTRIBUTE: eol -->
		<xsl:variable name="eol">
			<xsl:value-of select="@eol"/>
			<xsl:if test="not(@eol)">some</xsl:if><!-- apply default value when using a non-validating parser -->
		</xsl:variable>
		<xsl:variable name="eol-tooltip">
			<xsl:choose>
				<xsl:when test="$eol='all'">all end-of-line hyphenation has been retained, even though the lineation of the original may not have been</xsl:when>
				<xsl:when test="$eol='some'">end-of-line hyphenation has been retained in some cases</xsl:when>
				<xsl:when test="$eol='none'">all end-of-line hyphenation has been removed: any remaining hyphenation occurred within the line</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Hyphenation</td>
			<td>
				<p class="attributes">
					<var class="attribute">eol</var>
					<xsl:text> = </xsl:text>
					<span class="attribute-value" title="{$eol-tooltip}"><xsl:value-of select="$eol"/></span>
				</p>
				<xsl:apply-templates/>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="segmentation">
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Segmentation</td>
			<td><xsl:apply-templates/></td>
		</tr>
	</xsl:template>
	
	<xsl:template match="punctuation">
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Punctuation</td>
			<td><xsl:apply-templates/></td>
		</tr>
	</xsl:template>
	
	<xsl:template match="interpretation">
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Interpretation</td>
			<td><xsl:apply-templates/></td>
		</tr>
	</xsl:template>
	
	<xsl:template match="stdVals">
		<tr>
			<td class="label"><xsl:call-template name="title-attribute"/>Standardization</td>
			<td><xsl:apply-templates/></td>
		</tr>
	</xsl:template>
	
<!-- .......................................................................... -->
<!-- [2.4] <tagsDecl> -->

	<xsl:template match="tagsDecl">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Tagging declaration</h3>
			<xsl:if test="rendition">
				<h4 title="TEI &lt;rendition&gt;">Renditions:</h4>
				<table>
					<xsl:apply-templates select="rendition"/>
				</table>
			</xsl:if>
			<xsl:if test="namespace/tagUsage">
				<table>
					<xsl:apply-templates select="namespace/tagUsage"/>
				</table>
			</xsl:if>
			<xsl:if test="tagUsage"></xsl:if>
		</div>
	</xsl:template>
	
	<xsl:template match="rendition">
		<tr>
			<td class="label">ID <code><xsl:value-of select="@id"/></code></td>
			<td><p><xsl:apply-templates/></p></td>
		</tr>
	</xsl:template>
	
	<xsl:template match="tagUsage">
		<tr>
			<td class="label"><code>&lt;<xsl:value-of select="@gi"/>&gt;</code></td>
			<td>
				<xsl:if test="@occurs|@render|@ident">
					<p class="attributes">
						<xsl:for-each select="@occurs|@render|@ident">
							<var class="attribute"><xsl:value-of select="local-name(.)"/></var>
							<xsl:text> = </xsl:text>
							<span class="attribute-value"><xsl:value-of select="."/></span>
							<xsl:if test="not(position()=last())">, </xsl:if>
						</xsl:for-each>
					</p>
				</xsl:if>
				<p><xsl:apply-templates/></p>
			</td>
		</tr>
	</xsl:template>

<!-- .......................................................................... -->
<!-- [2.5] <refsDecl> -->

	<xsl:template match="refsDecl">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Reference system declaration</h3>
			<xsl:apply-templates select="p"/><!-- step|state not supported -->
		</div>
	</xsl:template>
	
<!-- .......................................................................... -->
<!-- [2.6] <classDecl> -->

<!-- .......................................................................... -->
<!-- [2.7] <fsdDecl> -->

<!-- .......................................................................... -->
<!-- [2.8] <metDecl> -->

<!-- .......................................................................... -->
<!-- [2.9] <variantEncoding> -->
	
	<xsl:template match="variantEncoding">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Variant encoding</h3>
			<table>
				<tr>
					<td class="label">Method</td>
					<td><xsl:value-of select="@method"/></td>
				</tr>
				<tr>
					<td class="label">Location</td>
					<td><xsl:value-of select="@location"/></td>
				</tr>
			</table>
		</div>
	</xsl:template>
	

<!-- ========================================================================== -->
<!-- [3] PROFILE DESCRIPTION <profileDesc> -->
<!-- ========================================================================== -->

	<xsl:template match="profileDesc">
		<div id="{local-name(.)}" class="level2">
			<h2><xsl:call-template name="title-attribute"/>3. Text profile</h2>
			<xsl:apply-templates/>
		</div>
	</xsl:template>

<!-- <!ELEMENT profileDesc %om.RR;  (creation?, langUsage*, textDesc*,particDesc*, settingDesc*, handList*, textClass*)>  -->

<!-- .......................................................................... -->
<!-- [3.1] <creation> -->

	<xsl:template match="creation">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Creation</h3>
			<p><xsl:apply-templates/></p>
		</div>
	</xsl:template>
	
<!-- .......................................................................... -->
<!-- [3.2] <langUsage> -->
	
	<!-- <!ELEMENT langUsage %om.RO; (p | language)+> -->
	
	<xsl:template match="langUsage">
		<div>
			<h3><xsl:call-template name="title-attribute"/>Language</h3>
			<!-- subsetting to (p+|(p*, language+)): -->
			<xsl:apply-templates select="p"/>
			<xsl:if test="language">
				<ul>
					<xsl:apply-templates select="language"/>
				</ul>
			</xsl:if>
		</div>
	</xsl:template>
	
	<xsl:template match="language">
		<li>
			<xsl:text>[</xsl:text>
			<xsl:value-of select="@ident"/>
			<xsl:text>] </xsl:text>
			<xsl:value-of select="."/>
		</li>
	</xsl:template>

<!-- .......................................................................... -->
<!-- The remaining items are not used in this project: -->

	<xsl:template match="textDesc|particDesc|settingDesc|handList|textClass">
		<xsl:comment>
			There's currently no template defined for element "<xsl:value-of select="local-name(.)"/>".
		</xsl:comment>
	</xsl:template>


<!-- ========================================================================== -->
<!-- [4] REVISION DESCRIPTION <revisionDesc> -->
<!-- ========================================================================== -->

	<xsl:template match="revisionDesc[list or change]">
		<div id="{local-name(.)}" class="level2">
			<h2><xsl:call-template name="title-attribute"/>4. Revision history</h2>
			<p>Major revisions in boldface.</p>
			<xsl:choose>
				<xsl:when test="list">
					<xsl:apply-templates/>
				</xsl:when>
				<xsl:otherwise>
					<table>
						<xsl:apply-templates select="change"/>
					</table>
				</xsl:otherwise>
			</xsl:choose>
		</div>
	</xsl:template>
	
	<xsl:template match="change">
		<tr>
			<td class="{string-join(('label',@type),' ')}">
				<xsl:apply-templates select="@n" mode="change"/>
				<xsl:apply-templates select="@when" mode="change"/>
			</td>
			<td>
				<xsl:apply-templates/>
				<xsl:apply-templates select="@who" mode="change"/>
			</td>
		</tr>
	</xsl:template>
	
	<xsl:template match="@n" mode="change">[<xsl:value-of select="."/>] </xsl:template>
	
	<xsl:template match="@who" mode="change"> (<xsl:value-of select="."/>)</xsl:template>
	
	<xsl:template match="@who[.='#TDH']" mode="change"/><!-- hide main contributor -->
	
	<!-- <list> handled by generic templates below -->
	

<!-- ========================================================================== -->
<!-- GENERAL TEMPLATES -->
<!-- ========================================================================== -->

	<xsl:template name="title-attribute">
		<xsl:attribute name="title">TEI &lt;<xsl:value-of select="local-name(.)"/>&gt;</xsl:attribute>
	</xsl:template>
	
	<xsl:template match="@*"/>
	
	<xsl:template match="@xml:lang">
		<xsl:attribute name="lang">
			<xsl:choose>
				<xsl:when test=".='eng'">en</xsl:when>
				<xsl:when test=".='ger'">de</xsl:when>
				<xsl:when test=".='dut'">nl</xsl:when>
				<xsl:when test=".='lat'">la</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="."/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:attribute>
	</xsl:template>
	
	<xsl:template match="list">
		<ul>
			<xsl:apply-templates select="@xml:lang"/>
			<xsl:apply-templates select="@xml:id"/>
			<xsl:apply-templates select="item"/>
		</ul>
	</xsl:template>
	
	<xsl:template match="item">
		<li><xsl:apply-templates select="@xml:lang|*|text()"/></li>
	</xsl:template>
	
	
	<!-- List of segment difference subtypes: -->
	
	<xsl:template match="id('diff-types')">
		<ul id="{@xml:id}"><xsl:apply-templates/></ul>
	</xsl:template>
	
	<xsl:template match="id('diff-types')/item">
		<li>
			<xsl:value-of select="@n"/>
			<xsl:text> = </xsl:text>
			<xsl:apply-templates/>
		</li>
	</xsl:template>
	
	<xsl:template match="id('diff-types')/item/label">
		<b><xsl:apply-templates/></b>
		<xsl:text>. </xsl:text>
	</xsl:template>
	
	
	<xsl:template match="ref">
		<a href="{@target}"><xsl:apply-templates select="@xml:lang|*|text()"/></a>
	</xsl:template>
	
	<xsl:template match="p">
		<p><xsl:apply-templates select="@xml:lang|*|text()"/></p>
	</xsl:template>
	
	<xsl:template match="p[list]">
		<p><xsl:apply-templates select="@xml:lang|(* except list)|text()"/></p>
		<xsl:apply-templates select="list"/>
	</xsl:template>
	
	<xsl:template match="mentioned|foreign|hi">
		<i><xsl:apply-templates  select="@xml:lang|*|text()"/></i>
	</xsl:template>
	
	<xsl:template match="cit">
		<xsl:apply-templates select="quote"/> (<xsl:apply-templates select="bibl"/>) 
	</xsl:template>
	
	<xsl:template match="quote">
		<q><xsl:apply-templates select="@xml:lang|*|text()"/></q>
	</xsl:template>
	
	<xsl:template match="emph">
		<em><xsl:apply-templates select="@xml:lang|*|text()"/></em>
	</xsl:template>
	
	<xsl:template match="emph[@rend='bold']|hi[@rend='bold']">
		<strong><xsl:apply-templates select="@xml:lang|*|text()"/></strong>
	</xsl:template>
	
	<xsl:template match="hi[@rend='monospace']"><code><xsl:apply-templates/></code></xsl:template>
	
	<xsl:template match="lb"><br/></xsl:template>
	
	<xsl:template match="choice[abbr and expan]"><abbr title="{expan/data()}"><xsl:apply-templates select="abbr"/></abbr></xsl:template>
	
	<xsl:template match="gi|att|tag|val">
		<code class="{local-name(.)}"><xsl:apply-templates/></code>
	</xsl:template>
	
	
<!-- ========================================================================== -->
<!-- BIBLIOGRAPHIC -->
<!-- ========================================================================== -->

<!-- incomplete, obviously -->

	<xsl:template match="biblStruct">
		<p class="biblio">
			<xsl:apply-templates select="@xml:lang"/>
			<xsl:apply-templates select="monogr"/>
			<xsl:apply-templates select="series|idno"/>
		</p>
	</xsl:template>
		
	<xsl:template match="monogr">
		<xsl:call-template name="process-authors"/>
		<xsl:apply-templates select="title"/>
		<xsl:apply-templates select="respStmt"/>
		<xsl:apply-templates select="edition"/>
		<xsl:apply-templates select="note"/>
		<xsl:apply-templates select="imprint"/>
	</xsl:template>
	
	
<!-- AUTHORS and EDITORS: -->
	<xsl:template name="process-authors">
		<xsl:call-template name="process-names"><xsl:with-param name="names" select="author"/></xsl:call-template>
		<xsl:if test="count(author)&gt;0 and count(editor)&gt;0"> / </xsl:if>
		<xsl:call-template name="process-names"><xsl:with-param name="names" select="editor"/></xsl:call-template>			
		<xsl:if test="count(editor)&gt;0">
			<xsl:choose>
				<xsl:when test="count(editor)=1"><xsl:text> </xsl:text>(Ed.)</xsl:when>
				<xsl:otherwise><xsl:text> </xsl:text>(Eds.)</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
		<xsl:text>. </xsl:text>
	</xsl:template>
	
	<xsl:template name="process-names">
		<xsl:param name="names"/>
		<xsl:for-each select="$names">
			<xsl:apply-templates select="current()"/>
			<xsl:if test="position()!=last()">
				<xsl:choose>
					<xsl:when test="position()=(last() - 1)"><xsl:text> &amp; </xsl:text></xsl:when>
					<xsl:when test="position()&lt;(last() - 1)">, </xsl:when>
				</xsl:choose>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	
	<xsl:template match="title">
		<cite>
			<xsl:apply-templates select="@xml:lang"/>
			<xsl:apply-templates/>
		</cite>
	</xsl:template>
	
	<xsl:template match="biblStruct/monogr/title">
		<cite>
			<xsl:apply-templates select="@xml:lang"/>
			<xsl:apply-templates/>
		</cite>
		<xsl:text>. </xsl:text>
	</xsl:template>

	<xsl:template match="biblStruct/monogr/respStmt/resp">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>
	
	<xsl:template match="biblStruct/monogr/edition">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>
	
	<xsl:template match="biblStruct/monogr/note">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>
	
	<xsl:template match="biblStruct/monogr/imprint">
		<xsl:apply-templates select="publisher"/>, 
		<xsl:apply-templates select="pubPlace"/>, 
		<xsl:apply-templates select="date"/>. 
	</xsl:template>
	
	<xsl:template match="series">
		<xsl:text> (</xsl:text>
		<xsl:apply-templates select="title"/>
		<xsl:apply-templates select="biblScope"/>
		<xsl:text>)</xsl:text>
	</xsl:template>
	
	<xsl:template match="biblScope[@type='pages']">
		<xsl:text>, pp. </xsl:text>
		<xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="biblScope[@type='volume']">
		<xsl:text>, vol. </xsl:text>
		<xsl:value-of select="."/>
	</xsl:template>
	<xsl:template match="biblScope">
		<xsl:text>, </xsl:text>
		<xsl:if test="@type">
			<xsl:value-of select="@type"/>
			<xsl:text> </xsl:text>
		</xsl:if>
		<xsl:value-of select="."/>
	</xsl:template>

</xsl:stylesheet>