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

Patrick Dowler Patrick.Dowler at nrc.ca
Mon Nov 6 15:40:53 PST 2000


Umm, isn't the whole point of JDOM to have an object model rather than an
event stream? If you want events, wouldn't you use SAX directly?

The thing described below could be implemented as an event handler (using
SAX) or as a tree-walker (using JDOM). You SAXProcessor coudl just as
easily be a JDOMWalker, yes? 

        Document doc = ...

        JDOMWalker walker = new JDOMWalker();
        walker.addProcessor( "book", new BookHandler() );
        walker.walk( doc );


> ----- 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" );
> 
> 
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
-- 

Patrick Dowler
Canadian Astronomy Data Centre




More information about the jdom-interest mailing list