<?xml version="1.0"?>
<!--
	# Create the summary table for the RDFa IR from the RDFa TC manifest document and the EARL report documents 
-->
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:earl="http://www.w3.org/ns/earl#"
	xmlns:test="http://www.w3.org/2006/03/test-description#"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
	xmlns:owl="http://www.w3.org/2002/07/owl#"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
	exclude-result-prefixes="rdf rdfs owl dc xsd #default"
	version="1.0">
	
<xsl:output
	method="html"
	indent="yes"
	omit-xml-declaration="no"
	encoding="utf-8"/>

<xsl:param name="RDFa_TC_HOME">http://www.w3.org/2006/07/SWD/RDFa/testsuite/xhtml1-testcases/</xsl:param>
<xsl:param name="APPROVED_TC">http://www.w3.org/2006/03/test-description#approved</xsl:param>
<xsl:param name="PASSED_TC">http://www.w3.org/ns/earl#pass</xsl:param>

<xsl:param name="input" select="document('impl-input.xml')" />


<xsl:template match="/">
	<table summary="Results for participating RDFa Processors" border="1">
	<caption align="bottom"><strong>Table 3.:</strong> Results for Server-side RDFa Processors.</caption>	
	<tbody>
	 <tr>
     <th align="left">Test</th>
     <th align="left" width="60%">Purpose</th>	     
     <xsl:for-each select = "$input/earldocs/in">
     	<th align="left"><xsl:value-of select="@title" /></th>
     </xsl:for-each>
     <th align="left" width="15%">Summary <br />legend: + ... <em>pass</em>, o ... <em>fail</em></th>
	</tr>
	<xsl:apply-templates select="rdf:RDF/test:TestCase"/>
    </tbody>
    </table>
</xsl:template>

<xsl:template match="rdf:RDF/test:TestCase">	 

	<xsl:if test="test:reviewStatus[@rdf:resource = $APPROVED_TC]">

	<xsl:variable name="thisTC" select="./@rdf:about" />

	<tr>
	<td valign="top">              
	  	<xsl:element name="a">
	  		<xsl:attribute name="href" >
	  	     <xsl:value-of select="$thisTC" />           
	  	    </xsl:attribute>
	  	     <xsl:value-of select="substring($thisTC, string-length($RDFa_TC_HOME) + 1)" />
	  	</xsl:element>
	</td>
	<td align="left" valign="top">
		<xsl:value-of select="./test:purpose" />
	</td>
    <xsl:for-each select = "$input/earldocs/in"><!-- show individual results -->
    	<xsl:variable name="result" select="document(.)/rdf:RDF//earl:Assertion/earl:test[@rdf:resource=$thisTC]/../earl:result/earl:outcome/@rdf:resource" />
     	<xsl:if test="substring-after($result, '#') = 'pass'">
     		<td align="center" valign="top" class="passTC" ><xsl:value-of select="substring-after($result, '#')" /></td>
     	</xsl:if>
     	<xsl:if test="substring-after($result, '#') = 'fail'">
     		<td align="center" valign="top" class="failTC"><xsl:value-of select="substring-after($result, '#')" /></td>
     	</xsl:if>
     	
    </xsl:for-each>
	<td valign="top"> <!-- show summary results for PASS -->
	    <xsl:for-each select = "$input/earldocs/in">
    		<xsl:variable name="result" select="document(.)/rdf:RDF//earl:Assertion/earl:test[@rdf:resource=$thisTC]/../earl:result/earl:outcome/@rdf:resource" />
     		<xsl:if test="$result = $PASSED_TC">+</xsl:if>
     		<xsl:if test="$result != $PASSED_TC">o</xsl:if>
    </xsl:for-each>
	</td>
	</tr>         
	
	</xsl:if>
</xsl:template>


</xsl:stylesheet>
