You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by 4p...@sneakemail.com on 2007/02/03 01:09:04 UTC

importNode() does not call UserDataHandler

Hello,

I overrid XercesDOMParser's startElement() method to attach user data to 
each newly created DOMNode. This works fine, and I can retreive the data 
later with getUserData().

However, I now merge two documents into one DOM, and I use importNode() 
for copying the nodes into the main document, collecting the nodes in a 
DocumentFragment first, and then adding them to the main document with 
replaceChild().

a) The new nodes in the main document don't have the user data any more;
b) The data handler is not called while executing importNode(). However, 
it _is_ called when I delete the parser, when all nodes it owns are 
deleted, which means that it should be properly registered.

Any clues what I could have done wrong here? I Use Xerces 2.7.0.

Cheers,

Uwe

P.S.: For some odd reason I never manage to debug into Xerces from my 
application on my Windows XP/VS7.1 installation, although the PDB and 
sources should be accessible; I compiled Xerces myself. Does anyone have 
experience with this?

Re: importNode() does not call UserDataHandler

Posted by Alberto Massari <am...@datadirect.com>.
Hi Uwe,

At 16.17 06/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>Hi Alberto,
>
>I assume I have to get this from SVN, right?

Yes.

>I found that the binary/source zips on the website are from 2005...
>
>Maybe the download site 
>(http://xml.apache.org/xerces-c/download.cgi) could say something 
>like that the new 2.7.x versions should be retreived from SVN and 
>compiled manually, if all patches are desired. Otherwise people like 
>me would assume that the 2.7.0 package on the website is the newest 
>in the 2.7 branch, which it isn't.

The package is only for version 2.7.0; the 2.7.x branch of SVN has 
been populated with several patches from that release, in order to be 
ready for a (not forecasted) 2.8 release.

Alberto


>Anyway, thanks for the effort, you've been a great help!
>
>Cheers,
>
>Uwe
>
>Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>list| schrieb:
>>
>>The same patch has been applied in the 2.7 branch, so you can keep 
>>using it; as for the 3.0 release timeframe, we are still working on 
>>including XInclude support, and trying to make the new build system 
>>to work on a couple of platforms; its stability should be good.
>>
>>Alberto
>>
>>
>>>Thanks & Cheers,
>>>
>>>Uwe
>>>
>>>
>>>Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>>>list| schrieb:
>>>>Hi Uwe,
>>>>I guess you are right, and Xerces doesn't expect the list of 
>>>>handlers to change midway; can you try getting the latest 
>>>>DOMDocumentImpl.cpp from SVN and try if it works?
>>>>
>>>>Thanks,
>>>>Alberto


Re: importNode() does not call UserDataHandler

Posted by 4p...@sneakemail.com.
Hi Alberto,

I assume I have to get this from SVN, right? I found that the 
binary/source zips on the website are from 2005...

Maybe the download site (http://xml.apache.org/xerces-c/download.cgi) 
could say something like that the new 2.7.x versions should be retreived 
from SVN and compiled manually, if all patches are desired. Otherwise 
people like me would assume that the 2.7.0 package on the website is the 
newest in the 2.7 branch, which it isn't.

Anyway, thanks for the effort, you've been a great help!

Cheers,

Uwe

Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing list| 
schrieb:
>
> The same patch has been applied in the 2.7 branch, so you can keep 
> using it; as for the 3.0 release timeframe, we are still working on 
> including XInclude support, and trying to make the new build system to 
> work on a couple of platforms; its stability should be good.
>
> Alberto
>
>
>> Thanks & Cheers,
>>
>> Uwe
>>
>>
>> Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>> list| schrieb:
>>> Hi Uwe,
>>> I guess you are right, and Xerces doesn't expect the list of 
>>> handlers to change midway; can you try getting the latest 
>>> DOMDocumentImpl.cpp from SVN and try if it works?
>>>
>>> Thanks,
>>> Alberto
>


Re: importNode() does not call UserDataHandler

Posted by Alberto Massari <am...@datadirect.com>.
At 10.57 06/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>Hi Alberto!
>
>Yep, it worked with the modified version of 
>DOMDocumentImpl::callUserDataHandlers(). Of course, I couldn't use 
>the full DOMDocumentImpl.cpp, it changed too much from 2.7 to 3.0. 
>However, I just put the stuff you changed in callUserDataHandlers() 
>into 2.7's version, and it did the trick.
>
>Something else that I discovered: DOMUserDataHandler::handle()'s 
>data parameter does not carry the data from src, but the one that 
>has been registered with the DOMDocument - but it the 
>DOMUserDataHandler::handle() docs don't say that anywhere. Not a 
>problem really, but I find it confusing (maybe it is not so much 
>though if you know that you have to register the data handler with 
>the DOMDocument, which I didn't at the beginning).

That could change if we decide that the handler being called is the 
one of the imported (or adopted) node. But it would be only in the 
3.0 version, as it would break existing programs that rely on this behavior.


>However, I wonder if switching to 3.0 makes sense for me, rather 
>than relying on a patched version of 2.7. How far is 3.0 from 
>release? How stable is it?

The same patch has been applied in the 2.7 branch, so you can keep 
using it; as for the 3.0 release timeframe, we are still working on 
including XInclude support, and trying to make the new build system 
to work on a couple of platforms; its stability should be good.

Alberto


>Thanks & Cheers,
>
>Uwe
>
>
>Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>list| schrieb:
>>Hi Uwe,
>>I guess you are right, and Xerces doesn't expect the list of 
>>handlers to change midway; can you try getting the latest 
>>DOMDocumentImpl.cpp from SVN and try if it works?
>>
>>Thanks,
>>Alberto


Re: importNode() does not call UserDataHandler

Posted by 4p...@sneakemail.com.
Hi Alberto!

Yep, it worked with the modified version of 
DOMDocumentImpl::callUserDataHandlers(). Of course, I couldn't use the 
full DOMDocumentImpl.cpp, it changed too much from 2.7 to 3.0. However, 
I just put the stuff you changed in callUserDataHandlers() into 2.7's 
version, and it did the trick.

Something else that I discovered: DOMUserDataHandler::handle()'s data 
parameter does not carry the data from src, but the one that has been 
registered with the DOMDocument - but it the 
DOMUserDataHandler::handle() docs don't say that anywhere. Not a problem 
really, but I find it confusing (maybe it is not so much though if you 
know that you have to register the data handler with the DOMDocument, 
which I didn't at the beginning).

However, I wonder if switching to 3.0 makes sense for me, rather than 
relying on a patched version of 2.7. How far is 3.0 from release? How 
stable is it?

Thanks & Cheers,

Uwe


Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing list| 
schrieb:
> Hi Uwe,
> I guess you are right, and Xerces doesn't expect the list of handlers 
> to change midway; can you try getting the latest DOMDocumentImpl.cpp 
> from SVN and try if it works?
>
> Thanks,
> Alberto
>


Re: importNode() does not call UserDataHandler

Posted by Alberto Massari <am...@datadirect.com>.
Hi Uwe,
I guess you are right, and Xerces doesn't expect the list of handlers 
to change midway; can you try getting the latest DOMDocumentImpl.cpp 
from SVN and try if it works?

Thanks,
Alberto

At 17.45 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>Hi Alberto,
>
>I'm not really sure if const_cast is so safe. Apparently, setting 
>user data (and modfying whatever tables Xerces uses to store it) 
>while in a DataHandler confuses Xerces so that it eventually 
>crashes. At least from what I can see it seems to invalidate the 
>enumerator that Xerces uses to iterate over its data handlers in 
>DOMDocumentImpl::callUserDataHandlers().
>
>Does Xerces 3.0 approach this in a different way, or is the 
>signature the only thing that changed? Because in the latter case, I 
>suppose switching to 3.0 won't solve my problem either.
>
>Cheers,
>
>Uwe
>
>
>Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>list| schrieb:
>>Hi Uwe,
>>actually there is a bug open for the "const" issue, that has been 
>>fixed in the 3.0 release (as it requires a signature change). In 
>>version 2.7 you have to use const_cast, but don't worry, it's safe...
>>
>>Alberto
>>
>>At 16.59 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>>>Thanks Alberto,
>>>
>>>The workaround does the trick. Hoever, I've got another problem at 
>>>my hands now, which I suspected to come to me beforehand (but I 
>>>never got that far before..): Since both the src and dst DOMNode 
>>>arguments of DataHandler::handle() are const, I cant attach user 
>>>data to the new node that's created by importNode().
>>>
>>>At first I hoped that Xerces would implicitely copy the user data 
>>>pointer from src to dst, while giving the DataHandler a chance to 
>>>fix what could become a mess, but apparently this is not so.
>>>
>>>Is there a proper way to get the user data from one node to 
>>>another? I can use const_cast<>, but that's surely not as things 
>>>are intended to be is it?
>>>
>>>Cheers,
>>>
>>>Uwe
>>>
>>>Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>>>list| schrieb:
>>>>At 11.49 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>>>>>Hi Alberto,
>>>>>
>>>>>Thanks a lot for the reply!
>>>>>
>>>>>I've resolved the debugging issue now; apparently the DLL was 
>>>>>older than the PDB, which doesn't help...
>>>>>
>>>>>So now I can debug into Xerces, and I traced the importNode() 
>>>>>call to DOMDocumentImpl::callUserDataHandlers(), where it 
>>>>>enumerates over the user data table. However, 
>>>>>userDataEnum.hasMoreElements() returns false on the first 
>>>>>iteration, which apparently means that there are no handlers, am 
>>>>>I correct? But as I said, my handler does get called when I delete nodes...
>>>>>
>>>>>Do you have any more clues?
>>>>
>>>>If I read the code right, the handler for importing nodes must be 
>>>>registered on the DOMDocument itself, so you can workaround the 
>>>>problem by registering the handler there; but by reading the 
>>>>specs this is wrong, as "the application can provide a handler 
>>>>that gets called when the node the object is associated to is 
>>>>being cloned, imported, or renamed". Unless someone else has 
>>>>problems with this, I'm going to fix this for 3.0.
>>>>
>>>>Alberto
>>>>
>>>>
>>>>>Cheers,
>>>>>
>>>>>Uwe
>>>>>
>>>>>
>>>>>Alberto Massari amassari-at-datadirect.com |xerces-c-users 
>>>>>mailing list| schrieb:
>>>>>>At 01.09 03/02/2007 +0100, you wrote:
>>>>>>>Hello,
>>>>>>>
>>>>>>>I overrid XercesDOMParser's startElement() method to attach 
>>>>>>>user data to each newly created DOMNode. This works fine, and 
>>>>>>>I can retreive the data later with getUserData().
>>>>>>>
>>>>>>>However, I now merge two documents into one DOM, and I use 
>>>>>>>importNode() for copying the nodes into the main document, 
>>>>>>>collecting the nodes in a DocumentFragment first, and then 
>>>>>>>adding them to the main document with replaceChild().
>>>>>>>
>>>>>>>a) The new nodes in the main document don't have the user data any more;
>>>>>>>b) The data handler is not called while executing 
>>>>>>>importNode(). However, it _is_ called when I delete the 
>>>>>>>parser, when all nodes it owns are deleted, which means that 
>>>>>>>it should be properly registered.
>>>>>>>
>>>>>>>Any clues what I could have done wrong here? I Use Xerces 2.7.0.
>>>>>>
>>>>>>Uwe,
>>>>>>the code for importNode calls the NODE_IMPORTED handler (unless 
>>>>>>you are cloning the entire document); can you verify if it invoked?
>>>>>>
>>>>>>>Cheers,
>>>>>>>
>>>>>>>Uwe
>>>>>>>
>>>>>>>P.S.: For some odd reason I never manage to debug into Xerces 
>>>>>>>from my application on my Windows XP/VS7.1 installation, 
>>>>>>>although the PDB and sources should be accessible; I compiled 
>>>>>>>Xerces myself. Does anyone have experience with this?
>>>>>>
>>>>>>Is the PDB in the same folder of the Xerces DLL being loaded?
>>>>>>
>>>>>>Alberto


Re: importNode() does not call UserDataHandler

Posted by 4p...@sneakemail.com.
Hi Alberto,

I'm not really sure if const_cast is so safe. Apparently, setting user 
data (and modfying whatever tables Xerces uses to store it) while in a 
DataHandler confuses Xerces so that it eventually crashes. At least from 
what I can see it seems to invalidate the enumerator that Xerces uses to 
iterate over its data handlers in DOMDocumentImpl::callUserDataHandlers().

Does Xerces 3.0 approach this in a different way, or is the signature 
the only thing that changed? Because in the latter case, I suppose 
switching to 3.0 won't solve my problem either.

Cheers,

Uwe


Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing list| 
schrieb:
> Hi Uwe,
> actually there is a bug open for the "const" issue, that has been 
> fixed in the 3.0 release (as it requires a signature change). In 
> version 2.7 you have to use const_cast, but don't worry, it's safe...
>
> Alberto
>
> At 16.59 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>> Thanks Alberto,
>>
>> The workaround does the trick. Hoever, I've got another problem at my 
>> hands now, which I suspected to come to me beforehand (but I never 
>> got that far before..): Since both the src and dst DOMNode arguments 
>> of DataHandler::handle() are const, I cant attach user data to the 
>> new node that's created by importNode().
>>
>> At first I hoped that Xerces would implicitely copy the user data 
>> pointer from src to dst, while giving the DataHandler a chance to fix 
>> what could become a mess, but apparently this is not so.
>>
>> Is there a proper way to get the user data from one node to another? 
>> I can use const_cast<>, but that's surely not as things are intended 
>> to be is it?
>>
>> Cheers,
>>
>> Uwe
>>
>> Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>> list| schrieb:
>>> At 11.49 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>>>> Hi Alberto,
>>>>
>>>> Thanks a lot for the reply!
>>>>
>>>> I've resolved the debugging issue now; apparently the DLL was older 
>>>> than the PDB, which doesn't help...
>>>>
>>>> So now I can debug into Xerces, and I traced the importNode() call 
>>>> to DOMDocumentImpl::callUserDataHandlers(), where it enumerates 
>>>> over the user data table. However, userDataEnum.hasMoreElements() 
>>>> returns false on the first iteration, which apparently means that 
>>>> there are no handlers, am I correct? But as I said, my handler does 
>>>> get called when I delete nodes...
>>>>
>>>> Do you have any more clues?
>>>
>>> If I read the code right, the handler for importing nodes must be 
>>> registered on the DOMDocument itself, so you can workaround the 
>>> problem by registering the handler there; but by reading the specs 
>>> this is wrong, as "the application can provide a handler that gets 
>>> called when the node the object is associated to is being cloned, 
>>> imported, or renamed". Unless someone else has problems with this, 
>>> I'm going to fix this for 3.0.
>>>
>>> Alberto
>>>
>>>
>>>> Cheers,
>>>>
>>>> Uwe
>>>>
>>>>
>>>> Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>>>> list| schrieb:
>>>>> At 01.09 03/02/2007 +0100, you wrote:
>>>>>> Hello,
>>>>>>
>>>>>> I overrid XercesDOMParser's startElement() method to attach user 
>>>>>> data to each newly created DOMNode. This works fine, and I can 
>>>>>> retreive the data later with getUserData().
>>>>>>
>>>>>> However, I now merge two documents into one DOM, and I use 
>>>>>> importNode() for copying the nodes into the main document, 
>>>>>> collecting the nodes in a DocumentFragment first, and then adding 
>>>>>> them to the main document with replaceChild().
>>>>>>
>>>>>> a) The new nodes in the main document don't have the user data 
>>>>>> any more;
>>>>>> b) The data handler is not called while executing importNode(). 
>>>>>> However, it _is_ called when I delete the parser, when all nodes 
>>>>>> it owns are deleted, which means that it should be properly 
>>>>>> registered.
>>>>>>
>>>>>> Any clues what I could have done wrong here? I Use Xerces 2.7.0.
>>>>>
>>>>> Uwe,
>>>>> the code for importNode calls the NODE_IMPORTED handler (unless 
>>>>> you are cloning the entire document); can you verify if it invoked?
>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Uwe
>>>>>>
>>>>>> P.S.: For some odd reason I never manage to debug into Xerces 
>>>>>> from my application on my Windows XP/VS7.1 installation, although 
>>>>>> the PDB and sources should be accessible; I compiled Xerces 
>>>>>> myself. Does anyone have experience with this?
>>>>>
>>>>> Is the PDB in the same folder of the Xerces DLL being loaded?
>>>>>
>>>>> Alberto
>


