<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="test-to-html.xsl" type="text/xml"?>
<!--
 Copyright (c) 2003 World Wide Web Consortium,

 (Massachusetts Institute of Technology, European Research Consortium for
 Informatics and Mathematics, Keio University). All Rights Reserved. This
 work is distributed under the W3C(r) Software License [1] in the hope that
 it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
-->

<!DOCTYPE test SYSTEM "dom3.dtd" [
  <!ENTITY % entities SYSTEM "dom3xpathents.ent">
  %entities;
]>
<test xmlns="&level3;" name="XPathResult_resultType">
  <metadata>
    <title>XPathResult_resultType</title>
    <creator>Bob Clary</creator>
    <description>
      Create an XPathResult for the expression /staff/employee
      for each type of XPathResultType, checking that the resultType
      of the XPathResult matches the requested type.
    </description>
    <date qualifier="created">2003-12-02</date>
    <subject resource="&spec;#XPathResultType"/>
    <subject resource="&spec;#XPathResult"/>
    <subject resource="&spec;#XPathEvaluator-createNSResolver"/>
    <subject resource="&spec;#XPathEvaluator-evaluate"/>
    <subject resource="&spec;#XPathResult-resultType"/>
    <subject resource="&spec;#XPathException"/>
    
  </metadata>

  <var name="doc"                          type="Document"/>
  <var name="resolver"                     type="XPathNSResolver"/>
  <var name="evaluator"                    type="XPathEvaluator"/>
  <var name="expression"                   type="DOMString" value="&quot;/staff/employee&quot;"/>
  <var name="contextNode"                  type="Node"/>
  <var name="inresult"                     type="XPathResult" isNull="true"/>
  <var name="outresult"                    type="XPathResult" isNull="true"/>
  <var name="inNodeType"                   type="short"/>
  <var name="outNodeType"                  type="short"/>
  <var name="ANY_TYPE"                     type="short" value="0"/>
  <var name="NUMBER_TYPE"                  type="short" value="1"/>
  <var name="STRING_TYPE"                  type="short" value="2"/>
  <var name="BOOLEAN_TYPE"                 type="short" value="3"/>
  <var name="UNORDERED_NODE_ITERATOR_TYPE" type="short" value="4"/>
  <var name="ORDERED_NODE_ITERATOR_TYPE"   type="short" value="5"/>
  <var name="UNORDERED_NODE_SNAPSHOT_TYPE" type="short" value="6"/>
  <var name="ORDERED_NODE_SNAPSHOT_TYPE"   type="short" value="7"/>
  <var name="ANY_UNORDERED_NODE_TYPE"      type="short" value="8"/>
  <var name="FIRST_ORDERED_NODE_TYPE"      type="short" value="9"/>
  <var name="isTypeEqual"                  type="boolean"/>

  <var name="nodeTypeList"                 type="List">
    <member type="short">0</member>
    <member type="short">1</member>
    <member type="short">2</member>
    <member type="short">3</member>
    <member type="short">4</member>
    <member type="short">5</member>
    <member type="short">6</member>
    <member type="short">7</member>
    <member type="short">8</member>
    <member type="short">9</member>
  </var>


  <load var="doc" href="staff" willBeModified="false"/>

  <createXPathEvaluator var="evaluator" document="doc"/>

  <createNSResolver obj="evaluator" var="resolver" nodeResolver="doc"/>

  <assign var="contextNode" value="doc"/>

  <for-each collection="nodeTypeList" member="inNodeType">

    <evaluate obj="evaluator"
              var="outresult"
              expression="expression"
              contextNode="contextNode"
              resolver="resolver"
              type="inNodeType"
              result="inresult"
              interface="XPathEvaluator"
        />

     <resultType obj="outresult"
                 var="outNodeType"/>

     <if>
       <equals expected="inNodeType" actual="ANY_TYPE"/>
       <assertEquals id="ANY_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="UNORDERED_NODE_ITERATOR_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="NUMBER_TYPE"/>
       <assertEquals id="NUMBER_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="NUMBER_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="STRING_TYPE"/>
       <assertEquals id="STRING_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="STRING_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="BOOLEAN_TYPE"/>
       <assertEquals id="BOOLEAN_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="BOOLEAN_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="UNORDERED_NODE_ITERATOR_TYPE"/>
       <assertEquals id="UNORDERED_NODE_ITERATOR_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="UNORDERED_NODE_ITERATOR_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="ORDERED_NODE_ITERATOR_TYPE"/>
       <assertEquals id="ORDERED_NODE_ITERATOR_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="ORDERED_NODE_ITERATOR_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="UNORDERED_NODE_SNAPSHOT_TYPE"/>
       <assertEquals id="UNORDERED_NODE_SNAPSHOT_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="UNORDERED_NODE_SNAPSHOT_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="ORDERED_NODE_SNAPSHOT_TYPE"/>
       <assertEquals id="ORDERED_NODE_SNAPSHOT_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="ORDERED_NODE_SNAPSHOT_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="ANY_UNORDERED_NODE_TYPE"/>
       <assertEquals id="ANY_UNORDERED_NODE_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="ANY_UNORDERED_NODE_TYPE"
		   ignoreCase="false"
		   />
     </if>
     <if>
       <equals expected="inNodeType" actual="FIRST_ORDERED_NODE_TYPE"/>
       <assertEquals id="FIRST_ORDERED_NODE_TYPE_resulttype" 
                   actual="outNodeType" 
		   expected="FIRST_ORDERED_NODE_TYPE"
		   ignoreCase="false"
		   />
     </if>

   </for-each>

</test>
