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

Robert (Jamie) Munro rjmunro at arjam.net
Mon Oct 28 09:25:25 PST 2002


I realise that what I am asking would be really trivial if I knew what I was
doing, but I am still learning both XML and Java.

I am writing a database replication project which makes changes to a JDBC
connected database from XML instructions like this:

<?xml version="1.0" encoding="UTF-8"?>
<FibrePacket>
  <FibreData>
    <Table name="PEOPLE">
      <UPDATES>
        <UPDATE ID="12" USER="SYSDBA" DATE="2002-10-28 16:23:47">
          <RECORD>7</RECORD>
          <FIELD>TITLE</FIELD>
          <OLD_VALUE>Mrs</OLD_VALUE>
          <NEW_VALUE>Mr</NEW_VALUE>
        </UPDATE>
      </UPDATES>
      <NEWRECORDS>
        <RECORD ID="13">
          <TITLE>Mr</TITLE>
          <FIRST_NAME>Patrick</FIRST_NAME>
          <SURNAME>McDonald</SURNAME>
        </RECORD>
      </NEWRECORDS>
    </Table>
  </FibreData>
</FibrePacket>

Obviously that example just contains one update and one new record for the
PEOPLE table. In actual use there will be many records and many tables. The
above translates to the following SQL statements:

update PEOPLE set TITLE='Mr' where ID=7 and TITLE='Mrs';
insert into PEOPLE fields (ID, TITLE, FIRST_NAME, SURNAME) values (13, 'Mr',
'Patrick', 'McDonald');

Would Element Scanner (from the contrib.) be a good way to parse and apply
this file? The idea is that where there is some sort of error, the element
would be kept for later processing, with a note about the error added to the
element. All the successful changes can be forgotten as soon as they are
applied, and their memory collected by the garbage collector. I don't want
to wait until everything is parsed into memory before applying it to the
database, because that could consume a lot of memory (there may be hundreds
or even thousands of changes in the XML files once the project is fully up
and running).

Thanks for your help,

Robert Munro

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]

It looks simple to fix, but I don't know the best solution to do it myself.




More information about the jdom-interest mailing list