<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:param name="DSTAMP"/>
    <xsl:param name="TSTAMP"/>
    <xsl:param name="TODAY"/>
    <xsl:output method="html" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <html>
            <head>
                <title>Web Services Policy 1.5 CR Dashboard</title>
                <link rel="stylesheet" type="text/css"
                    href="http://www.w3.org/Guide/pubrules-style.css"/>
                <link rel="stylesheet" type="text/css"
                    href="http://www.w3.org/2006/02/charter-style.css"/>
                <style type="text/css"> body {font-family:sans-serif} td {vertical-align:top}
                    .passed {background-color:green} .failed {background-color:orange} .disaster
                    {background-color:red} .border th, .border td { border: 1px solid black;
                    padding: 0.5ex } .border th { background: #ccc } .good { background: green }
                    .bad { background: red } .group {background-color:#DDD} .heading
                    {font-weight:bold; white-space: nowrap} .explanatory {font-size:smaller}
                    .results {border:1px solid black; padding:0px; width:100px; height:18px; font-size:x-small; font-weight:bold;}
                </style>
            </head>
            <body>
                <p class="navicons"><a href="../../../"><img src="http://www.w3.org/Icons/w3c_home"
                    alt="W3C" height="48" width="72" /> </a><xsl:text>  </xsl:text><a
                        href="http://www.w3.org/Architecture/"><img src="http://www.w3.org/Icons/arch"
                            alt="Architecture Domain" height="48" width="212" /> </a><xsl:text>  </xsl:text><a href="http://www.w3.org/2002/ws/"><img
                                src="http://www.w3.org/2002/ws/3/04/diags/wsa.png" width="192" height="48"
                                alt="Web Services Activity" /> </a></p>

                <p class="navlinks"><a href="http://www.w3.org/2002/ws/policy">About Web Services Policy WG</a></p>
                <h1>Web Services Policy 1.5 CR Dashboard</h1>
                <xsl:if test="$TODAY">
                    <address>
                        <xsl:text>Generated </xsl:text>
                        <xsl:value-of select="$TODAY"/>,
                        <xsl:value-of select="$TSTAMP"/>
                    </address>
                </xsl:if>
                <p class="explanatory">The dashboard summarizes the results of unit and interop
                    testing of the <a href="http://www.w3.org/TR/ws-policy">Web Services Policy 1.5
                        - Framework</a> and <a href="http://www.w3.org/TR/ws-policy-attach">Web
                        Services Policy 1.5 - Attachment</a> specifications, in fulfillment of the
                    CR exit criteria (<a
                        href="http://www.w3.org/TR/2007/CR-ws-policy-20070228/#status">Framework</a>
                    and <a href="http://www.w3.org/TR/2007/CR-ws-policy-attach-20070228/#status"
                        >Attachment</a>). <a
                        href="http://dev.w3.org/cvsweb/~checkout~/2006/ws/policy/interop/">Interop
                        scenarios and test files</a> are on the W3C CVS archive. </p>
                <p></p>
                <hr color="#C0C0C0"></hr>
                <h2 id="implementers">Implementers</h2>
                <p>Testing is based on implementations (in alphabetical order) from:</p>
                <table border="2" bordercolorlight="#000000"
                    bordercolordark="#000000" style="border-collapse: collapse" cellpadding="5">
                    <tr>
                    <xsl:for-each select="document('temp-participants.xml')/participants/participant">
                        <xsl:sort select="organization"/>
                        <xsl:call-template name="generate-participant-rows"/>
                    </xsl:for-each>
                    </tr>
                </table>
                <p></p>
                <hr color="#C0C0C0"></hr>

            <h2 id="unit">CR Test Results</h2>
        	<p><xsl:value-of select="description"/> The following table enumerates
            results from implementers based on running the various rounds of CR tests; both unit and pair-wise interoperability. Green indicates a
            successful outcome, red indicates a failure and no color indicates 'no claims'. Detail results can be found <a href="http://dev.w3.org/cvsweb/~checkout~/2006/ws/policy/interop/results/dashboard.html">here</a>.</p>

                <table border="2" bordercolorlight="#000000"
                    bordercolordark="#000000" style="border-collapse: collapse" cellpadding="5">
                    <tr>
                        <th class="results">Organization</th>
                        <th class="results">Round 1 Results</th>
                        <th class="results">Round 2 WSDL1.1 Results</th>
                        <th class="results">Round 2 WSDL2.0 Results</th>
                        <th class="results">Round 3 WSDL1.1 Results</th>
                        <th class="results">Round 3 WSDL2.0 Results</th>
                        <th class="results">Round 4 UDDI Results</th>
                        <th class="results">Round 4 External WSDL1.1 Results</th>
                        <th class="results">Round 4 External WSDL2.0 Results</th>
                        <th class="results">Round 4 MediaType Results</th>
                        <th class="results">Round 4 Negative Test Results</th>
                    </tr>
                    <xsl:for-each select="document('temp-participants.xml')/participants/participant">
                        <xsl:sort select="organization"/>
                        <xsl:call-template name="generate-participant-results"/>
                    </xsl:for-each>
                </table>

            </body>
        </html>
    </xsl:template>

    <xsl:template name="generate-column-with-hyperlink">
        <xsl:param name="name"/>
        <td><a href="#{$name}"><xsl:value-of select="$name"/></a></td>
    </xsl:template>

    <xsl:template name="generate-participant-rows">
            <xsl:variable name="organization" select="organization"/>
            <td id="{$organization}"><xsl:value-of select="organization"/></td>
    </xsl:template>

	<xsl:template match="/results">
            <td><xsl:value-of select="count(result/passed[text()='true'])"/>
            of <xsl:value-of select="count(result/passed[text()!='tbd'])"/></td>
	</xsl:template>
	
	<xsl:template name="generate-column">
		<xsl:param name="file"/>
		<xsl:variable name="pass" select="0"/>
		<xsl:variable name="attempted" select="0"/>
		<xsl:variable name="total" select="0"/>
		<xsl:variable name="pass" select="count(document($file)/results/result/passed[text()='true'])"/>
		<xsl:variable name="fail" select="count(document($file)/results/result/passed[text()='false'])"/>
		<xsl:variable name="attempted" select="count(document($file)/results/result/passed[text()!='tbd'])"/>
		<xsl:variable name="total" select="count(document($file)/results/result)"/>
        <td class="results"><span style="position:absolute"><xsl:value-of select="$pass"/> of <xsl:value-of select="$attempted"/></span><img alt="{$pass} of {$total}" width="{$pass div $total * 100}" height="18px" src="http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/green.gif"/><img alt="{$fail} of {$total}" width="{$fail div $total * 100}" height="18px" src="http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/test-suite/red.gif"/></td>
	</xsl:template>
	
	<!-- It would be ideal if this could be driven by the rounds.xml. However, there is no
	information in that file related to the filename or directory structure for where the results are
	stored. If the results file mapping could be included in the rounds file, we could drive this
	summarization automatically. CBF -->
	
    <xsl:template name="generate-participant-results">
        <tr>
            <xsl:variable name="organization" select="organization"/>
            <td id="{$organization}" class="results"><xsl:value-of select="organization"/></td>
            <xsl:variable name="file" select="concat('round1/round1-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
            <xsl:variable name="file" select="concat('round2/WSDL11/round2-WSDL11-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
            <xsl:variable name="file" select="concat('round2/WSDL20/round2-WSDL20-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
			<xsl:variable name="file" select="concat('round3/WSDL11/round3-WSDL11-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
			<xsl:variable name="file" select="concat('round3/WSDL20/round3-WSDL20-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
			<xsl:variable name="file" select="concat('round4/UDDI/round4-UDDI-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
			<xsl:variable name="file" select="concat('round4/external-policy-attachment/WSDL11/round4-External-Policy-Attachment-WSDL11-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
			<xsl:variable name="file" select="concat('round4/external-policy-attachment/WSDL20/round4-External-Policy-Attachment-WSDL20-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
	    <xsl:variable name="file" select="concat('round4/mediatype/round4-Media-Type-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
	    <xsl:variable name="file" select="concat('round4/negative-test/round4-Negative-Test-',$organization,'.xml')"/>
            <xsl:choose>
            	<xsl:when test="boolean(document($file))">
            		<xsl:call-template name="generate-column">
            			<xsl:with-param name="file" select="$file"/>
            		</xsl:call-template>
            	</xsl:when>
            	<xsl:otherwise>
            		<td class="results">N/A</td>
            	</xsl:otherwise>
            </xsl:choose>
        </tr>
    </xsl:template>

    <!-- This template is for future graphical representation of how far along we are towards achieving
    the CR exit criteria for each feature. I have in mind that we would list each feature and its progress
    here, rather than the feature table in the detail report. CBF -->

    <xsl:template name="generate-feature-progress">
    </xsl:template>

</xsl:stylesheet>
