You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by sa...@ca.ibm.com on 2001/03/29 19:02:18 UTC

Re: DOM Events problem (with patch)

Hi Torkel,

I read the DOM Events spec, and have the same understanding as you do.

The problem is that in class "NodeImpl" (org/apache/xerces/dom/NodeIml.java
line 1159), we only get the owner element when the event "DOMAttrModified"
is registered.

My fix is to get the owner element no matter whether "DOMAttrModified" is
registered. The patch file is attached. Could someone check it in?

diff -w -r1.38 NodeImpl.java
1155a1156
>                 owner=((NodeImpl)(enclosingAttr.getOwnerElement()));
1159d1159
<                 owner=((NodeImpl)(enclosingAttr.getOwnerElement()));

Cheers,
Sandy Gao
Software Developer, IBM Canada
(1-416) 448-3255
sandygao@ca.ibm.com

(See attached file: diff.txt)



                                                                                                                        
                    "Torkel Dominique"                                                                                  
                    <torkel.dominique@h       To:     <xe...@xml.apache.org>                                    
                    otsip.com>                cc:                                                                       
                                              Subject:     DOM Events problem                                           
                    03/26/2001 06:44 AM                                                                                 
                    Please respond to                                                                                   
                    xerces-j-user                                                                                       
                                                                                                                        
                                                                                                                        



Hi,

I'm using xerces-J 1.3.0 and have a problem with DOM events.
I have the following part of an XML document, which I parse into a DOM
tree:

<a>
 <b c="10">yes</b>
</a>

Now I register an EventListener to node a:

node_a.addEventListener("DOMSubtreeModified", eventLstener, false);

If I now change the value of element "b" (e.g. from "yes" to "no"), I
receive an event as expected.
But, if I change the value of attribute "c" (e.g. from "10" to "11"), I do
not receive any event.(WHY??)

If I, on the other hand, listens for a "DOMAttrModified" event,

node_a.addEventListener("DOMAttrModified", eventLstener, false);

and change the value of attribute "c", I receive an event. After reading
the
DOM Events spec, my understanding is that the "DOMSubtreeModified" event
should be a general event type which can be used instead of any of the
other
mutation events, including the "DOMAttrModified" event. If this is correct
then why don't I receive the event in the first example?

Even more funny is that if I listen to both "DOMSubtreeModified" events and
"DOMAttrModified" events, I receive two events when I change the value of
attribute "c", one "DOMSubtreeModified" event and one "DOMAttrModified"
event! Why is this?

Is there something that I have misunderstood?

Thanks,
Torkel Dominique
Hotsip
Sweden


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org