Why SAX needs namespace support

david at megginson.com david at megginson.com
Tue Jan 26 17:14:58 GMT 1999

Simon St.Laurent writes:

 > I'd like to see namespace support in SAX; however, I'd prefer not
 > to implement it by piling that functionality into parsers, creating
 > yet another monolith.  While the monoliths survive, I think we can
 > do better.

Perl's motto is "there's more than one way to do it"; SAX's should be
"we'll try to let you do it any way you want."  Many XML parsers
either provide or are about to provide native namespace processing, so
it would not make sense to force namespace processing to be a separate
filter layer; other parsers probably will not provide namespace
processing natively, so it makes sense to allow namespace processing
to exist in a filter layer.

Try this on.  First, we create a new exception:

  public class SAXUnsupportedFeatureException extends SAXException

then we add some fun new methods to the extended Parser class

  public void setNamespaceProcessing (boolean flag)
    throws SAXUnsupportedFeatureException;

  public void setValidation (boolean flag)
    throws SAXUnsupportedFeatureException;

  public void setEntityExpansion (boolean flag)
    throws SAXUnsupportedFeatureException;

There is no default for any of these -- some SAX drivers may validate
or expand entities by default, while others may not -- and drivers are 
free to throw a SAXUnsupportedFeatureException for any call to any of
these.  If an application needs to be certain that it is or isn't
validating, that it is or isn't getting namespace processing, or that
it is or isn't getting external entity expansion, it has to call one
of these methods explicitly; if it doesn't care, then it can take
whatever the parser wants to give it (the status quo for SAX 1.0).

All the best,


David Megginson                 david at megginson.com

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)

More information about the Xml-dev mailing list