I am reading an xml document, inserting an element and then writing it. In this process, the document loses doctype and dtd info. Through “Transformer” class I can set OutputProperties but my requirement is to insert or update some element and not to play with doctype at all.
Could somebody give me a hint?
I am reading an xml document, inserting an element and then writing it. In
Share
From a post at Example Depot:
The referenced article contains this example.
Here is another code snippet from someone with the same problem, which, unfortunately is not complete (and the forum is in german language, but the formum text is irrelevant here) but maybe you can complete the missing steps.
EDIT
A real ugly hack/workaround – but maybe the only solution to your problem:
<!-- DOCTYPE -->) to the DOM at the very beginning of the document