When trying to adopt node after parsing
public static Node parseString(Document doc, String content)
throws Exception
StringReader contentReader = new StringReader(content);
InputSource source = new InputSource(contentReader);
DocumentBuilder b = XMLTools.get(false, false);
Document sourceDoc = b.parse(source);
XMLTools.release(b, false, false);
Node root = sourceDoc.getFirstChild();
Node imported = doc.adoptNode(root);
if (imported == null) {
System.out.println("not adopted");
imported = doc.importNode(root, true);
}
return imported;
}
folowing error occur:
java.lang.ClassCastException: org.apache.xerces.dom.DocumentImpl
at org.apache.xerces.dom.DeferredAttrImpl.synchronizeChildren(Unknown
Source)
at org.apache.xerces.dom.AttrImpl.setOwnerDocument(Unknown Source)
at org.apache.xerces.dom.NamedNodeMapImpl.setOwnerDocument(Unknown
Source)
at org.apache.xerces.dom.ElementImpl.setOwnerDocument(Unknown Source)
at org.apache.xerces.dom.ParentNode.setOwnerDocument(Unknown Source)
at org.apache.xerces.dom.ElementImpl.setOwnerDocument(Unknown Source)
at org.apache.xerces.dom.CoreDocumentImpl.adoptNode(Unknown Source)
Java: JDK 1.5.0_08 Xerces 2.8.1
What I do wrong?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]