This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.
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