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());
}
 
Ad

Advertisements


Top