Please ignore my previous message. I found out how to do that. Here is an 
example of how to restore DocumentType in Xerces 1.4.4 after DOM to DOM 
transformation:

Properties prop = transformer.getOutputProperties();
if ((prop.getProperty("doctype-system") != null
        || prop.getProperty("doctype-public") != null)
        && outDocument.getDocumentElement() != null) {
        DOMImplementation impl = docBuilder.getDOMImplementation();
        DocumentTypeImpl doctypeImpl =
                new DocumentTypeImpl (
                        (CoreDocumentImpl) outDocument,
                        outDocument.getDocumentElement().getNodeName(),
                        prop.getProperty("doctype-public"),
                        prop.getProperty("doctype-system"));
        if (doctypeImpl != null)
                outDocument.appendChild(doctypeImpl);
}






"Vlad.Epshtein" <[EMAIL PROTECTED]>
05/06/2002 01:07 PM
Please respond to xerces-j-user

 
        To:     xerces-j-user <[EMAIL PROTECTED]>
        cc: 
        Subject:        Re: how to modify DOCTYPE node in an existing document?


Thanks for your prompt response.

I tried using insertBefore, but my doctype's ownerDocument is not set and 
I don't know if there is a way to do that.
I've tried using importNode, but the doctype node cannot be imported.
Does anybody know if there is any other way to set the owner document in 
the doctype?

Thanks in advance,
Vlad




Elena Litani <[EMAIL PROTECTED]>
05/03/2002 04:49 PM
Please respond to xerces-j-user

 
        To:     xerces-j-user <[EMAIL PROTECTED]>
        cc: 
        Subject:        Re: how to modify DOCTYPE node in an existing 
document?


[EMAIL PROTECTED] wrote:
> I need to change/assign DTD in a DOM object, so I'm creating a new
> document with a doctype I need and copying all the children of the root
> node. Does anybody know if there is a better and less expensive way to
> modify or set DOCTYPE in an existing document?

The doctype is just the first child of the document (for wellformness
reasons it must appear before documentElement). 
So the following trick will do:
1. document.removeChild (document.getDoctype())
2. create a new doctype using DOMImplementation
3. document.insertBefore (newDoctype, document.getDocumentElement())

However, this trick will only work with the latest code from CVS for
Xerces2 (thanks to Arnaud Le Hors).
You may try it for Xerces 1, however you might get exception..

Hope it helps,
-- 
Elena Litani / IBM Toronto

---------------------------------------------------------------------
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]





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

Reply via email to