<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  
  <!-- URI Reference resolver test runner -->
  <!-- $Id: uritest.xsl,v 1.1 2006/03/17 16:56:26 Dave Exp $ -->

  <xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.01//EN" />
  
  <xsl:include href="urires.xsl" />

  <xsl:template match="/tests">
    <html>
      <head>
	<title>URI Reference Parsing Tests</title>
      </head>
      <body>
	<h1>URI Reference Parsing Tests</h1>

	<h2>
	  <xsl:text>Testing </xsl:text>
	  <a href="urires.xsl">urires.xsl</a>
	  <xsl:text>; strict mode: </xsl:text>
	  <xsl:value-of select="strict" />
	</h2>
	
	<table border="1" cellpadding="5">
	  <tr>
	    <th>Test Num</th>
	    <th>Base</th>
	    <th>Reference</th>
	    <th>Result</th>
	    <th>Expected</th>
	    <th>Pass</th>
	  </tr>

	  <xsl:apply-templates />

	</table>

	<hr />

	<div>
	  <address><a href="http://djpowell.net/">David Powell</a> - some tests taken from: <a href="http://www.w3.org/2004/04/uri-rel-test.html">http://www.w3.org/2004/04/uri-rel-test.html</a></address>
	</div>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="/tests/test">
    <tr>
      <td>
	<xsl:value-of select="num" />
      </td>

      <td>
	<xsl:value-of select="base" />
      </td>

      <td>
	<xsl:value-of select="in" />
      </td>

      <xsl:variable name="result">
	<xsl:call-template name="resolveRef">
	  <xsl:with-param name="base" select="base" />
	  <xsl:with-param name="ref" select="in" />
	  <xsl:with-param name="strict" select="/tests/strict" />
	</xsl:call-template>
      </xsl:variable>

      <td>
        <a href="{$result}">
	<xsl:value-of select="$result" />
        </a>
      </td>

      <td>
	<xsl:value-of select="expect" />
      </td>

      <td>
	<xsl:choose>
	  <xsl:when test="$result = expect">
	    <span style="color: green; font-weight: bold">PASS</span>
	  </xsl:when>
	  <xsl:otherwise>
	    <span style="color: red; font-weight: bold">FAIL</span>
	  </xsl:otherwise>
	</xsl:choose>
      </td>
    </tr>

  </xsl:template>

  <xsl:template match="*" />

</xsl:stylesheet>
