File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Merging XML documents with DOM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Merging XML documents with DOM" Watch "Merging XML documents with DOM" New topic
Author

Merging XML documents with DOM

Rikko Verrijzer
Ranch Hand

Joined: Jul 22, 2003
Posts: 34
Hi,

I'm trying to modify a XML file with DOM. Basically what needs to be done is to translate all math inside a XML file from latex to mathML. Finding the math and translating it is to mathML no problem.

However the translation proces creates a new DOM XML tree. The problem I have is the integration of this new DOM tree into the old DOM tree.

I understood that the following lines of code should take care of this merging problem:



However this results in an error message like:
Exception in thread "main" org.apache.crimson.tree.DomEx: NOT_SUPPORTED_ERR: This DOM implementation does not support that node type.
at org.apache.crimson.tree.XmlDocument.importNode(XmlDocument.java:1259)
at translate.MathTransformation.process(MathTransformation.java:144)

Now apparently I'm not allowed to inserted complete documents into another document, but any child node I try add instead of the root node generates to following error:

Exception in thread "main" org.apache.crimson.tree.DomEx: WRONG_DOCUMENT_ERR: That node doesn't belong in this document.
at org.apache.crimson.tree.ParentNode.checkDocument(ParentNode.java:250)
at org.apache.crimson.tree.ParentNode.appendChild(ParentNode.java:333)
at translate.MathTransformation.process(MathTransformation.java:146)

I'm relatively new to DOM so this might be easy to solve.

Thanks,
Rikko
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
The first thing that occurs to me is a namespace conflict. If the node you want to import is in the MathML namespace but the original DOM does not know about the namespace you would get a conflict. (Just guessing - have not tried this.)
It may be that you will have to write a new document that knows all the namespaces involved.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Merging XML documents with DOM