You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by Ravi Trivedi <tr...@india.hp.com> on 2001/02/03 14:27:27 UTC

Xerces 1.2 fails with : DOM006 Hierarchy request error , but Xerces 1.0.3 works fine..


-----Original Message-----
From: Ravi Trivedi [mailto:trivedi@india.hp.com]
Sent: Saturday, February 03, 2001 6:45 PM
To: ''
Subject:



Hi,
This piece of test code fails with Xerces1.2 while works fine with 1.0.3
Xerces.
Can any one say if I am doing anything wrong ? What is the alternative.

Regards,
Ravi

ps: If the Parser is set to not  use lazy DOM it works fine i.e.

theParser.setFeature("http://apache.org/xml/features/dom/defer-node-expansio
n", false );
But this doesnt help me , as this main is actually a function in my code ,
where I recieve Document as a parameter.

=======================test.java====================================
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import org.apache.xerces.parsers.*;
import org.xml.sax.InputSource;
import org.apache.xml.serialize.*;
import org.apache.xerces.dom.DocumentImpl;
 public class test extends Object {



public static void main ( String args [] ) {

    try {
        String fileName = "C:\\tmp\\1.xml";
        DOMParser theParser =  new DOMParser();
        InputStreamReader inReader = new InputStreamReader(new
FileInputStream(fileName));
        InputSource inSource = new InputSource ( inReader );
        theParser.parse( inSource);
        Document doc = theParser.getDocument();

        Document m_document = new DocumentImpl();
        DocumentFragment m_content = m_document.createDocumentFragment();

        NodeList childs = doc.getChildNodes();

        for (int i = 0; i < childs.getLength(); i++) {
           System.out.println("childs.item(" + i + ").GetNodeName=" +
                  childs.item(i).getNodeName() + ", getNodeType=" +
childs.item(i).getNodeType());
            Node node = m_document.importNode(childs.item(i), true);
            m_content.appendChild(node);
        }

    } catch (Exception e) {      e.printStackTrace ( System.out );    }

}


}

====================file C:\TMP\1.xml
<test22>
 </test22>


Re: Xerces 1.2 fails with : DOM006 Hierarchy request error , but Xerces 1.0.3 works fine..

Posted by Arnaud Le Hors <le...@us.ibm.com>.
I found that the DOMParser was wrongly creating a doctype node and on
top of it was adding it after the root element. These two bugs are
fixed. I committed the change.
Thanks for your report!
-- 
Arnaud  Le Hors - IBM Cupertino, XML Strategy Group

Re: Xerces 1.2 fails with : DOM006 Hierarchy request error , but Xerces 1.0.3 works fine..

Posted by Arnaud Le Hors <le...@us.ibm.com>.
I found that the DOMParser was wrongly creating a doctype node and on
top of it was adding it after the root element. These two bugs are
fixed. I committed the change.
Thanks for your report!
-- 
Arnaud  Le Hors - IBM Cupertino, XML Strategy Group