Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know you asked this nearly a week ago, but the answer is this:Do that before you call its transform() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic