This content has been marked as final. Show 3 replies
do you mean that the DTD should exist and can't beThat would be the sensible thing to do. In my opinion having a computer program produce a document with an internal DTD is rather pointless. Just have the program produce a document that is valid according to the DTD and leave out the DTD entirely. Unless you're declaring entities in the DTD, and even that is pointless as the purpose of entities is to make it easier for people to type the document. Computers don't need that help.
However if you have a use case where having a computer-generated internal DTD would provide some value, I would like to see it.
how can i create the new XML file and give it its name?Check out the documentation for StreamResult. You'll see it has constructors that take a File or an OutputStream.