<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4134.600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>
<DIV><FONT size=2>I am using JDOM b5.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>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.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>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.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>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. </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Is there a way to achieve the desired effect short of making a
DTD mandatory? </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Thanks in advance</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Jeddy</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2></FONT> </DIV></FONT></DIV></BODY></HTML>