Tenho esse método abaixo, onde estou tentando gerar um XHTML, porém nem por Deus consigo colocar o Doctype. Reparem que o ID publico e privado do Doctype é setado porém não aparece quando mando escrever o XHTML. Alguém pode me ajudar???
public void write(Writer writer) throws IOException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
// Create a XML document
Document docXml = builder.newDocument();
// Fill XML document with XHTML tags
document.createXml(docXml);
// Format
OutputFormat format = new OutputFormat();
format.setMethod(Method.XHTML);
format.setOmitXMLDeclaration(true);
format.setDoctype(document.getDoctype().getPubId(), document.getDoctype().getSysId());
format.setIndenting(indenting);
// Write XHTML
XMLSerializer s = new XMLSerializer(writer, format);
s.serialize(docXml);
writer.flush();
writer.close();
} catch (ParserConfigurationException e) {
}
}
