[jdom-interest] DTD information not present in DocType

philip.nelson at omniresources.com philip.nelson at omniresources.com
Thu Sep 27 08:28:47 PDT 2001


> Using the latest JDOM from CVS, I failed to get any 
> information stored into 
> DocType. I managed to track this problem down to SAXBuilder 
> that performs the 
> following test in configureParser():
> 
>          // 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
>              }
>          }
> 
> Why is the DeclHandler registration dependent on entity 
> expansion? Is that a 
> leftover from the time where DTD information was not stored 
> in DocType?

This is by design.  Unfortunately, it's not by JDOM design but by SAX2
design.  Whether or not you can get the internal subset is set by the
setting of this property.  The same property determines if entities are
expanded or not.  What this means is we don't have separate flags for
building the internal subset and expanding entities.

The only way to get around it that I am aware of is to always use the
declHandler and expand the entities into the content ourselves if the expand
flag is true (the default).  This would in turn require the internal subset
to be represented as something other than a string so we code decode the
entity reference.  That would be required for Elliotte's proposal for
getting the attribute types also, even if the type was accessed from the
attribute itself as Elliotte seems to be insisting on.  So if this is a good
idea, then somebody has to volunteer to do it.


> Removing the test on expand fixes the problem.
> 
> Another question: Shouldn't JDOM also attempt to register 
> DeclHandlers using 
> the alternate property name 
"http://xml.org/sax/handlers/DeclHandler" just as 
it does for LexicalHandlers?

I don't know.  Elliotte's and Brett's references both show it the way we
have it, as a property.  Anyone?



More information about the jdom-interest mailing list