xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ravi Trivedi" <triv...@india.hp.com>
Subject Xerces 1.2 fails with : DOM006 Hierarchy request error , but Xerces 1.0.3 works fine..
Date Sat, 03 Feb 2001 13:27:27 GMT


-----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>


Mime
View raw message