> Hi All,
>
[quoted text clipped - 48 lines]
> org.w3c.dom.Document doc = impl.createDocument(null, "students",
> svgDOCTYPE);
I haven't done what you are trying to do, but I can tell you that
DOMImplementation.createDocumentType() takes a systemId not the text
of a DTD.
The DocumentType object simply refers to a DTD, it doesn't force you
to conform to it when you construct your DOM, so if you just want the
DTD to be able to write it out again, if you have the DTD in a string
anyway, you could output the string when you serialize your DOM, and
skip creating the DocumentType object. For example:
String dtd = "<!DOCTYPE students [ ... ]>";
DOMSource ds = new DOMSource();
Document doc = (Document) ds.getNode();
...
// create your DOM
pw.println("<?xml version='1.0' encoding='UTF-8'?>");
pw.println(dtd);
StreamResult sr = new StreamResult(pw);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer trans = tf.newTransformer();
trans.setOutputProperty("omit-xml-declaration", "true");
trans.transform(ds, sr);
Frank Fredstone - 23 Apr 2007 17:38 GMT
>> Hi All,
>>
[quoted text clipped - 72 lines]
> Transformer trans = tf.newTransformer();
> trans.setOutputProperty("omit-xml-declaration", "true");
Oops, also:
trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
> trans.transform(ds, sr);
Franks
Begreen - 24 Apr 2007 03:20 GMT
> > Hi All,
>
[quoted text clipped - 75 lines]
>
> - Show quoted text -
Franks,
Thanks, for the response, but where do you use your doc object?