Re: importNode() does not call UserDataHandler

Posted by Alberto Massari <am...@datadirect.com>.
Hi Uwe,
actually there is a bug open for the "const" issue, that has been 
fixed in the 3.0 release (as it requires a signature change). In 
version 2.7 you have to use const_cast, but don't worry, it's safe...

Alberto

At 16.59 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>Thanks Alberto,
>
>The workaround does the trick. Hoever, I've got another problem at 
>my hands now, which I suspected to come to me beforehand (but I 
>never got that far before..): Since both the src and dst DOMNode 
>arguments of DataHandler::handle() are const, I cant attach user 
>data to the new node that's created by importNode().
>
>At first I hoped that Xerces would implicitely copy the user data 
>pointer from src to dst, while giving the DataHandler a chance to 
>fix what could become a mess, but apparently this is not so.
>
>Is there a proper way to get the user data from one node to another? 
>I can use const_cast<>, but that's surely not as things are intended 
>to be is it?
>
>Cheers,
>
>Uwe
>
>Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>list| schrieb:
>>At 11.49 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>>>Hi Alberto,
>>>
>>>Thanks a lot for the reply!
>>>
>>>I've resolved the debugging issue now; apparently the DLL was 
>>>older than the PDB, which doesn't help...
>>>
>>>So now I can debug into Xerces, and I traced the importNode() call 
>>>to DOMDocumentImpl::callUserDataHandlers(), where it enumerates 
>>>over the user data table. However, userDataEnum.hasMoreElements() 
>>>returns false on the first iteration, which apparently means that 
>>>there are no handlers, am I correct? But as I said, my handler 
>>>does get called when I delete nodes...
>>>
>>>Do you have any more clues?
>>
>>If I read the code right, the handler for importing nodes must be 
>>registered on the DOMDocument itself, so you can workaround the 
>>problem by registering the handler there; but by reading the specs 
>>this is wrong, as "the application can provide a handler that gets 
>>called when the node the object is associated to is being cloned, 
>>imported, or renamed". Unless someone else has problems with this, 
>>I'm going to fix this for 3.0.
>>
>>Alberto
>>
>>
>>>Cheers,
>>>
>>>Uwe
>>>
>>>
>>>Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>>>list| schrieb:
>>>>At 01.09 03/02/2007 +0100, you wrote:
>>>>>Hello,
>>>>>
>>>>>I overrid XercesDOMParser's startElement() method to attach user 
>>>>>data to each newly created DOMNode. This works fine, and I can 
>>>>>retreive the data later with getUserData().
>>>>>
>>>>>However, I now merge two documents into one DOM, and I use 
>>>>>importNode() for copying the nodes into the main document, 
>>>>>collecting the nodes in a DocumentFragment first, and then 
>>>>>adding them to the main document with replaceChild().
>>>>>
>>>>>a) The new nodes in the main document don't have the user data any more;
>>>>>b) The data handler is not called while executing importNode(). 
>>>>>However, it _is_ called when I delete the parser, when all nodes 
>>>>>it owns are deleted, which means that it should be properly registered.
>>>>>
>>>>>Any clues what I could have done wrong here? I Use Xerces 2.7.0.
>>>>
>>>>Uwe,
>>>>the code for importNode calls the NODE_IMPORTED handler (unless 
>>>>you are cloning the entire document); can you verify if it invoked?
>>>>
>>>>>Cheers,
>>>>>
>>>>>Uwe
>>>>>
>>>>>P.S.: For some odd reason I never manage to debug into Xerces 
>>>>>from my application on my Windows XP/VS7.1 installation, 
>>>>>although the PDB and sources should be accessible; I compiled 
>>>>>Xerces myself. Does anyone have experience with this?
>>>>
>>>>Is the PDB in the same folder of the Xerces DLL being loaded?
>>>>
>>>>Alberto


