<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tm="http://www.w3.org/2006/02/wsdl/TestMetadata" exclude-result-prefixes="tm">
	<xsl:output method="html" encoding="UTF-8" indent="yes"/>
	
	<xsl:param name="DSTAMP" />
	<xsl:param name="TSTAMP" />
	<xsl:param name="TODAY" />

	<xsl:template match="/">
		<html>
			<head>
				<title>Component Model Test Results</title>
				<style type="text/css">
					body {font-family:sans-serif}
					td {border:1px solid #DDDDDD}
					.passed   {background-color:green}
					.failed   {background-color:orange}
					.disaster {background-color:red}
				</style>
			</head>
			<body>
				<h3>Component Model Test Results</h3>
				<xsl:if test="$TODAY">
					<address>
						<xsl:text>Generated </xsl:text>
						<xsl:value-of select="$TODAY" />,
						<xsl:value-of select="$TSTAMP" />
					</address>
				</xsl:if>
				<p>These results present the results of parsing "good" (e.g. valid) WSDL documents and emitting
				an XML representation of the component model.  These interchange format results are canonicalized
				to remove differences in ID-IDREF reference values and the order of elements.</p>
				<h3>Summary:</h3>
				<xsl:call-template name="interchange-results-summary"/>
				<h3>Detailed results:</h3>
				<table>
					<tr>
						<td style="text-align:center">Testcase</td>
						<td style="text-align:center">WSDL</td>
						<td style="text-align:center" colspan="{count(summary/result[1]/implementation)}">Failures</td>
					</tr>
					<tr>
						<td colspan="2"/>
						<xsl:for-each select="summary/result[1]/implementation">
							<td><strong><xsl:value-of select="@vendor"/></strong></td>
						</xsl:for-each>
					</tr>
					<xsl:for-each select="summary/result">
						<tr>
							<td><xsl:value-of select="@name"/></td>
							<td><xsl:value-of select="@testcase"/></td>
							<xsl:for-each select="implementation">
								<td style="width:6em">
									<xsl:choose>
										<xsl:when test="@result='none'"><span style="font-size:x-small">none supplied</span></xsl:when>
										<xsl:when test="@result='unsupported'"><span style="font-size:x-small">unsupported extension</span></xsl:when>
										<xsl:otherwise>
											<xsl:choose>
												<xsl:when test="@failures = 0"><xsl:attribute name="class">passed</xsl:attribute></xsl:when>
												<xsl:when test="@failures &lt; 6"><xsl:attribute name="class">failed</xsl:attribute></xsl:when>
												<xsl:otherwise><xsl:attribute name="class">disaster</xsl:attribute></xsl:otherwise>
											</xsl:choose>
											<xsl:value-of select="@failures"/>
											[<a href="{@log}?content-type=application/xml">log</a>]
										</xsl:otherwise>
									</xsl:choose>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</table>
			</body>
		</html>
	</xsl:template>
	<xsl:template name="interchange-results-summary">
		<table>
			<tr>
				<xsl:for-each select="summary/result[1]/implementation">
					<td><strong><xsl:value-of select="@vendor"/></strong></td>
				</xsl:for-each>
			</tr>
			<tr>
				<xsl:for-each select="summary/result[1]/implementation">
					<td style="border:1px solid black; padding:0px; width:201px; height:18px; font-size:x-small; font-weight:bold">
						<xsl:variable name="total" select="count(/summary/result)"/>
						<xsl:variable name="passed" select="count(/summary/result/implementation[@vendor=current()/@vendor][@result='passed'])"/>
						<xsl:variable name="failed" select="count(/summary/result/implementation[@vendor=current()/@vendor][@result='failed'])"/>
						<xsl:variable name="percentage-passed" select="$passed div $total"/>
						<xsl:variable name="percentage-failed" select="$failed div $total"/>
						<xsl:if test="$percentage-passed > .01">
							<span style="position:absolute"><xsl:value-of select="$passed"/></span>
							<img src="green.gif" height="16" width="{round(200*$percentage-passed)}" alt="{round($percentage-passed * 100)}% passed"/>
						</xsl:if>
						<xsl:if test="$percentage-failed > .01">
							<span style="position:absolute"><xsl:value-of select="$failed"/></span>
							<img src="red.gif" height="16" width="{round(200*$percentage-failed)}" alt="{round($percentage-failed * 100)}% failed"/>
						</xsl:if>
					</td>
				</xsl:for-each>
			</tr>
		</table>
	</xsl:template>
</xsl:stylesheet>
