jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes How do I get the DOCTYPE declaration output from an org.w3c.xml.Document object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How do I get the DOCTYPE declaration output from an org.w3c.xml.Document object?" Watch "How do I get the DOCTYPE declaration output from an org.w3c.xml.Document object?" New topic
Author

How do I get the DOCTYPE declaration output from an org.w3c.xml.Document object?

Joe Vahabzadeh
Ranch Hand

Joined: Jan 05, 2005
Posts: 140
All,

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.

Thanks in advance.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19693
    
  10

I know you asked this nearly a week ago, but the answer is this:Do that before you call its transform() method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I get the DOCTYPE declaration output from an org.w3c.xml.Document object?
 
It's not a secret anymore!