Saving XML Documents
From: Stefan Schulz (terra_at_spacetime.de)
Date: 07/31/04
- Next message: Jack Barlow: "Talking to Network Cameras."
- Previous message: Oscar kind: "Re: Jar file manifest"
- Next in thread: John Fereira: "Re: Saving XML Documents"
- Reply: John Fereira: "Re: Saving XML Documents"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 31 Jul 2004 12:16:05 +0200
Hi there
I have a Problem.
I read an XML file by the following sequence of method invocations
DocumentBuilderFactory builderFactory =
DocumentBuilderFactory.newInstance();
builderFactory.setValidating(true);
builderFactory.setExpandEntityReferences(true);
builderFactory.setIgnoringComments(true);
DocumentBuilder builder =
builderFactory.newDocumentBuilder();
builder.setErrorHandler(new ErrorHandler(){
// ...
});
root = builder.parse(xmlFile);
which correctly includes entities and validates against the DTD given in
the <!DOCTYPE > declaration. However, once i am done with the document,
and possibly made modifications, i try to save it as follows:
DOMSource src = new DOMSource(root);
StreamResult res = new StreamResult(xmlFile);
TransformerFactory transFactory =
TransformerFactory.newInstance();
Transformer trans = transFactory.newTransformer();
trans.transform(src, res);
Which produces a file with all entities expanded, all default values for
attributes filled in, and with _no_doctype_declaration_. This will of
course not be cleanly parsable with my parser. Since this seems to be
the wrong way to go about things, can someone point me into the right
direction?
If possible, i would like to remain in the standard class library.
See you
Stefan
- Next message: Jack Barlow: "Talking to Network Cameras."
- Previous message: Oscar kind: "Re: Jar file manifest"
- Next in thread: John Fereira: "Re: Saving XML Documents"
- Reply: John Fereira: "Re: Saving XML Documents"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|