<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:doc="http://xsltsl.org/xsl/documentation/1.0">
	<doc:reference xmlns="">
		<referenceinfo>
			<releaseinfo role="meta">
	$Id:  $
			</releaseinfo>
			<author>
				<surname>Turner</surname>
				<firstname>Eric</firstname>
			</author>
			<copyright>
				<year>2006</year>
				<holder>Waters Corp.</holder>
			</copyright>
		</referenceinfo>
		<title>Waters Unitreport Detail</title>
		<partintro>
			<section>
				<title>Introduction</title>
				<para></para>
			</section>
		</partintro>
	</doc:reference>
	<xsl:output method="xml" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" indent="yes" encoding="ISO-8859-1"/>
	<xsl:template match="/">
		<html>
			<head>
				<script language="javascript">
			function openWithStyle(style)
			{
			var myUrl =new String(window.location.href);
			var newUrl = new String("");
			var styleIndex = myUrl.indexOf("style",0);
			// check if style is in Url
			if (styleIndex != -1)
			{
				// remove the style query string
				newUrl = myUrl.substring(0,styleIndex-1);
				//newUrl = newUrl + "&#38;style=" + "ViewXml.xslt";
			}
			else
			{
				newUrl = myUrl + "&#38;style=" + style;
			}
			window.location.href=newUrl;
			}
				</script>
				<link rel="stylesheet" href="/css/style.css"/>
				<style type="text/css">
		h1 {text-align:center;
			font-size:18pt;
			}
		h2 {font-family:Arial;
			font-weight:400;
			font-size:12pt;
			}
		h3 {font-family:Arial;
			font-weight:400;
			font-size:12pt;
			text-decoration:underline;
			}
		h4 {
				    border-style: solid;
					border-width: thin;
					border-color: #000000;
					text-align: left;
					font-family: Verdana, Arial, Helvetica, sans-serif;
					font-size: 8px;
					font-weight: normal;
					}
		h5	{
			font-family: Verdana, Arial, Helvetica, sans-serif;
			font-size: 24px;
			border-style: solid;
			font-weight: normal;
			text-align: left;
			border-width: thin;
			vertical-align: top;
			}
					.ItemName {
						font-family: Verdana, Arial, Helvetica, sans-serif;
						font-size: 12px;
						font-weight: bold;
					}
					.Measurement {
						font-family: Verdana, Arial, Helvetica, sans-serif;
						font-size: 12px;
					}
					.outCome {
					border-top-style: none;
					border-right-style: none;
					border-bottom-style: none;
					border-left-style: solid;
					border-top-width: thin;
					border-right-width: thin;
					border-bottom-width: thin;
					border-left-width: thin;
					border-top-color: #000000;
					border-right-color: #000000;
					border-bottom-color: #000000;
					border-left-color: #000000;
					text-align: center;
				}
				.TableHeader {
					font-family: Verdana, Arial, Helvetica, sans-serif;
					font-size: 12px;
					border-top-style: none;
					border-right-style: none;
					border-bottom-style: none;
					border-left-style: none;
					border-top-width: thin;
					border-right-width: thin;
					border-bottom-width: thin;
					border-left-width: thin;
					border-top-color: #000000;
					border-right-color: #000000;
					border-bottom-color: #000000;
					border-left-color: #000000;
					text-align: center;
					height: 30px;
					background-color: #CCCCCC;
					color: #000000;
				}
				.table
				{
				empty-cells: show;
				}

				hr {

				border: 0;
				width: 700;
				color: #003366;
				background-color: #f00;
				height: 2px;
				}
				</style>
			</head>
			<body>
				<!-- ===============  -->
				<!-- Test Header      -->
				<!-- ===============  -->
			<h1>Waters Corporation - Instrument Final Test Record</h1>
		<table border="3" width="100%">
			<td>
				<table border="0" height="100px">
					<tr>
						<td colspan="210">
							<h2>Part Number: <U><xsl:value-of select="/UnitReport/Category/Product/@part-no"/></U></h2>
						</td>
						<td>
							<h2 align="left">Product: <U><xsl:value-of select="/UnitReport/Category/Product/@name"/></U></h2>
						</td>
					</tr>
					<tr>
						<td colspan="210">
							<h2>Operator: <U><xsl:value-of select="/UnitReport/Operator/@name"/></U></h2>
						</td>
						<td colspan="80">
							<h2 align="left">Start Time: 
								<U>
								<xsl:variable name="start-time" select="/UnitReport/@start-time"></xsl:variable>
								<xsl:variable name="end-time" select="/UnitReport/@end-time"></xsl:variable>
								<xsl:value-of select="substring-before(substring-after($start-time,'-'),'-')"/>
								<xsl:text>/</xsl:text>
								<xsl:value-of select="substring-before(substring-after(substring-after($start-time,'-'),'-'),'T')"/>
								<xsl:text>/</xsl:text>
								<xsl:value-of select="substring-before($start-time,'-')"/>
								<xsl:text>, </xsl:text>
								<xsl:value-of select="substring-before(substring-after($start-time,'T'),':')"/>
								<xsl:text>:</xsl:text>
								<xsl:value-of select="substring-before(substring-after(substring-after($start-time,'T'),':'),':')"/>
								<xsl:text>:</xsl:text>
								<xsl:value-of select="substring-before(substring-after(substring-after(substring-after($start-time,'T'),':'),':'),'-')"/>
								</U>
							</h2>
						</td>
					</tr>
					<tr>
						<td colspan="210">
							<h2>Serial Number: <U><xsl:value-of select="/UnitReport/Category/Product/@serial-no"/></U></h2>
						</td>
						<td>
							<xsl:if test="string-length((UnitReport/Category/Product/Property/ValueString)[1])>0">
								<h2 align="left"><xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)[1]/@name"/>: <U><xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)[1]"/></U></h2>
							</xsl:if>
						</td>
					</tr>
				</table>
			</td>
		</table>
		<table>
			<xsl:if test="string-length((UnitReport/TestRun/Property/ValueString)[1])>0">
				<tr>
					<td>
					<xsl:value-of select="(UnitReport/TestRun/Property/ValueString[1])/@name"></xsl:value-of>
					:
					<xsl:value-of select="(UnitReport/TestRun/Property/ValueString[1])"></xsl:value-of>
					</td>
				</tr>
			</xsl:if>
			<xsl:if test="string-length((UnitReport/Category/Product/Property/ValueString)[2])>0">
				<tr>
					<td>
					<xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)[2]/@name"></xsl:value-of>
					:
					<xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)[2]"></xsl:value-of>
					</td>
				</tr>
			</xsl:if>
			<xsl:if test="string-length((UnitReport/Category/Product/Property/ValueString)[3])>0">
				<tr>
					<td>
					<xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)[3]/@name"></xsl:value-of>
					:
					<xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)[3]"></xsl:value-of>
					</td>
				</tr>
			</xsl:if>
			<xsl:if test="string-length((UnitReport/Category/Product/Property/ValueString)[4])>0">
				<tr>
					<td>
					<xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)[4]/@name"></xsl:value-of>
					:
					<xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)[4]"></xsl:value-of>
					</td>
				</tr>
			</xsl:if>
			
		</table>
			
				<table cellspacing="0" width="100%" class="table" border="0">
					<!-- Table header -->
					<tr align="left">
						<td colspan="2" class="TableHeader">Name</td>
						<td class="TableHeader">LSL</td>
						<td class="TableHeader">Measurement</td>
						<td class="TableHeader">USL</td>
						<td class="TableHeader">Unit</td>
						<td class="TableHeader">Outcome</td>
					</tr>
					<!-- ===================== -->
					<!--    Test Runs		   -->
					<!-- ===================== -->
					
					<xsl:for-each select="UnitReport/Category/Product/Property">
						<xsl:if test="string-length(UnitReport/Category/Product/Property)>0">
							<xsl:value-of select="(UnitReport/Category/Product/Property/ValueString)"/>
						</xsl:if>
					</xsl:for-each>  
					
					<xsl:for-each select="//child::*/TestRun">
					<tr>
							<td  class="ItemName" colspan="2" align="left">
								<xsl:value-of select="@name"/>
							</td>
							<!-- LSL -->
							<td class="Measurement" align="center">
								<xsl:if test="string-length(./Result/Property/ValueDouble[1]/@lsl)>0">
									<xsl:value-of select="./Result/Property/ValueDouble[1]/@lsl"/>
								</xsl:if>
								<xsl:if test="string-length(./Result/Property/ValueInteger[1]/@lsl)>0">
									<xsl:value-of select="./Result/Property/ValueInteger[1]/@lsl"/>
								</xsl:if>
							</td>
							<!-- VALUE -->
							<td class="Measurement" align="center">
								<xsl:if test="string-length(./Result/Property/ValueDouble[1])>0">
									<xsl:value-of select="./Result/Property/ValueDouble[1]"/>
								</xsl:if>
								<xsl:if test="string-length(./Result/Property/ValueString[1])>0">
									<xsl:value-of select="./Result/Property/ValueString[1]"/>
								</xsl:if>
								<xsl:if test="string-length(./Result/Property/ValueInteger[1])>0">
									<xsl:value-of select="./Result/Property/ValueInteger[1]"/>
								</xsl:if>
							</td>
							<!-- USL -->
							<td class="Measurement" align="center">
								<xsl:if test="string-length(./Result/Property/ValueDouble[1]/@usl)>0">
									<xsl:value-of select="./Result/Property/ValueDouble[1]/@usl"/>
								</xsl:if>
								<xsl:if test="string-length(./Result/Property/ValueInteger[1]/@usl)>0">
									<xsl:value-of select="./Result/Property/ValueInteger[1]/@usl"/>
								</xsl:if>
							</td>
							<!-- UNIT -->
							<td class="Measurement" align="center">
								<xsl:if test="string-length(./Result/Property/ValueDouble[1]/@uom)>0">
									<xsl:value-of select="./Result/Property/ValueDouble[1]/@uom"/>
								</xsl:if>
								<xsl:if test="string-length(./Result/Property/ValueString[1]/@uom)>0">
									<xsl:value-of select="./Result/Property/ValueString[1]/@uom"/>
								</xsl:if>
								<xsl:if test="string-length(./Result/Property/ValueInteger[1]/@uom)>0">
									<xsl:value-of select="./Result/Property/ValueInteger[1]/@uom"/>
								</xsl:if>
							</td>
							<td class="outCome" width="80">
								<xsl:variable select="@grade" name="SQGrade"/>
								<xsl:call-template name="OutCome">
									<xsl:with-param name="SQGrade" select="$SQGrade"></xsl:with-param>
								</xsl:call-template>
							</td>
						</tr>
					</xsl:for-each>
				<tr colspan="9" width="100%">
					<td  colspan="9" width="100%">
						<br></br>
					Notes:
					<br></br>
					<hr width="100%"></hr>
					<br></br>
					<hr width="100%"></hr>
					<br></br>
					<hr width="100%"></hr>
					<br></br>
					</td>
					</tr>
					<tr>
						<td colspan="5" align="center" width="100%" height="25px">
							<h5>Signed:
							</h5>
						</td>
						<td colspan="6" align="center" width="100%" height="25px">
							<h5>Date:
							</h5>
						</td>
					</tr>
					<tr>
						<td colspan="9" width="100%">
							<h4 >
							<xsl:text>This Test Record and any data contained within it are proprietary to Waters Corporation and must be retained by Waters for the time period prescribed in its Quality Records Retention Policy.  If any of the individual tests noted above fail, a note must be referenced that details the work performed to correct that specific deficiency.  An overall failure indicates a special circumstance in which case a complete retest is to be done.  A second form is required to document that testing.  The initial form must be attached and retained.</xsl:text>
							</h4>
						</td>
					</tr>
				</table>
			</body>
		</html>
	</xsl:template>
	<xsl:template name="OutCome">
		<xsl:param name="SQGrade"/>
		<font size="2" face="Verdana, Arial, Helvetica, sans-serif">
			<xsl:if test="contains($SQGrade, 'FAIL')">
				<xsl:attribute name="color">RED</xsl:attribute>
			</xsl:if>
			<xsl:if test="contains($SQGrade, 'PASS')">
				<xsl:attribute name="color">GREEN</xsl:attribute>
			</xsl:if>
			<xsl:if test="contains($SQGrade, 'INCOMPLETE')">
				<xsl:attribute name="color">BLUE</xsl:attribute>
			</xsl:if>
			<xsl:if test="contains($SQGrade, 'ABORTED')">
				<xsl:attribute name="color">BLACK</xsl:attribute>
			</xsl:if>
			<xsl:if test="contains($SQGrade, 'SKIPPED')">
				<xsl:attribute name="color">MAROON</xsl:attribute>
			</xsl:if>
		</font>
		<xsl:value-of select="$SQGrade"/>
	</xsl:template>
</xsl:stylesheet>