<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="LABORATORY_PROCEDURE">
	<html>
	<head><title>PT and PTT Procedure</title></head>
	<body bgcolor="#FFFFCC">
	<blockquote>
	<xsl:apply-templates />
	</blockquote>
	</body>
	</html>
</xsl:template>

<xsl:template match="ABBREV"></xsl:template>

<xsl:template match="TITLE">
	<h2 align="center"><xsl:value-of select="." /></h2>
	<h6 align="center"><a href="#intro">Introduction</a> | <a href="#spec">Specimen</a> | <a href="#reag">Reagents</a> | <a href="#inst">Instruments</a> | <a href="#mat">Materials</a> | <a href="#qc">QC</a> | <a href="#proc">Procedure</a> | <a href="#ref">Ref Values</a> | <a href="#notes">Notes</a> | <a href="#cite">Citations</a></h6>
</xsl:template>

<xsl:template match="INTRODUCTION">
	<h3><a name="intro">Introduction</a></h3>
	<p><xsl:value-of select="PRINCIPLE" /></p>
</xsl:template>

<xsl:template match="SPECIMEN_REQUIREMENTS">
	<hr />
	<xsl:apply-templates select="SPECIMEN" />
</xsl:template>

<xsl:template match="SPECIMEN">
	<h3><a name="spec">Specimen(s)</a></h3>
	<table>
	<tr><td><b>Type:</b></td><td><xsl:value-of select="TYPE" /></td></tr>
	<tr><td valign="top"><b>Container:</b></td><td><xsl:value-of select="CONTAINER" /></td></tr>
	<tr><td valign="top"><b>Volume:</b></td><td><xsl:apply-templates select="VOLUME" /></td></tr>
	</table>
	<h4>Reject specimens if:</h4>
	<xsl:apply-templates select="REJECTION"/>
</xsl:template>
	
<xsl:template match="VOLUME">
	<xsl:value-of select="OBTAINED" />
</xsl:template>

<xsl:template match="REJECTION">
	<ul>
	<xsl:for-each select="CRITERIA">
		<li><xsl:value-of select="."/></li>
	</xsl:for-each>
	</ul>
	<h4>Rejection procedure:</h4>
	<ol>
	<xsl:apply-templates select="STEP"/>
	</ol>
</xsl:template>

<xsl:template match="STEP">
	<xsl:choose>
		<xsl:when test="self::node()[@TYPE]">
			<p><li><b><xsl:value-of select="@TYPE" />.</b>
			<xsl:if test="self::text()">
				<xsl:value-of select="." />
			</xsl:if>
			<xsl:if test="self::node()[STEP] | self::node()[ACTION]">
				<ol><xsl:apply-templates select="STEP | CONDITION | ACTION | EMPH" /></ol>
			</xsl:if></li></p>
		</xsl:when>
		<xsl:when test="self::node()[CONDITION]">
			<ul>
			<xsl:for-each select="CONDITION">
				<li><xsl:value-of select="." /></li>
			</xsl:for-each>
			</ul>
		</xsl:when>
		<xsl:when test="self::node()[STEP] | self::node()[ACTION]">
			<ol><xsl:apply-templates select="STEP | ACTION | EMPH | CONDITION" /></ol>
		</xsl:when>
		<xsl:otherwise>
			<li><xsl:value-of select="." /></li>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="ACTION">
	<xsl:choose>
		<xsl:when test="self::node()[STEP]">
			<ol>
			<xsl:apply-templates />
			</ol>
		</xsl:when>
		<xsl:otherwise>
			<li><xsl:value-of select="." /></li>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
		

<xsl:template match="PRECAUTION">
	<blockquote><i><xsl:value-of select="." /></i></blockquote>
</xsl:template>

<xsl:template match="EMPH">
	<blockquote><i><xsl:value-of select="." /></i></blockquote>
</xsl:template>

