Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dtd lost during transformation

Status
Not open for further replies.

Naug

Technical User
Sep 24, 2004
85
RU
I got meself another problem with xml - I read OpenOffice content file which uses a dtd into DOM like so

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(new File("content.xml"));

afterwords I modify some nodes and transform the DOM back to file like so
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
DOMSource source = new DOMSource(document);
PrintWriter pout = new PrintWriter("xml.xml","UTF-8");
StreamResult result = new StreamResult(pout);
transformer.transform(source, result);



My problem is that the resulting xml file is lacking a dtd line. Also lot's of default attributes are added to nodes which makes file more then two times larger than the original.

My primary consern is ofcourse to learn how to add the DTD to my new file and it would also be nice to figure how to control dom adding default atributes to nodes without my command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top