problem: writing out an XML file always includes the commented DTD in the beginning. Why?

B

bronski

My problem is, I use javax.xml.Transform to write out a modified
Document object to a file. It has a dtd, and it is included every time
in the written file, no matter what. Why? How do I get rid of the
behaviour?

Here's the code:

try {
// Create a transformer
Transformer xformer =
TransformerFactory.newInstance()
.newTransformer();

// Write the DOM document to a file
Source source = new DOMSource(doc);
File newFile = new File(foo.xml);
Result result = new StreamResult(newFile);
xformer.transform(source, result);
} catch (TransformerConfigurationException e) {
System.out.println(e.getMessage());
} catch (TransformerException e) {
System.out.println(e.getMessage());
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top