Hi Prashant,
   Thanks for reply.

The following code works for me:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbf.newDocumentBuilder();

DOMImplementation domImplementation = docBuilder.getDOMImplementation();
DocumentTypeImpl documentType = (DocumentTypeImpl)
domImplementation.createDocumentType("root",
                                              null,
                                                              null);

documentType.setInternalSubset("<!ENTITY x 'hello'>");
Document document = domImplementation.createDocument(null, null, documentType);

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"));

document.appendChild(root);

DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
DOMImplementationLS impl =
(DOMImplementationLS)registry.getDOMImplementation("LS");
LSSerializer writer = impl.createLSSerializer();
LSOutput output = impl.createLSOutput();
output.setByteStream(System.out);
writer.write(document, output);

I have further question related to this:
I still have to use, Xerces specific class DocumentTypeImpl, which is
deprecated, and I have a risk to loose this functionality in future
Xerces releases. Can we ask for API enhancement to standard DOM APIs
for this? Or, Xerces preserve this API till we have DOM API
enhancement?


On Jan 14, 2008 10:13 AM, Prashant Reddy <[EMAIL PROTECTED]> wrote:
> Try this code :
>
> DocumentBuilder builder = factory.newDocumentBuilder();
> final DOMImplementation domImplementation =
> builder.getDOMImplementation();
>
> /* See this sttmt  */
> final DocumentType documentType =
> domImplementation.createDocumentType(rootName, /* this is null ?*/
>                    xmlVersion.getPublicId(),
>                    xmlVersion.getSystemId());
>
> documentType.setInternalSubset("...");
> document = domImplementation.createDocument(null, rootName,
> documentType);
>
> Then Serialize the document object...
>
> -Prashant


-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to