This content has been marked as final. Show 3 replies
You can't use Transformer to write out an internal DTD.
transformer.setOutputProperty( OutputKeys.DOCTYPE_PUBLIC , "something" ); transformer.setOutputProperty( OutputKeys.DOCTYPE_SYSTEM , "something" );
do you mean that the DTD should exist and can't be created dynamically?
how can i create the new XML file and give it its name?
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.