Re: importNode() does not call UserDataHandler

Posted by 4p...@sneakemail.com.
Thanks Alberto,

The workaround does the trick. Hoever, I've got another problem at my 
hands now, which I suspected to come to me beforehand (but I never got 
that far before..): Since both the src and dst DOMNode arguments of 
DataHandler::handle() are const, I cant attach user data to the new node 
that's created by importNode().

At first I hoped that Xerces would implicitely copy the user data 
pointer from src to dst, while giving the DataHandler a chance to fix 
what could become a mess, but apparently this is not so.

Is there a proper way to get the user data from one node to another? I 
can use const_cast<>, but that's surely not as things are intended to be 
is it?

Cheers,

Uwe

Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing list| 
schrieb:
> At 11.49 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>> Hi Alberto,
>>
>> Thanks a lot for the reply!
>>
>> I've resolved the debugging issue now; apparently the DLL was older 
>> than the PDB, which doesn't help...
>>
>> So now I can debug into Xerces, and I traced the importNode() call to 
>> DOMDocumentImpl::callUserDataHandlers(), where it enumerates over the 
>> user data table. However, userDataEnum.hasMoreElements() returns 
>> false on the first iteration, which apparently means that there are 
>> no handlers, am I correct? But as I said, my handler does get called 
>> when I delete nodes...
>>
>> Do you have any more clues?
>
> If I read the code right, the handler for importing nodes must be 
> registered on the DOMDocument itself, so you can workaround the 
> problem by registering the handler there; but by reading the specs 
> this is wrong, as "the application can provide a handler that gets 
> called when the node the object is associated to is being cloned, 
> imported, or renamed". Unless someone else has problems with this, I'm 
> going to fix this for 3.0.
>
> Alberto
>
>
>> Cheers,
>>
>> Uwe
>>
>>
>> Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>> list| schrieb:
>>> At 01.09 03/02/2007 +0100, you wrote:
>>>> Hello,
>>>>
>>>> I overrid XercesDOMParser's startElement() method to attach user 
>>>> data to each newly created DOMNode. This works fine, and I can 
>>>> retreive the data later with getUserData().
>>>>
>>>> However, I now merge two documents into one DOM, and I use 
>>>> importNode() for copying the nodes into the main document, 
>>>> collecting the nodes in a DocumentFragment first, and then adding 
>>>> them to the main document with replaceChild().
>>>>
>>>> a) The new nodes in the main document don't have the user data any 
>>>> more;
>>>> b) The data handler is not called while executing importNode(). 
>>>> However, it _is_ called when I delete the parser, when all nodes it 
>>>> owns are deleted, which means that it should be properly registered.
>>>>
>>>> Any clues what I could have done wrong here? I Use Xerces 2.7.0.
>>>
>>> Uwe,
>>> the code for importNode calls the NODE_IMPORTED handler (unless you 
>>> are cloning the entire document); can you verify if it invoked?
>>>
>>>> Cheers,
>>>>
>>>> Uwe
>>>>
>>>> P.S.: For some odd reason I never manage to debug into Xerces from 
>>>> my application on my Windows XP/VS7.1 installation, although the 
>>>> PDB and sources should be accessible; I compiled Xerces myself. 
>>>> Does anyone have experience with this?
>>>
>>> Is the PDB in the same folder of the Xerces DLL being loaded?
>>>
>>> Alberto
>


