<?xml version='1.0' encoding='UTF-8' ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
	<xsl:decimal-format name="european" decimal-separator=',' grouping-separator='.' />
	<xsl:template match='/'>
		<html>
			<head>
				<title>Jetstress <xsl:value-of select="/output/@type"/> Test Result Report</title>
				<style type='text/css'>

					LEGEND
					{
					font-family: Verdana; font-size: 10pt; color: #FF3300;
					}

					H1, H2, H3, H4, H5, H6
					{
					font-family: Microsoft Sans Serif; font-size: 18pt; font-weight: normal;
					}

					H1
					{
					background-color: #D1D2D3;
					}

					.highlighted
					{
					color: #FF3300;
					}

					td
					{
					font-family: Verdana; font-size: 10pt; vertical-align: top; align: left;
					}

					td.invisible
					{
					font-family: Verdana; font-size: 10pt; color: #FFFFFF; vertical-align: top; align: left; background-color:#FFFFFF;
					}

					td.grid_row_header
					{
					font-family: Verdana; font-size: 10pt; font-weight: bold; vertical-align: top; align: left;
					}

					tr.grid_alternating_row
					{
					background-color:#DDDDDD;
					}

					tr.grid_column_header
					{
					background-color: #FFCEC1;
					}

					tr.grid_column_header
					{
					background-color: #FFCEC1;
					}

					td.grid_cell_border
					{
					border-right: thin solid #000000;
					}

					.failure
					{
					font-family: Verdana; font-size: 10pt; font-weight: bold; color: #FF0000;
					}

					.warning
					{
					font-family: Verdana; font-size: 10pt; font-weight: bold; color: #B9B900;
					}

					.success
					{
					font-family: Verdana; font-size: 10pt; font-weight: bold; color: #008000;
					}

					.verbose
					{
					font-family: Verdana; font-size: 9pt;
					}

				</style>
			</head>
			<body>

				<h1>Microsoft Exchange Server <span class="highlighted">Jetstress</span></h1>
				<h2><xsl:value-of select="/output/@type"/> Test Result Report</h2>
				
				<xsl:if test='count(/output/test-summary) != 0'>
					<fieldset>
						<legend>Test Summary</legend>
						<xsl:apply-templates select = '/output/test-summary'/>
					</fieldset>
					<br/>
				</xsl:if>

				<xsl:if test='count(/output/test-issues/element) != 0'>
					<fieldset>
						<legend>Test Issues</legend>
						<xsl:apply-templates select = '/output/test-issues'/>
					</fieldset>
					<br/>
				</xsl:if>

				<xsl:if test='count(/output/backup-stats-all/backup-stats) != 0'>
					<fieldset>
						<legend>Streaming Backup Statistics - All</legend>
						<xsl:apply-templates select = '/output/backup-stats-all'/>
					</fieldset>
					<br/>
				</xsl:if>

				<xsl:if test='count(/output/soft-recovery-stats-all/soft-recovery-stats) != 0'>
					<fieldset>
						<legend>Soft-Recovery Statistics - All</legend>
						<xsl:apply-templates select = '/output/soft-recovery-stats-all'/>
					</fieldset>
					<br/>
				</xsl:if>
				
				<xsl:if test='count(/output/database-sizing) != 0'>
					<fieldset>
						<legend>Database Sizing and Throughput</legend>
						<xsl:apply-templates select = '/output/database-sizing'/>
					</fieldset>
					<br/>
				</xsl:if>
				
				<xsl:if test='count(/output/jetstress-system) != 0'>
					<fieldset>
						<legend>Jetstress System Parameters</legend>
						<xsl:apply-templates select = '/output/jetstress-system'/>
					</fieldset>
					<br/>
				</xsl:if>
				
				<xsl:if test='count(/output/disk-subsystem) != 0'>
					<fieldset>
						<legend>Disk Subsystem Performance</legend>
						<xsl:apply-templates select = '/output/disk-subsystem'/>
					</fieldset>
					<br/>
				</xsl:if>

				<xsl:if test='count(/output/host-system) != 0'>
					<fieldset>
						<legend>Host System Performance</legend>
						<xsl:apply-templates select = '/output/host-system'/>
						</fieldset>
					<br/>
				</xsl:if>

				<xsl:if test='count(/output/checksum-stats-all/checksum-stats) != 0'>
					<fieldset>
						<legend>Checksum Statistics - All</legend>
						<xsl:apply-templates select = '/output/checksum-stats-all'/>
					</fieldset>
					<br/>
				</xsl:if>

				<xsl:if test='count(/output/disk-subsystem-of-checksum) != 0'>
					<fieldset>
						<legend>Disk Subsystem Performance (of checksum)</legend>
						<xsl:apply-templates select = '/output/disk-subsystem-of-checksum'/>
					</fieldset>
					<br/>
				</xsl:if>
				
				<xsl:if test='count(/output/memory-system-of-checksum) != 0'>
					<fieldset>
						<legend>Memory System Performance (of checksum)</legend>
						<xsl:apply-templates select = '/output/memory-system-of-checksum'/>
					</fieldset>
					<br/>
				</xsl:if>
				
				<xsl:if test='count(/output/test-log) != 0'>
					<fieldset>
						<legend>Test Log</legend>
						<span class="verbose">
							<xsl:value-of select = "/output/test-log" disable-output-escaping = "yes"/>
						</span>
					</fieldset>
					<br/>
				</xsl:if>

			</body>
		</html>
	</xsl:template>

	<xsl:template match = 'soft-recovery-stats-all'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<tr class ='grid_column_header'>
				<td class ='grid_cell_border'>Database Instance</td>
				<td class ='grid_cell_border'>Log files replayed</td>
				<td class ='grid_cell_border'>Elapsed seconds</td>
			</tr>
			<xsl:for-each select='./soft-recovery-stats'>
				<tr>
					<xsl:choose>
						<xsl:when test='position() mod 2 = 0'>
							<xsl:attribute name='class'>grid_alternating_row</xsl:attribute>
						</xsl:when>
					</xsl:choose>
					<td class ='grid_row_header grid_cell_border'>
						<xsl:value-of select = '@display-name'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@log-files-replayed'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@elapsed-time'/>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>
	
	<xsl:template match = 'backup-stats-all'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<tr class ='grid_column_header'>
				<td class ='grid_cell_border'>Database Instance</td>
				<td class ='grid_cell_border'>Database Size (MBytes)</td>
				<td class ='grid_cell_border'>Elapsed Backup Time</td>
				<td class ='grid_cell_border'>MBytes Transferred/sec</td>
			</tr>
			<xsl:for-each select='./backup-stats'>
				<tr>
					<xsl:choose>
						<xsl:when test='position() mod 2 = 0'>
							<xsl:attribute name='class'>grid_alternating_row</xsl:attribute>
						</xsl:when>
					</xsl:choose>
					<td class ='grid_row_header grid_cell_border'>
						<xsl:value-of select = '@display-name'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@instance-size'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@backup-time'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@transfer-rate'/>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template match = 'checksum-stats-all'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<tr class ='grid_column_header'>
				<td class ='grid_cell_border'>Database</td>
				<td class ='grid_cell_border'>Seen pages</td>
				<td class ='grid_cell_border'>Bad pages</td>
				<td class ='grid_cell_border'>Correctable pages</td>
				<td class ='grid_cell_border'>Wrong page no pages</td>
				<td class ='grid_cell_border'>File length / seconds taken</td>
			</tr>
			<xsl:for-each select='./checksum-stats'>
				<tr>
					<xsl:choose>
						<xsl:when test='position() mod 2 = 0'>
							<xsl:attribute name='class'>grid_alternating_row</xsl:attribute>
						</xsl:when>
					</xsl:choose>
					<td class ='grid_row_header grid_cell_border'>
						<xsl:value-of select = '@display-name'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@seen-pages'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@bad-pages'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@correctable-pages'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@wrong-pgno-pages'/>
					</td>
					<td class ='grid_cell_border'>
						<xsl:value-of select = '@mbytes-per-sec'/>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template match = 'memory-system-of-checksum'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<tr class ='grid_column_header'>
				<td class ='grid_row_header grid_cell_border'>Counter</td>
				<td class ='grid_cell_border'>Average</td>
				<td class ='grid_cell_border'>Minimum</td>
				<td class ='grid_cell_border'>Maximum</td>
			</tr>
			<xsl:for-each select = './/instance'>
				<tr>
					<xsl:choose>
						<xsl:when test='position() mod 2 = 0'>
							<xsl:attribute name='class'>grid_alternating_row</xsl:attribute>
						</xsl:when>
					</xsl:choose>
					<td class='grid_row_header grid_cell_border'>
						<xsl:value-of select = '../@name'/>
					</td>
					<td>
						<xsl:attribute name='class'>
							<xsl:value-of select='@class'/> grid_cell_border
						</xsl:attribute>
						<xsl:choose>
							<xsl:when test='format-number(@average, "0.000")!="NaN"'>
								<xsl:value-of select = 'format-number(@average, "0.000")'/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select = '@average'/>
							</xsl:otherwise>
						</xsl:choose>						
					</td>
					<td>
						<xsl:attribute name='class'>
							<xsl:value-of select='@class'/> grid_cell_border
						</xsl:attribute>
						<xsl:choose>
							<xsl:when test='format-number(@minimum, "0.000")!="NaN"'>
								<xsl:value-of select = 'format-number(@minimum, "0.000")'/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select = '@minimum'/>
							</xsl:otherwise>
						</xsl:choose>						
					</td>
					<td>
						<xsl:attribute name='class'>
							<xsl:value-of select='@class'/> grid_cell_border
						</xsl:attribute>
						<xsl:choose>
							<xsl:when test='format-number(@maximum, "0.000")!="NaN"'>
								<xsl:value-of select = 'format-number(@maximum, "0.000")'/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select = '@maximum'/>
							</xsl:otherwise>
						</xsl:choose>					
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template match = 'disk-subsystem-of-checksum'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<xsl:for-each select = 'object'>
				<xsl:for-each select = 'instance[count(counter) &gt; 3]'>
					<xsl:if test='position()=1'>
						<tr class ='grid_column_header'>
							<td class='grid_row_header grid_cell_border'>
								<xsl:value-of select = '../@name'/>
							</td>
							<xsl:for-each select = 'counter'>
								<td class ='grid_cell_border'>
									<xsl:choose>
										<xsl:when test='@display-name'>
											<xsl:value-of select = '@display-name'/>
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select = '@name'/>
										</xsl:otherwise>
									</xsl:choose>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:if>
				</xsl:for-each>
				<xsl:for-each select = 'instance'>
					<tr>
						<xsl:choose>
							<xsl:when test='position() mod 2 = 0'>
								<xsl:attribute name='class'>grid_alternating_row</xsl:attribute>
							</xsl:when>
						</xsl:choose>
						<td class='grid_row_header grid_cell_border'>
							<xsl:choose>
								<xsl:when test='@display-name'>
									<xsl:value-of select = '@display-name'/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select = '@name'/>
								</xsl:otherwise>
							</xsl:choose>
						</td>
						<xsl:for-each select = 'counter'>
							<td>
								<xsl:attribute name='class'><xsl:value-of select='@class'/> grid_cell_border</xsl:attribute>
								<xsl:choose>
									<xsl:when test='format-number(@average, "0.000")!="NaN"'>
										<xsl:value-of select = 'format-number(@average, "0.000")'/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select = '@average'/>
									</xsl:otherwise>
								</xsl:choose>
							</td>
						</xsl:for-each>
					</tr>
				</xsl:for-each>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template match = 'test-issues'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<xsl:for-each select = 'element'>
				<tr>
					<td class='grid_row_header'>
						<xsl:if test='@class'>
							<xsl:attribute name='class'><xsl:value-of select='@class'/> grid_row_header</xsl:attribute>
						</xsl:if>
						<xsl:value-of select = '@issue'/>
					</td>
					<td>
						<xsl:value-of select = '@value' disable-output-escaping = "yes"></xsl:value-of>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>
	
	<xsl:template match = 'test-summary'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<xsl:for-each select = 'element'>
				<tr>
					<td class='grid_row_header'>
						<xsl:value-of select = '@name'/>
					</td>
					<td>
						<xsl:if test='@class'>
							<xsl:attribute name='class'><xsl:value-of select='@class'/></xsl:attribute>
						</xsl:if>
						<xsl:choose>
							<xsl:when test='boolean(number(@value))'>
								<xsl:value-of select = 'format-number(@value,"0.###")'></xsl:value-of>
							</xsl:when >
							<xsl:otherwise>
								<xsl:value-of select = '@value' disable-output-escaping = "yes"></xsl:value-of>
							</xsl:otherwise>
						</xsl:choose>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>
	
	<xsl:template match = 'database-sizing'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<xsl:for-each select = 'element'>
				<tr>
					<td class='grid_row_header'>
						<xsl:value-of select = '@name'/>
					</td>
					<td>
						<xsl:choose>
							<xsl:when test='boolean(number(@value))'>
								<xsl:value-of select = 'format-number(@value,"0.###")'></xsl:value-of>
							</xsl:when >
							<xsl:otherwise>
								<xsl:value-of select = '@value'></xsl:value-of>
							</xsl:otherwise>
						</xsl:choose>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>
	
	<xsl:template match = 'jetstress-system'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<xsl:for-each select = 'element'>
				<tr>
					<td class='grid_row_header'>
						<xsl:value-of select = '@name'/>
					</td>
					<td>
						<xsl:value-of select = '@value'/>
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template match = 'host-system'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<tr class ='grid_column_header'>
				<td class ='grid_row_header grid_cell_border'>Counter</td>
				<td class ='grid_cell_border'>Average</td>
				<td class ='grid_cell_border'>Minimum</td>
				<td class ='grid_cell_border'>Maximum</td>
			</tr>
			<xsl:for-each select = './/instance'>
				<tr>
					<xsl:choose>
						<xsl:when test='position() mod 2 = 0'>
							<xsl:attribute name='class'>grid_alternating_row</xsl:attribute>
						</xsl:when>
					</xsl:choose>
					<td class='grid_row_header grid_cell_border'>
						<xsl:value-of select = '../@name'/>
					</td>
					<td>
						<xsl:attribute name='class'><xsl:value-of select='@average-class'/> grid_cell_border</xsl:attribute>
						<xsl:choose>
							<xsl:when test='format-number(@average, "0.000")!="NaN"'>
								<xsl:value-of select = 'format-number(@average, "0.000")'/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select = '@average'/>
							</xsl:otherwise>
						</xsl:choose>	
					</td>
					<td>
						<xsl:attribute name='class'><xsl:value-of select='@minimum-class'/> grid_cell_border</xsl:attribute>
						<xsl:choose>
							<xsl:when test='format-number(@minimum, "0.000")!="NaN"'>
								<xsl:value-of select = 'format-number(@minimum, "0.000")'/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select = '@minimum'/>
							</xsl:otherwise>
						</xsl:choose>	
					</td>
					<td>
						<xsl:attribute name='class'><xsl:value-of select='@maximum-class'/> grid_cell_border</xsl:attribute>
						<xsl:choose>
							<xsl:when test='format-number(@maximum, "0.000")!="NaN"'>
								<xsl:value-of select = 'format-number(@maximum, "0.000")'/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select = '@maximum'/>
							</xsl:otherwise>
						</xsl:choose>	
					</td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template match = 'disk-subsystem'>
		<table border='0' cellspacing='0' cellpadding='2'>
			<xsl:for-each select = 'object'>
				<xsl:for-each select = 'instance[count(counter) &gt; 4]'>
					<xsl:if test='position()=1'>
						<tr class ='grid_column_header'>
							<td class='grid_row_header grid_cell_border'>
								<xsl:value-of select = '../@name'/>
							</td>
							<xsl:for-each select = 'counter'>
								<td class ='grid_cell_border'>
									<xsl:choose>
										<xsl:when test='@display-name'>
											<xsl:value-of select = '@display-name'/>
										</xsl:when>
										<xsl:otherwise>
											<xsl:value-of select = '@name'/>
										</xsl:otherwise>
									</xsl:choose>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:if>
				</xsl:for-each>
				<xsl:for-each select = 'instance'>
					<tr>
						<xsl:choose>
							<xsl:when test='position() mod 2 = 0'>
								<xsl:attribute name='class'>grid_alternating_row</xsl:attribute>
							</xsl:when>
						</xsl:choose>
						<td class='grid_row_header grid_cell_border'>
							<xsl:choose>
								<xsl:when test='@display-name'>
									<xsl:value-of select = '@display-name'/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select = '@name'/>
								</xsl:otherwise>
						</xsl:choose>
						</td>
						<xsl:for-each select = 'counter'>
							<td>
								<xsl:attribute name='class'><xsl:value-of select='@class'/> grid_cell_border</xsl:attribute>
								<xsl:choose>
									<xsl:when test='format-number(@average, "0.000")!="NaN"'>
										<xsl:value-of select = 'format-number(@average, "0.000")'/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select = '@average'/>
									</xsl:otherwise>
								</xsl:choose>
							</td>
						</xsl:for-each>
						<xsl:if test='count(counter) &lt; 5'>
							<td class ='grid_cell_border'>(n/a)</td>
						</xsl:if>
					</tr>
				</xsl:for-each>
			</xsl:for-each>
		</table>
	</xsl:template>
	
</xsl:stylesheet>