[jdom-interest] Newbie: Schema validation of a document being built via JDOM

John Methot johnm at lariat.com
Fri Mar 16 17:06:02 PST 2001


I've read back through the archives since November for all
validation-related topics.  I see a lot of questions about validating
documents that are being read.

My interest is in using JDOM to create documents programmatically.  But I
don't see anything in the javadoc or tutorials on JDOM that say I can
validate a document as I'm building it.  I can specify a systemID (a DTD or,
preferably, a schema) when I create a Document object.  But then it would
seem useful if when I called Element.addAttribute() or Element.addElement()
(for example) I would get an exception if I tried to add an attribute or
child element that violated the schema.

I'm pretty sure this isn't there now (please correct me if it is and I'm
missing it).

The only approach I can see right now is to build the entire document and
then validate it by parsing the whole thing, but that wouldn't give me much
visibility into the structural errors as they occur.

Anybody else have the desire to validate a document as it is built?  Am I
thinking about this all wrong?

TIA,

John Methot




More information about the jdom-interest mailing list