Re: importNode() does not call UserDataHandler

Posted by Alberto Massari <am...@datadirect.com>.
At 11.49 05/02/2007 +0100, 4pzbrog02@sneakemail.com wrote:
>Hi Alberto,
>
>Thanks a lot for the reply!
>
>I've resolved the debugging issue now; apparently the DLL was older 
>than the PDB, which doesn't help...
>
>So now I can debug into Xerces, and I traced the importNode() call 
>to DOMDocumentImpl::callUserDataHandlers(), where it enumerates over 
>the user data table. However, userDataEnum.hasMoreElements() returns 
>false on the first iteration, which apparently means that there are 
>no handlers, am I correct? But as I said, my handler does get called 
>when I delete nodes...
>
>Do you have any more clues?

If I read the code right, the handler for importing nodes must be 
registered on the DOMDocument itself, so you can workaround the 
problem by registering the handler there; but by reading the specs 
this is wrong, as "the application can provide a handler that gets 
called when the node the object is associated to is being cloned, 
imported, or renamed". Unless someone else has problems with this, 
I'm going to fix this for 3.0.

Alberto


>Cheers,
>
>Uwe
>
>
>Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing 
>list| schrieb:
>>At 01.09 03/02/2007 +0100, you wrote:
>>>Hello,
>>>
>>>I overrid XercesDOMParser's startElement() method to attach user 
>>>data to each newly created DOMNode. This works fine, and I can 
>>>retreive the data later with getUserData().
>>>
>>>However, I now merge two documents into one DOM, and I use 
>>>importNode() for copying the nodes into the main document, 
>>>collecting the nodes in a DocumentFragment first, and then adding 
>>>them to the main document with replaceChild().
>>>
>>>a) The new nodes in the main document don't have the user data any more;
>>>b) The data handler is not called while executing importNode(). 
>>>However, it _is_ called when I delete the parser, when all nodes 
>>>it owns are deleted, which means that it should be properly registered.
>>>
>>>Any clues what I could have done wrong here? I Use Xerces 2.7.0.
>>
>>Uwe,
>>the code for importNode calls the NODE_IMPORTED handler (unless you 
>>are cloning the entire document); can you verify if it invoked?
>>
>>>Cheers,
>>>
>>>Uwe
>>>
>>>P.S.: For some odd reason I never manage to debug into Xerces from 
>>>my application on my Windows XP/VS7.1 installation, although the 
>>>PDB and sources should be accessible; I compiled Xerces myself. 
>>>Does anyone have experience with this?
>>
>>Is the PDB in the same folder of the Xerces DLL being loaded?
>>
>>Alberto


