[jdom-interest] SAXBuilder bug w.r.t internal DTD subset
Elliotte Rusty Harold
elharo at metalab.unc.edu
Fri Apr 12 10:24:13 PDT 2002
Currently SAXBuilder only sets the DeclHandler if the parser is not
expanding entities. However, even if the parser is expanding entities,
we still need the DeclHandler to set up the internal DTD subset. The fix
is straight-forward. Remove the code to set the declaration-handler from
the if block. That is, change this:
if (!expand) {
try {
parser.setProperty(
"http://xml.org/sax/properties/declaration-handler",
contentHandler);
} catch (SAXNotSupportedException e) {
// No lexical reporting available
} catch (SAXNotRecognizedException e) {
// No lexical reporting available
}
}
to this:
// Set the DeclHandler
try {
parser.setProperty(
"http://xml.org/sax/properties/declaration-handler",
contentHandler);
} catch (SAXNotSupportedException e) {
// The parser does not support the DeclHandler interface
} catch (SAXNotRecognizedException e) {
// The parser does not support the DeclHandler interface
}
I don't think this break anybody's code and all the tests still run. A
patch is attached. I deleted my code base and checked it out from
scratch so hopefully this is the only change in the patch.
--
+-----------------------+------------------------+-------------------+
| 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/ |
+----------------------------------+---------------------------------+
-------------- next part --------------
Index: src/java/org/jdom/input/SAXBuilder.java
===================================================================
RCS file: /home/cvspublic/jdom/src/java/org/jdom/input/SAXBuilder.java,v
retrieving revision 1.65
diff -d -u -r1.65 SAXBuilder.java
--- src/java/org/jdom/input/SAXBuilder.java 2002/04/11 06:19:10 1.65
+++ src/java/org/jdom/input/SAXBuilder.java 2002/04/13 01:30:28
@@ -574,17 +574,16 @@
}
}
- // Try setting the DeclHandler if entity expansion is off
- if (!expand) {
- try {
- parser.setProperty(
- "http://xml.org/sax/properties/declaration-handler",
- contentHandler);
- } catch (SAXNotSupportedException e) {
- // No lexical reporting available
- } catch (SAXNotRecognizedException e) {
- // No lexical reporting available
- }
+ // Set the DeclHandler. This is needed for the internal
+ // DTD subset and any unresolved entity references.
+ try {
+ parser.setProperty(
+ "http://xml.org/sax/properties/declaration-handler",
+ contentHandler);
+ } catch (SAXNotSupportedException e) {
+ // The parser does not support the DeclHandler interface
+ } catch (SAXNotRecognizedException e) {
+ // The parser does not support the DeclHandler interface
}
// Set validation.
More information about the jdom-interest
mailing list