<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" media-type="text/html"  indent="yes" encoding="utf-8"/>
  <xsl:param name="APP_ROOT" select="'http://localhost:8080/SigmaSure'"/>
  <xsl:param name="UNIT_REPORT_ID" select="'1'"/>
  <xsl:template match="/">
    <html>
      <head>
      <!-- Put css stuff here -->
        <style>
          .TableHeader {
          font-family: Arial;
          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;
          color: #000000;
          font-weight: 900;
          }
          .TableHeaderL {
          font-family: Arial;
          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;
          color: #000000;
          font-weight: 900;
          }
          .TableHeaderC {
          font-family: Arial;
          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;
          color: #000000;
          font-weight: 900;
          }
          h1 {
          text-align:center;
          font-size:18pt;
          }
          h2 {
          font-family:Arial;
          font-weight:400;
          font-size:12pt;
          }
          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: Arial;
          font-size: 24pt;
          border-style: solid;
          font-weight: normal;
          text-align: left;
          border-width: thin;
          vertical-align: top;
          }
          h6 {
          border-style: none;
          border-width: thin;
          border-color: #000000;
          text-align: left;
          font-family: Arial;
          font-size: 18pt;
          font-weight: bold;
          }
          .ItemName {
          font-family: Arial;
          font-size: 10pt;
          font-weight: bold;
          }
          .SubItemName {
          font-family: Arial;
          font-size: 10pt;
          font-weight: normal;
          }
          .outCome {
          font-family: Arial;
          font-size: 10pt;
          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;
          }
          .suboutCome{
          font-family: Arial;
          font-size: 10pt;
          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;
          }
        </style>
      </head>
      <body>
        <h1>Waters Corporation - Test Record</h1>
        <table border="3" width="100%">
          <td>
            <table border="0" width="100%" colspan="4">
              <tr>
                <td colspan="160">
                  <h2>
                    Part Number: <U>
                      <xsl:value-of select="/UnitReport/Category/Product/@part-no"/>
                    </U>
                  </h2>
                </td>
                <td colspan="40">
                  <h2>
                    Product: <U>
                      <xsl:value-of select="/UnitReport/Category/Product/@name"/>
                    </U>
                  </h2>
                </td>
              </tr>
              <tr>
                <td colspan="160">
                  <h2>
                    Operator: <U>
                      <xsl:value-of select="/UnitReport/Operator/@name"/>
                    </U>
                  </h2>
                </td>
                <td colspan="40">
                  <h2>
                    Start Time:
                    <U>
                      <xsl:variable name="start-time" select="/UnitReport/@start-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="100">
                  <h2>
                    Serial Number: <U>
                      <xsl:value-of select="/UnitReport/Category/Product/@serial-no"/>
                    </U>
                  </h2>
                </td>
              </tr>
            </table>
          </td>
        </table>
        <table>
          <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>
        
        
          <!-- TEST RUNS -->        
        
          <table cellspacing="0" width="100%" class="table" border="0">
             <!-- Table header -->
             <tr align="left">
               <td class="TableHeaderL">Name</td>
               <td class="TableHeaderC">LSL</td>
               <td class="TableHeaderC">Measurement</td>
               <td class="TableHeaderC">USL</td>
               <td class="TableHeaderC">Unit</td>
               <td class="TableHeaderC">&#160;&#160;&#160;&#160;Outcome&#160;&#160;&#160;&#160;</td>
             </tr>
          <xsl:for-each select="UnitReport/TestRun/*">
            <xsl:choose>
              <!-- Don't show failed Noise and Drift Tests-->
              <xsl:when test="(@name='Noise' or @name='Drift')"/>  
              <!-- Don't show tests we want to omit-->
              <xsl:when test="node()='Omit'"/>
           <xsl:otherwise>
            <tr>
            <xsl:choose>
              <xsl:when test="node()=Result or not(node())">
                <!--This is Bold Upper Level Test Run-->
                <!-- Test Name  -->
                <xsl:if test="string-length(./Result/Property/ValueDouble/@name)>0">
                  <td class="ItemName" align="left">
                    <xsl:value-of select="./Result/Property/ValueDouble/@name"/>
                  </td>
                </xsl:if>
                <xsl:if test="string-length(./Result/ValueDouble/@name)>0">

                  <xsl:choose>
                  <xsl:when test="./Result/ValueDouble/@name='Ro'">
                    <td class="ItemName" align="left">
                      PMT Coefficient
                    </td>
                   </xsl:when>
                    <xsl:otherwise>
                  <td class="ItemName" align="left">
                    <xsl:value-of select="./Result/ValueDouble/@name"/>
                  </td>
                    </xsl:otherwise>
                  </xsl:choose>

                  </xsl:if>
                <xsl:if test="string-length(./Result/Property/ValueString/@name)>0">
                  <td class="ItemName" align="left">
                    <xsl:value-of select="./Result/Property/ValueString/@name"/>
                  </td>
                </xsl:if>
                <xsl:if test="string-length(./Result/ValueString/@name)>0">
                  <td class="ItemName" align="left">
                    <xsl:value-of select="./Result/ValueString/@name"/>
                  </td>
                </xsl:if>
                <xsl:if test="string-length(./Result/Property/ValueBoolean/@name)>0">
                  <td class="ItemName" align="left">
                    <xsl:value-of select="./Result/Property/ValueBoolean/@name"/>
                  </td>
                </xsl:if>
                <xsl:if test="string-length(./Result/ValueBoolean/@name)>0">
                  <td class="ItemName" align="left">
                    <xsl:value-of select="./Result/ValueBoolean/@name"/>
                  </td>
                </xsl:if>

                <xsl:if test="string-length(./Result/Property/ValueInteger/@name)>0">
                  <td class="ItemName" align="left">
                    <xsl:value-of select="./Result/Property/ValueInteger/@name"/>
                  </td>
                </xsl:if>

                <xsl:if test="string-length(./Result/ValueInteger/@name)>0">
                  <td class="ItemName" align="left">
                    <xsl:value-of select="./Result/ValueInteger/@name"/>
                  </td>
                </xsl:if>
                
                <!-- Test has no reults -->
                <xsl:if test="not(node())">
                  <td class="ItemName" align="left">
                    <xsl:value-of select="@name"/>
                  </td>
                </xsl:if>
                <!-- LSL -->
                <xsl:choose>
                  <xsl:when test="string-length(./Result/Property/ValueDouble/@lsl)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/Property/ValueDouble/@lsl"/>
                    </td>
                  </xsl:when>

                  <xsl:when test="string-length(./Result/ValueDouble/@lsl)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/ValueDouble/@lsl"/>
                    </td>
                  </xsl:when>

                  <xsl:when test="string-length(./Result/Property/ValueInteger/@lsl)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/Property/ValueInteger/@lsl"/>
                    </td>
                  </xsl:when>

                  <xsl:when test="string-length(./Result/ValueInteger/@lsl)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/ValueInteger/@lsl"/>
                    </td>
                  </xsl:when>
                  
                  <xsl:otherwise>
                    <td></td>
                  </xsl:otherwise>
                </xsl:choose>
                <!-- Meas -->
                <xsl:if test="string-length(node()[1])>0">
                  <td class="ItemName" align="center">
                    <xsl:value-of select="node()[1]"/>
                  </td>
                </xsl:if>
                <xsl:if test="string-length(node()[1])=0">
                  <td></td>
                </xsl:if>
                <!-- USL  -->
                <xsl:choose>
                  <xsl:when test="string-length(./Result/Property/ValueDouble/@usl)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/Property/ValueDouble/@usl"/>
                    </td>
                  </xsl:when>
                  <xsl:when test="string-length(./Result/ValueDouble/@usl)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/ValueDouble/@usl"/>
                    </td>
                  </xsl:when>
                  <xsl:when test="string-length(./Result/Property/ValueInteger/@usl)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/Property/ValueInteger/@usl"/>
                    </td>
                  </xsl:when>
                  <xsl:when test="string-length(./Result/ValueInteger/@usl)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/ValueInteger/@usl"/>
                    </td>
                  </xsl:when>
               <xsl:otherwise>
                    <td></td>
                  </xsl:otherwise>
                </xsl:choose>
                <!-- UOM  -->
                <xsl:choose>
                  <xsl:when test="string-length(./Result/Property/ValueDouble/@uom)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/Property/ValueDouble/@uom"/>
                    </td>
                  </xsl:when>
                  <xsl:when test="string-length(./Result/ValueDouble/@uom)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/ValueDouble/@uom"/>
                    </td>
                  </xsl:when>
                  <xsl:when test="string-length(./Result/Property/ValueInteger/@uom)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/Property/ValueInteger/@uom"/>
                    </td>
                  </xsl:when>
                  <xsl:when test="string-length(./Result/ValueInteger/@uom)>0">
                    <td class="ItemName" align="center">
                      <xsl:value-of select="./Result/ValueInteger/@uom"/>
                    </td>
                  </xsl:when>
               <xsl:otherwise>
                    <td></td>
                  </xsl:otherwise>
                </xsl:choose>
                <!-- Grade  -->
                <xsl:if test="string-length(./@grade)>0">
                  <td class="outCome" align="left">
                    <xsl:value-of select="./@grade"/>
                  </td>
                </xsl:if>
              </xsl:when>  <!-- when uppper level test-->
             <xsl:otherwise>
                <!--This is sub test with name and result in Bold on top-->
                <td class="ItemName">
                  <xsl:value-of select="@name"/>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td class="outCome" align="left">
                    <xsl:value-of select="@grade"/>
                  </td>
                </td>
                <tr></tr>
                <!-- SubTests -->
                <xsl:for-each select="(.)/TestRun">
                  <xsl:choose>
                    <!-- Don't show failed Noise and Drift Tests-->
                    <xsl:when test="(@name='Noise' or @name='Drift')"/>
                    <!-- Don't show tests we want to omit-->
                    <xsl:when test="node()='Omit'"/>
                  <xsl:otherwise>
                      <tr>
                        <td class="SubItemName">
                          &#160;&#160;&#160;&#160;<xsl:value-of select="@name"/>
                        </td>
                        <!-- sub LSL -->
                        <xsl:choose>
                          <xsl:when test="string-length(Result/Property/ValueDouble/@lsl)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/Property/ValueDouble/@lsl"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/ValueDouble/@lsl)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/ValueDouble/@lsl"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/Property/ValueInteger/@lsl)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/Property/ValueInteger/@lsl"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/ValueInteger/@lsl)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/ValueInteger/@lsl"/>
                            </td>
                          </xsl:when>
                          <xsl:otherwise>
                            <td></td>
                          </xsl:otherwise>
                        </xsl:choose>
                        <!-- Sub Meas  -->
                        <xsl:if test="string-length(node()[1])>0">
                          <td class="SubItemName" align="center">
                            <xsl:value-of select="node()[1]"/>
                          </td>
                        </xsl:if>
                        <xsl:if test="string-length(node()[1])=0">
                          <td></td>
                        </xsl:if>
                        <!-- sub USL -->
                        <xsl:choose>

                          <xsl:when test="string-length(Result/Property/ValueDouble/@usl)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/Property/ValueDouble/@usl"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/ValueDouble/@usl)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/ValueDouble/@usl"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/Property/ValueInteger/@usl)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/Property/ValueInteger/@usl"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/ValueInteger/@usl)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/ValueInteger/@usl"/>
                            </td>
                          </xsl:when>
                          <xsl:otherwise>
                            <td></td>
                          </xsl:otherwise>
                        </xsl:choose>
                        <!-- Sub uom  -->
                        <xsl:choose>
                          <xsl:when test="string-length(Result/Property/ValueDouble/@uom)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/Property/ValueDouble/@uom"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/ValueDouble/@uom)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/ValueDouble/@uom"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/Property/ValueInteger/@uom)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/Property/ValueInteger/@uom"/>
                            </td>
                          </xsl:when>

                          <xsl:when test="string-length(Result/ValueInteger/@uom)>0">
                            <td class="SubItemName" align="center">
                              <xsl:value-of select="Result/ValueInteger/@uom"/>
                            </td>
                          </xsl:when>

                          <xsl:otherwise>
                            <td></td>
                          </xsl:otherwise>
                        </xsl:choose>
                        <!-- Grade  -->
                        <xsl:if test="string-length(@grade)>0">
                          <td class="outCome" align="left">
                            &#160;&#160;&#160;&#160;<xsl:value-of select="@grade"/>
                          </td>
                        </xsl:if>
                      </tr>
                    </xsl:otherwise> <!-- end of check for noise, drift, or Omit-->
                  </xsl:choose> <!--goes with the otherwise right above this-->
                 </xsl:for-each> <!-- with for each test run-->
              </xsl:otherwise>
              <!-- end of sub test-->
            </xsl:choose>
            <!--big choice sub or no-->
            </tr>
              </xsl:otherwise> <!-- with if noise or drift or Omit-->
            </xsl:choose>  <!-- with if noise or drift or Omit-->
          </xsl:for-each>
        </table>
        
        <tr>
          <td>
            <br></br>
          </td>
        </tr>

        <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>
       

        

        <table width="100%">
          <tr>
            <td align="center">
              <h5>
                Signed:
              </h5>
            </td>
            <td align="center">
              <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:stylesheet>
			
	
