I am using LSSerializer to serializing the DOM. Below is the complete code:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbf.newDocumentBuilder(); CoreDocumentImpl document = (CoreDocumentImpl)docBuilder.newDocument(); DocumentTypeImpl docType = (DocumentTypeImpl)document.createDocumentType("root", null, null); docType.setInternalSubset("<!ENTITY x 'hello'>"); Element root = document.createElement("root"); Element a = document.createElement("a"); root.appendChild(a); EntityReference x = document.createEntityReference("x"); a.appendChild(x); a.appendChild(document.createTextNode(" world")); DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); LSSerializer writer = impl.createLSSerializer(); LSOutput output = impl.createLSOutput(); output.setByteStream(System.out); writer.write(root, output); With this code, I am getting output: <?xml version="1.0" encoding="UTF-8"?> <root> <a>&x; world</a> </root> But I also want internal DTD subset in the output. I guess, DocumentType node is not part of DOM data model, so is not getting serialized (but then, what is the use of attaching DocumentType node to the Document object ?). Am I correct to think so? Or, is this possible with Xerces-J? I am ready to use any Xerces specific extensions. Will appreciate further help ... On Jan 13, 2008 3:49 PM, Dick Deneer <[EMAIL PROTECTED]> wrote: > Are you using a Transformer class to serialize the document ? If so, > then try to use the LSSerializer instead to serialize the DOM and you > will also have the DTD subset in your output. > > > Regards > Dick Deneer -- Regards, Mukul Gandhi --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]