<xsl:template match="REAGENTS">
<hr />
<h3><a name="reag">Reagent(s)</a></h3>
	<p><table>
	<xsl:for-each select="REAGENT">
		<tr><xsl:apply-templates select="IDENTITY" /></tr>
		<xsl:if test="self::node()[PREPARATION]">
		<tr><td valign="top" align="right"><b>Preparation:</b></td><td><xsl:value-of select="PREPARATION" /></td></tr>
		</xsl:if>
		<xsl:if test="self::node()[STABILITY]">
		<tr><td valign="top" align="right"><b>Stability:</b></td><td><xsl:value-of select="STABILITY" /></td></tr>
		</xsl:if>
		<xsl:if test="self::node()[STORAGE]">
		<tr><td valign="top" align="right"><b>Storage:</b></td><td><xsl:value-of select="STORAGE" /></td></tr>
		</xsl:if>
		<tr><td colspan="2"></td></tr>
	</xsl:for-each>
	</table></p>
</xsl:template>

<xsl:template match="IDENTITY">
	<td><b><xsl:value-of select="NAME" /></b>
	<xsl:if test="self::node()[VENDOR]">
		(<xsl:value-of select="VENDOR" />)
	</xsl:if>
	</td><td></td>
</xsl:template>

<xsl:template match="INSTRUMENTS">
<hr />
<h3><a name="inst">Instruments(s)</a></h3>
	<xsl:for-each select="INSTRUMENT">
		<table>
		<tr><xsl:apply-templates select="IDENTITY" /></tr>
		</table>
		<p><b>Setup:</b></p>
		<ol>
		<xsl:apply-templates select="SETUP" />
		</ol>
	</xsl:for-each>
</xsl:template>

<xsl:template match="SETUP">
	<xsl:apply-templates select="STEP" />
</xsl:template>
		
<xsl:template match="MATERIALS">
<hr />
	<h3><a name="mat">Materials</a></h3>
	<ul>
	<xsl:for-each select="ITEM">
		<li><xsl:value-of select="." /></li>
	</xsl:for-each>
	</ul>
</xsl:template>

<xsl:template match="QUALITY_CONTROL">
	<hr />
	<h3><a name="qc">Quality Control</a></h3>
	<h4>Controls</h4>
	<p><table>
	<xsl:for-each select="CONTROL">
		<tr><xsl:apply-templates select="IDENTITY" /></tr>
		<tr><td valign="top" align="right"><b>Preparation:</b></td><td><xsl:value-of select="PREPARATION" /></td></tr>
		<tr><td valign="top" align="right"><b>Stability:</b></td><td><xsl:value-of select="STABILITY" /></td></tr>
		<tr><td colspan="2"></td></tr>
	</xsl:for-each>
	</table></p>
	<h4>Verification</h4>
	<xsl:apply-templates select="VERIFICATION" />
</xsl:template>

<xsl:template match="VERIFICATION">
	<ol>
	<xsl:apply-templates select="STEP" />
	</ol>
</xsl:template>

<xsl:template match="PROCEDURE">
<hr />
<h3><a name="proc">Procedure</a></h3>
	<ol>
	<xsl:apply-templates />
	</ol>
</xsl:template>

<xsl:template match="RESULTS">
	<hr />
	<h3><a name="ref">Reference values</a></h3>
	<table>
	<xsl:for-each select="REFERENCE_VALUE">
		<tr><td><xsl:value-of select="CONDITION" /></td><td><xsl:value-of select="VALUE" /></td></tr>
	</xsl:for-each>
	</table>
</xsl:template>

<xsl:template match="PROCEDURAL_NOTES">
	<hr />
	<h3><a name="notes">Procedure Notes</a></h3>
	<ul>
	<xsl:for-each select="NOTE">
		<li><xsl:value-of select="." /></li>
	</xsl:for-each>
	</ul>
</xsl:template>

<xsl:template match="CITATIONS">
	<hr />
	<h3><a name="cite">Citations</a></h3>
	<xsl:apply-templates select="CITATION"/>
</xsl:template>

<xsl:template match="CITATION">
	<p>
	<xsl:if test="self::node()[TITLE]">
		<xsl:value-of select="TITLE" /><br/>
	</xsl:if>
	<xsl:if test="self::node()[SOURCE]">
		<xsl:value-of select="SOURCE" />
	</xsl:if>
	<xsl:if test="self::node()[PAGES]">
		pp <xsl:value-of select="PAGES" />
	</xsl:if>
	<xsl:if test="self::node()[YEAR]">
		<xsl:value-of select="YEAR" />
	</xsl:if>
	</p>
</xsl:template>

</xsl:stylesheet>
