[jdom-interest] Newbie question: contrib - Element Scanner

Laurent Bihanic laurent.bihanic at atosorigin.com
Mon Nov 25 04:50:47 PST 2002


Robert (Jamie) Munro wrote:

> Would Element Scanner (from the contrib.) be a good way to parse and apply
> this file?

Yes, ElementScanner could apply but your XML structure is not quite easy to 
deal with. Ideally, I suppose you'd like ElementScanner to notify you of 
<RECORD> and <UPDATE> elements. It can but you would then loose the 
information from the <Table> and <UPDATES/NEWRECORDS> elements, i.e. 
ElementScanner won't store which table to target or what kind of action is to 
be performed.
On the other hand, you can choose to request ElementScanner to provide you 
with the <Table> elements containing all <RECORD> and <UPDATE> descendants. 
Bigger chunks.

One good way to get both the table and action information and JDOM Elements is 
to combine ElementScanner (to retrieve the <RECORD> and <UPDATE> nodes) with a 
do-it-yourself SAX filter (XMLFilter) that will store the current target table 
name and the current type of action (insert/update).

> Ps. When I try to compile ElementScanner, I get:
> org/jdom/contrib/input/scanner/ElementScanner.java [752:1] unreported
> exception java.io.IOException; must be caught or declared to be thrown
>          super(factory);
>          ^
> 1 error
> Errors compiling ElementScanner [LMod]

These errors come from ElementScanner relying on the latest JDOM API (from 
CVS) while you are trying to compile it against JDOM beta 8.

To fix those, you need to:
  - add a "throws Exception" clause to "protected SAXHandler 
createContentHandler()"
  - add a "throws IOException" clause to "public ElementBuilder(JDOMFactory)"

Laurent




More information about the jdom-interest mailing list