Re: importNode() does not call UserDataHandler

Posted by 4p...@sneakemail.com.
Hi Alberto,

Thanks a lot for the reply!

I've resolved the debugging issue now; apparently the DLL was older than 
the PDB, which doesn't help...

So now I can debug into Xerces, and I traced the importNode() call to 
DOMDocumentImpl::callUserDataHandlers(), where it enumerates over the 
user data table. However, userDataEnum.hasMoreElements() returns false 
on the first iteration, which apparently means that there are no 
handlers, am I correct? But as I said, my handler does get called when I 
delete nodes...

Do you have any more clues?

Cheers,

Uwe


Alberto Massari amassari-at-datadirect.com |xerces-c-users mailing list| 
schrieb:
> At 01.09 03/02/2007 +0100, you wrote:
>> Hello,
>>
>> I overrid XercesDOMParser's startElement() method to attach user data 
>> to each newly created DOMNode. This works fine, and I can retreive 
>> the data later with getUserData().
>>
>> However, I now merge two documents into one DOM, and I use 
>> importNode() for copying the nodes into the main document, collecting 
>> the nodes in a DocumentFragment first, and then adding them to the 
>> main document with replaceChild().
>>
>> a) The new nodes in the main document don't have the user data any more;
>> b) The data handler is not called while executing importNode(). 
>> However, it _is_ called when I delete the parser, when all nodes it 
>> owns are deleted, which means that it should be properly registered.
>>
>> Any clues what I could have done wrong here? I Use Xerces 2.7.0.
>
> Uwe,
> the code for importNode calls the NODE_IMPORTED handler (unless you 
> are cloning the entire document); can you verify if it invoked?
>
>> Cheers,
>>
>> Uwe
>>
>> P.S.: For some odd reason I never manage to debug into Xerces from my 
>> application on my Windows XP/VS7.1 installation, although the PDB and 
>> sources should be accessible; I compiled Xerces myself. Does anyone 
>> have experience with this?
>
> Is the PDB in the same folder of the Xerces DLL being loaded?
>
> Alberto


