Inserting node in XMl and retaining doc type information
posted 7 years ago
I want to insert one new node in an XML. Using the following code I can do that. But the problem is if the XML has doc type declaration then its giving me problem. After inserting the node the transformer is removing my doc type declaration from the XML. I have to retain the doc type definition (including entity declaration) as it is in the original XML file.
The following is the code that I�m using.
The doc type def. in the original file is some thing like this.
I know that I can set up the doc type definition in the new XML using the following properties of the transformer.
I cannot hard code the DTD def. as it can vary from one XML to another. Using doc.getDocType() I can get the doctype of the original XML. But is it is not returning the complete def. including entities declaration. Its giving me "someurl/TFJA.dtd".
Is there any way to retain the complete doc type in the original XML file? I don�t have much experience in XML and this issue is eating my head.. Also do I have to modify the DTD to accommodate the new tags added in order to make it a valid XML?
Any help and sample code would be highly appreciated.