Transfo
rmerFactory transformerFactory =
TransformerFactory.newInstance();
cal-align: middle; border: 0px none; text-align: center; margin: 0px auto;" />
Transformer transformer =
transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, " yes "
);
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, " no "
);
transformer.setOutputProperty(OutputKeys.METHOD, " xml "
);
DOMImplementation domImpl =
document.getImplementation();
DocumentType doctype = domImpl.createDocumentType( " doctype "
,
" SYSTEM "
,
" TEST.dtd "
);
transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctype.getPublicId());
transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctype.getSystemId());
DOMSource source = new
DOMSource(document);
StreamResult result = new StreamResult( new
File(database));
transformer.transform(source, result);