Re: importNode() does not call UserDataHandler

Posted by Alberto Massari <am...@datadirect.com>.
At 01.09 03/02/2007 +0100, you wrote:
>Hello,
>
>I overrid XercesDOMParser's startElement() method to attach user 
>data to each newly created DOMNode. This works fine, and I can 
>retreive the data later with getUserData().
>
>However, I now merge two documents into one DOM, and I use 
>importNode() for copying the nodes into the main document, 
>collecting the nodes in a DocumentFragment first, and then adding 
>them to the main document with replaceChild().
>
>a) The new nodes in the main document don't have the user data any more;
>b) The data handler is not called while executing importNode(). 
>However, it _is_ called when I delete the parser, when all nodes it 
>owns are deleted, which means that it should be properly registered.
>
>Any clues what I could have done wrong here? I Use Xerces 2.7.0.

Uwe,
the code for importNode calls the NODE_IMPORTED handler (unless you 
are cloning the entire document); can you verify if it invoked?

>Cheers,
>
>Uwe
>
>P.S.: For some odd reason I never manage to debug into Xerces from 
>my application on my Windows XP/VS7.1 installation, although the PDB 
>and sources should be accessible; I compiled Xerces myself. Does 
>anyone have experience with this?

Is the PDB in the same folder of the Xerces DLL being loaded?

Alberto