Hello,

I have discovered a bug in the class org.apache.xerces.dom.DeepNodeListImpl. The
attached code demonstrates it, just try switching the order of the two println
lines. It seems that you have to call the getLength() method at least once
before accessing any of the items directly. I don't feel that this behavior is
intentional.

public class XMLTest
{
public static void main (String[] args)
throws Exception
  {
    org.apache.xerces.parsers.DOMParser parser = new
org.apache.xerces.parsers.DOMParser();
    parser.parse("file:///d:/testing/xercestest/test.xml");
    org.w3c.dom.Node d = parser.getDocument();
    org.w3c.dom.NodeList nl = d.getChildNodes();
    System.out.println("Node 0 is an element?
"+(nl.item(0).getNodeType()==org.w3c.dom.Node.ELEMENT_NODE));
    System.out.println("Length of nodelist: "+nl.getLength());
  }
}

Executed on the file test.xml:
<?xml version="1.0"?>
<!DOCTYPE TEST SYSTEM "test.dtd">
<TEST/>

with the DTD test.dtd:
<!ELEMENT TEST EMPTY>

By the way, thanks to all developers for the good work with this parser.

Wolfhart Bauer


Reply via email to