You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Alexander Weinmann <Al...@abaxx.de> on 2001/04/25 11:27:29 UTC

WG: Problem with events

Hello Xerces Developers,

The Xerces Users list would not give me any response
on this. But I absolutely want to use the dom events
to implement my personal xml editor.

So could somebody just compile the small sample 
Program below and tell me what is wrong with it ...
or simply send me to lines of sample code that does the
job ...

I simply do not know how to catch "MutationEvents",
when I manipulate attributes:



>  -----Urspr�ngliche Nachricht-----
> Von: 	Alexander Weinmann  
> Gesendet:	Dienstag, 24. April 2001 09:08
> An:	'xerces-j-user@xml.apache.org'
> Betreff:	Problem with events
> 
> Hello Xerces-Users,
> 
> 
> I would like to use the DOM-Level-2 Event-Model implemented in 
> Xerces. Especially I want to get notifications about any sort
> of document manipulations (Mutation Events). At the moment, 
> I only managed to do that for Adding/Removing of nodes. But 
> I need the same effect for attribute changes.  
> 
> Could samebody tell me what is wrong in my example code:
> ( I use Xerces 1.3.0)
> 
> 
> import org.w3c.dom.*;
> import org.apache.xerces.dom.*;
> import org.w3c.dom.events.*;
> import org.apache.xerces.dom.events.*;
> import org.xml.sax.*;
> import javax.xml.parsers.*;
> 
> public class EventTester  {
> 
>   public static void main(String[] args ) throws Exception{
>     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
>     DocumentBuilder builder = factory.newDocumentBuilder();
>     Document doc = builder.newDocument();
>     final String DOM_ATTR_MODIFIED = "DOMAttrModified";
>     EventListener eventListener = new 
>       EventListener(){
>         public void handleEvent(Event ev) {
>           MutationEvent mutationEvent= (MutationEvent)ev;
>           System.out.println("Here we are: "+mutationEvent.getType()+
>                              " on "+mutationEvent.getRelatedNode().
>                              getNodeName());
>         }};
>     EventTarget eventTarget=(org.w3c.dom.events.EventTarget)doc;
>     eventTarget.addEventListener("DOMAttrModified",eventListener,false);
>     Element el = doc.createElement("tester");
>     doc.appendChild(el);
>     // Here I expect to get an event, but I do not get it ...
>     el.setAttribute("test","mytest");
>     System.exit(0);
>   }
> } 
> 
> 
> 
> 
>  <<EventTester.java>> 
> 
> 
> abaXX 
> TECHNOLOGY AG
> Alexander Weinmann
> Development Engineer Training
> 
> [Address] Forststrasse 7, 
> 70174 Stuttgart, 
> Germany
> [Phone] +49-(711)-61-41-6 - 1541
> [Fax] +49-(711)-61-41-6 - 1111
> [E-mail] <<m...@abaxx.de>>
> [Internet] http://www.abaXX.com <http://www.abaxx.com/>
> 
> 
>