problem: cannot write out an XML file without DTD being included

V

vmmattil

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top