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
Op 13-jan-2008, om 6:29 heeft Mukul Gandhi het volgende geschreven:
I found that Xerces-J provides non-DOM classes CoreDocumentImpl and
DocumentTypeImpl for this.
I tried this code:
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"));
But when I serialize the Document object I don't get internal DTD
subset in the output.
Unfortunately, it's mentioned in the Java docs for CoreDocumentImpl
and DocumentTypeImpl, "Usage of this class is not supported. It may be
altered or removed at any time."
I'll appreciate, how to approach this problem correctly with Xerces-J.
On Jan 11, 2008 10:38 PM, Mukul Gandhi <[EMAIL PROTECTED]> wrote:
Following is the XML I want to create (in this lexical form only):
<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY x "hello">
]>
<root>
<a>&x; world</a>
</root>
--
Regards,
Mukul Gandhi
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]