OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

xslt-conformance message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: [xslt-conformance] Ideas for test case filtration


Here is an idea that I'll be presenting at the Nextware conference in
Baltimore (http://www.nextwareexpo.com) that Carmelo might be able to
use. I'm presenting it to the list for your edification.

ASSUMPTION: Questionnaire responses from the vendors will have the same
XML structure as the test data. Before the launch of the templates below,
assume that the variable $quest has been set to a node-set containing
behavior data for the processor-under-test regarding the gray-areas. It
would be set via the document() function on an XML file that represents
answers to the questionnaire.

The example shows filtering just by gray areas. Rather than accepting a
test case if it passes, in the real production system, we would move on
to filter the case further based on other criteria. Note that $max is
set to the number of gray-area items in the current test case, if any,
while $quest should have items for all gray areas.

<xsl:template match="test-case">
  <xsl:choose>
    <xsl:when test="not(gray-area)">
      <!-- Test involves no gray areas, so use it. -->
      <xsl:copy-of select="."/>
      <!-- [Actually, we would perform other filtering.] -->
    </xsl:when>
    <xsl:otherwise>
      <!-- Step through the compares (item by item) without using
          for-each, quit at first false. -->
      <xsl:call-template name="multi-and">
        <xsl:with-param name="pos" select="1"/>
        <xsl:with-param name="max"
            select="count(gray-area/gray-area-choice)"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="multi-and">
  <xsl:param name="pos" select="0"/>
  <xsl:param name="max" select="0"/>
  <!-- If we have called this template, it means we have no mismatch
    so far. On this iteration, check the item at position $pos in
    the list. -->
  <!-- Obtain the name of the gray-area item that we need to look up
      in $quest. -->
  <xsl:variable name="item"
      select="gray-area/gray-area-choice[$pos]/@name"/>
  <!-- Does the behavior of $item in this test-case match the behavior
      specified (in $quest) for the processor-under-test? -->
  <xsl:if test="gray-area/gray-area-choice[$pos]/@behavior =
    $quest/gray-area/gray-area-choice[@name=$item]/@behavior">
    <!-- True (matching) this time, are there more to check? -->
    <xsl:choose>
      <xsl:when test="$pos &lt; $max">
        <!-- There are more, step ahead in the list. -->
        <xsl:call-template name="multi-and">
          <xsl:with-param name="pos" select="$pos+1"/>
          <xsl:with-param name="max" select="$max"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <!-- No more items to test. We were true on all. -->
        <xsl:copy-of select="."/>
        <!-- [Actually, we would perform other filtering.] -->
      </xsl:otherwise>
    </xsl:choose>
  </xsl:if>
</xsl:template>

Verbalizing the above:
A test-case in the input that has no gray areas is copied through to
the output because we have no reason to reject it. If a test-case has
one or more gray-area children, each has a name. Step through those
gray-area items, and match names against the questionnaire. The
@behavior value for item X must match between this test case and the
questionnaire. If all match, the test can be used, so we copy it
through to the output. Since this is a multi-way logical AND
operation, the first mismatch (false) means we can quit, rejecting
the test-case.
.................David Marston




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC