<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>931</bug_id>
          
          <creation_ts>2004-10-29 16:15:19 +0000</creation_ts>
          <short_desc>org.w3c.dom.Document cannot be cast to org.w3c.dom.Element</short_desc>
          <delta_ts>2012-12-04 00:52:25 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>DOM TS</product>
          <component>DOM Level 3</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Windows 3.1</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yash Talwar">ytalwar</reporter>
          <assigned_to name="Philippe Le Hegaret">plh</assigned_to>
          
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2581</commentid>
    <comment_count>0</comment_count>
    <who name="Yash Talwar">ytalwar</who>
    <bug_when>2004-10-29 16:15:19 +0000</bug_when>
    <thetext>I have been trying to use the DOM Level 3 Test Suite for XPath API.  I think
there is a bug in the following testcase:

org.w3c.domts.level3.xpath.XPathEvaluator_evaluate_document

This test case has following code:
----------------------------------------
public void runTest() throws Throwable {
   Document doc;
   XPathEvaluator xpEvaluator;
   Element root;
   XPathResult result;
   XPathNSResolver nullNSResolver = null;

   XPathResult nullResult = null;

   doc = (Document) load(&quot;staffNS&quot;, false);
   xpEvaluator = (XPathEvaluator) createXPathEvaluator(doc);
   root = (Element)  doc; // This line has problem.
   result = (XPathResult) xpEvaluator.evaluate(&quot;/&quot;, root, nullNSResolver,    
              (short) 0, ((Object) /*XPathResult */nullResult));
   assertNotNull(&quot;notnull&quot;, result);
}
-----------------------------------

The line of code:

root = (Element) doc;

has a problem.
This line tries to cast org.w3c.dom.Document to org.w3c.dom.Element.  This line
results in ClassCastException because these two interfaces are not in same
inheritance tree.

This line of code should be changed as follows:

root = doc.getDocumentElement();

The identical problem is also seen in other testcases such as follows:

org.w3c.domts.level3.xpath.XPathExpression_evaluate_document
has a line in runTest() method:

contextNode = (Element)  doc;  // throws ClassCastException.

should be changed to:

contextNode = doc.getDocumentElement();</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>