[jdom-interest] Validation Catch22
jbernard at rochester.rr.com
Fri Dec 22 06:09:11 PST 2000
I am using JDOM b5.
I would like to be able to turn on validation (builder.setValidation(true)) with the behavior being: validate if a DTD is specified in the document, otherwise don't validate. Unfortunately Xerces throws an exception if validation is true and no DTD is supplied.
The problem is that my application doesn't mandate inclusion of a DTD and I don't know whether or not a DTD is supplied in the XML document when I call builder.build.
The hack I employed is to catch JDOMException("...element must be declared...") exception and retry without validation. This seems particularly ugly as there isn't a specific exception indicating the absence of a DTD. The exception may be thrown because of an invalid element in the document as well as a missing DTD.
Is there a way to achieve the desired effect short of making a DTD mandatory?
Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jdom-interest