How do I get the DOCTYPE declaration output from an org.w3c.xml.Document object?
posted 8 years ago
I'm not quite sure what I'm doing wrong here. In fact, I believe my attempt at solving my problem thus far, which doesn't work, is itself sort of a hack.
Anyway, I have a Document instance that I'm using a java.xml.transform.Transformer instance to write out to a file.
Everything works fairly well, except that I need the following declaration to be in the resulting XML file, and it's not there:
<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
I'm creating a template file that already has that reference, and parsing that file into the Document instance, then adding all the elements I need, then using the transform object to write it out. Still, while everything is perfect, that DOCTYPE reference is missing.
How can I fix this problem? Ideally, instead of using that empty template file, I'd like to create my Document instance the right way, but I'm not sure how.