<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:s="http://www.w3.org/2008/09/soapjms/test-cases/assertions"
  xmlns:tc="http://www.w3.org/2008/soapjms/testsuite/testcases/" 
  xmlns:xlink="http://www.w3.org/1999/xlink"
  exclude-result-prefixes="xlink">
  <xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" indent="yes"/>

  <xsl:template match="/">
    <html>
      <head>
        <title>SOAP over Java Message Service 1.0 - Test Assertions</title>
        <link href="../testsuite.css" rel="stylesheet" type="text/css"/>
      </head>
      <body>
      <p class="navicons"><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home"
      alt="W3C" height="48" width="72" /></a> <a href="http://www.w3.org/Architecture/"><img
      src="http://www.w3.org/Icons/arch" alt="Architecture Domain" height="48" width="212"
      /></a> <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>
        <h1>SOAP over Java Message Service 1.0 - Test Assertions</h1>

	<p>The following table contains a summary of the test assertions found in the 
       <a href="http://www.w3.org/TR/soapjms/">SOAP-JMS Binding specification</a>,
	   along with the list of testcases which test each assertion.</p>

	<div class="assertion">
        <table border="1" summary="Testcase summary" rules="all">
         <tr>
            <th>Test Assertion ID</th>
            <th>Description</th>
	    <th>Testcases</th>
         </tr>

	<xsl:for-each select=".//assert">
	  <xsl:sort select="@id"/>
            <tr>
              <td><a name="{@id}" href="http://www.w3.org/TR/soapjms/#{@id}-summary"><xsl:value-of select="@id"/></a></td>
	      <td><xsl:call-template name="copy-elements-and-text"/></td>
	      <td><xsl:call-template name="cross-ref"><xsl:with-param name="assertID" select="@id"/></xsl:call-template></td>
	    </tr>
	</xsl:for-each>
	</table>
	</div>

    <hr/>
    <p>Generated from <a href="../../soapjms.xml">soapjms.xml</a> using <a href="assertions.xsl">assertions.xsl</a>.</p>
    <xsl:copy-of select="document('../address.xml')/suffix/*"/>

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

  <xsl:template name="cross-ref">
    <xsl:param name="assertID" />
    <xsl:variable name="matchingAssertions" select='document("../testcases/testcases.xml")/tc:testcases/tc:testcase/tc:assertions/tc:assertion[@id=$assertID]/../../@xml:id' />
    <xsl:choose>
      <xsl:when test="count($matchingAssertions) > 0">
          <xsl:for-each select='$matchingAssertions'>
            <a href="../testcases/testcases.html#{.}"><xsl:value-of select="."/></a><xsl:text> </xsl:text>
          </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        untestable by test cases.
      </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

  <!-- Copies all the element and text node children of the current node. Use this to avoid copy-of which all copies the namespace attributes -->
  <xsl:template name="copy-elements-and-text">
  	<xsl:for-each select="*|text()">
  		<xsl:apply-templates select="." mode="copy"/>
  	</xsl:for-each>
  </xsl:template>

  <!-- simply convert a "rfc2119" element to "strong" -->
  <xsl:template match="rfc2119" mode="copy">
  <strong><xsl:value-of select="."/></strong>
  </xsl:template>

  <xsl:template match="specref" mode="copy">
  <a href="http://www.w3.org/TR/soapjms/#{@ref}">SOAP-JMS Binding specification (<xsl:value-of select="@ref"/>)</a>
  </xsl:template>

  <xsl:template match="bibref" mode="copy">
      <cite xmlns="http://www.w3.org/1999/xhtml">
          <a xmlns="http://www.w3.org/1999/xhtml">
              <xsl:attribute name="href">
	          <xsl:value-of select="id(@ref)/@href"/>
              </xsl:attribute>
              <xsl:choose>
                  <xsl:when test="id(@ref)/@key">
                      <xsl:value-of select="id(@ref)/@key"/>
                  </xsl:when>
                  <xsl:otherwise>
                      <xsl:value-of select="@ref"/>
                  </xsl:otherwise>
              </xsl:choose>
          </a>
      </cite>
  </xsl:template>

  <!-- Copies the current element node, omitting the namespace attributes of this node and its children, recursively. -->
  <xsl:template match="*" mode="copy">
  	<xsl:element name="{name()}">
  		<xsl:for-each select="@*">
  			<xsl:attribute name="{name()}">
  				<xsl:value-of select="." />
  			</xsl:attribute>
  		</xsl:for-each>
  		<xsl:call-template name="copy-elements-and-text" />
  	</xsl:element>
  </xsl:template>
  
  <!-- Copies a text node. -->
  <xsl:template match="text()" mode="copy">
  	<xsl:copy-of select="." />
  </xsl:template>

</xsl:stylesheet>

