<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                >

  <xsl:import href="splitns.xsl" />

  <xsl:output method="html" />

  <xsl:template match="/root">
    <html>
      <head>
        <title>Namespace split test</title>
        <style type="text/css">
          .success {font-weight: bold; color: green}
          .fail {font-weight: bold; color: red}
        </style>
      </head>
      <body>
        <h1>Namespace split test</h1>
        <table border="1">
          <tr>
            <th>URI</th>
            <th>Last NonNcName</th>
            <th>Split</th>
            <th>Namespace</th>
            <th>Local name</th>
            <th>Expected</th>
            <th>Test</th>
          </tr>
          <xsl:apply-templates />
        </table>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="test">
    <tr>
      <td>
        <xsl:value-of select="uri" />
      </td>
      <td>
        <xsl:call-template name="findLastNonNcName">
          <xsl:with-param name="uri" select="uri" />
        </xsl:call-template>
      </td>
      <xsl:variable name="split">
        <xsl:call-template name="findNamespaceSplit">
          <xsl:with-param name="uri" select="uri" />
        </xsl:call-template>
      </xsl:variable>
      <td>
        <xsl:value-of select="$split" />
      </td>
      <td>
        <xsl:value-of select="substring(uri, 1, $split - 1)" />
      </td>
      <td>
        <xsl:value-of select="substring(uri, $split)" />
      </td>
      <td>
        <xsl:value-of select="expected" />
      </td>
      <td>
        <xsl:choose>
          <xsl:when test="expected = substring(uri, 1, $split - 1)">
            <span class="success">SUCCESS</span>
          </xsl:when>
          <xsl:otherwise>
            <span class="fail">FAIL</span>
          </xsl:otherwise>
        </xsl:choose>
      </td>
    </tr>
  </xsl:template>

</xsl:stylesheet>
