Hi Anthony,

Thanks for your reply. 
I tried this with XalanDocument(with XalanSourceTreeDocument to be precise,
as XalanDocument is abstract), but did't work as
XalanSourceTreeDocument::import() implementation looks like:

XalanNode* XalanSourceTreeDocument::importNode(XalanNode*, bool)
{
        throw
XalanDOMException(XalanDOMException::NO_MODIFICATION_ALLOWED_ERR);
        return 0;
}

Hence at least it's not possible using XalanDocument (exactly what I want to
do).
Am just wondering how people are processing the results of Xalan API's if
caching of Xalan's objects are so tricky.

Probaly I'm missing something very basic here :-(

Mayank


-----Original Message-----
From: Anthony Zawacki [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 20, 2003 9:17 AM
To: KHARE,MAYANK (HP-India,ex2)
Cc: 'xalan-c-users@xml.apache.org'
Subject: Re: XalanNode.cloneNode() issue !!

This is just a guess, because a key portion of the code is missing (in the
do xpath query stuff .......)

My guess is that when you clone the node, it is still owned by the original
document.  When that document goes out of scope, the clone goes out of
scope.  So what you probably want to do is import the nodes into another
document that stays alive a little longer.  I can't provide a snippet for
you because I don't use XalanNodes, but rather use Xerces because I need a
mutable DOM.

Using the deprecated Xerces API, the code looks something like this:

    DOM_Document theCopy = DOM_Document::createDocument();
    DOM_Element root = c.theMessage.getDocumentElement();
    theCopy.appendChild(theCopy.importNode(root.cloneNode(), true));

Is there something equivalent using the Xalan APIs directly (rather than
going through the DOM?)

Thanks,
Anthony Zawacki

410-571-7161
[EMAIL PROTECTED]

Reply via email to