[jdom-interest] SAXBuilder setFeature() and setProperty() exceptions

Elliotte Rusty Harold elharo at metalab.unc.edu
Tue Apr 16 14:15:57 PDT 2002


As indicated in the JavaDoc for SAXBuilder setFeature() and setProperty():

NOTE: SAXBuilder requires that some particular features of the SAX 
parser be set up in certain ways for it to work properly. The list of 
such features may change in the future. Therefore, the use of this 
method may cause parsing to break, and even if it doesn't break anything 
today it might break parsing in a future JDOM version, because what JDOM 
parsers require may change over time. Use with caution.

That's an important note. I wonder if we shouldn't also enforce it in 
code? That is, would it be a good idea to have  setFeature() and 
setProperty() throw an exception (probably something like 
 BuilderConfigrationException extends JDOMException)  if someone passes 
a known conflicting value for  such a feature; e.g. tries to turn 
namespace processing off.

The SAX equivalents of these methods in XMLReader are declared to throw  
SAXNotRecognizedException 
<http://java.sun.com/j2se/1.4/docs/api/org/xml/sax/SAXNotRecognizedException.html> 
and SAXNotSupportedException 
<http://java.sun.com/j2se/1.4/docs/api/org/xml/sax/SAXNotSupportedException.html>

Along a similar note, we're delaying those exceptions until a document 
is actually built.  I'd prefer them to be thrown immediately  until the 
unrecognized;/unsupported feature/property is set. I think the reason we 
delay them is to allow the parser to be swapped out after the builder is 
 initially constrcuted, but is this really something that's needed? 
Currently, that functionality is only available from  the protected 
interface. I don't see anyway to access from the public interface. Is it 
really so much to ask that the client create a new instance of 
SAXBuilder if they want to use a different parser?

-- 
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|           The XML Bible, 2nd Edition (IDG Books, 2001)             |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:   http://www.cafeaulait.org/     | 
|  Read Cafe con Leche for XML News:  http://www.cafeconleche.org/   |
+----------------------------------+---------------------------------+





More information about the jdom-interest mailing list