[jdom-interest] Re: Proposal: JDOM event based processing

Joseph Bowbeer jozart at csi.com
Mon Nov 6 12:38:12 PST 2000

I think this idea has potential.  It might simplify some things I may
want to do.


1. Implement your SAXProcessor as an XMLFilter so it can be plugged into
a filter chain.

2. Add the XPath expression to the event so one event handler can handle
several different Element events unambiguously.

3. Use Beans-style naming to aid introspection.  This way, Element event
listeners and Element event sources can be connected auto-visually using

----- original message -----

James Strachan james at metastuff.com
Mon, 6 Nov 2000 12:17:48 -0000

What I'd like to be able to do is to do event based processing of an XML
document via JDOM, avoiding the need to use SAX directly. Consider the
following interface proposal

  package org.jdom;
  public interface ElementHandler
    public void handle( Element element ) throws JDOMException;

  public BookHandler implements ElementHandler {
    public void handle( Element book ) throws JDOMException {
      Element title = book.getChild( "title" );
      Element author = book.getChild( "author" );

  SAXProcessor processor = new SAXProcessor();
  processor.addProcessor( "//book", new BookHandler() );
  processor.process( "books.xml" );

More information about the jdom-interest mailing list