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] <<mailto:[EMAIL PROTECTED]>>
[Internet] http://www.abaXX.com <http://www.abaxx.com/>



Attachment: EventTester.java
Description: Binary data

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

Reply via email to