Hello,
the question may be stupid, but how do I create a doctype specification in
a serialized document? Here's what I do, I'd expect to see a doctype
declaration in the output, but I only get XML declaration and document.
Thanks,
Jochen
public class domtest {
public static void main (String args[]) throws java.io.IOException {
org.apache.xerces.dom.DocumentImpl myDoc =
new org.apache.xerces.dom.DocumentImpl();
org.w3c.dom.DocumentType dt =
new org.apache.xerces.dom.DocumentTypeImpl(myDoc, "dibob", null,
"dibob.dtd");
myDoc.appendChild(dt);
myDoc.appendChild(myDoc.createElement("dibob"));
org.apache.xml.serialize.OutputFormat oformat =
new org.apache.xml.serialize.OutputFormat("XML", "iso-8859-1",
true);
oformat.setDoctype(null, "dibob.dtd");
oformat.setStandalone(false);
org.apache.xml.serialize.XMLSerializer serializer =
new org.apache.xml.serialize.XMLSerializer(oformat);
serializer.setOutputCharStream(new java.io.PrintWriter(System.out));
serializer.serialize(myDoc);
}
}