[jdom-interest] Newbie question: ResultSetBuilder

Robert (Jamie) Munro rjmunro at arjam.net
Thu Sep 5 10:04:51 PDT 2002

Having not written any Java before, except "Hello World", whilst I was
trying to use Java to read some data from a database and output it as XML, I
thought to myself "This is much harder than it should be". Then I found
JDOM's XMLOutputter while looking for a way to turn the DOM I was building
back into XML. I then discoverd the rest of JDOM, and realised that it
didn't have to be as hard a job as it had been until that point.

I then discoverd ResultSetBuilder which did almost everything I needed to do
already anyway. There are 2 problems that I found and solved, but possibly
not by the best method.

Firstly, I needed to get the results of several queries and store them in a
single XML file. I found myself doing the slightly silly looking:


Wouldn't it be more sensible for the builders to build root elements, rather
than whole documents, or (more probable) am I missing something?

Secondly, I needed to be able to differentiate nulls from empty strings, so
I have added a method to resultSetBuilder called setNullAttrib. It takes two
strings, one is an attribute name and the other is a value - I use "Null"
and "Yes". If it is called, it gives that attribute to fields that were null
(ie <fieldname Null="Yes" /> rather than just <fieldname  />. Do other
people think this is a good idea? Where do I submit my changes for inclusion
in the main distribution?


Robert J Munro

More information about the jdom-interest mailing list