[cxml-devel] SAX handler

David Lichteblau david at lichteblau.com
Wed Sep 10 16:01:26 UTC 2008


Hi,

Quoting Andy Chambers (achambers.home at googlemail.com):
> Should new code inherit from sax:default-handler?

yes, that's a good choice.

I'm currently preparing cxml documentation for the next release.  Here
is what the docstring is going to say on this matter:


  "Historically, any object has been usable as a SAX handler with CXML,
   as long as it implemented all SAX events, i.e. had methods
   for the generic functions defined in the SAX package.

   While this approach still works, it is now recommended that SAX handlers
   should be implemented by subclassing @class{abstract-handler} or one
   of its subclasses.  Useful subclasses are @class{content-handler}
   and @class{default-handler}.

   As a rule of thumb, write a subclass of @class{default-handler} if
   you want to handle only a few special SAX events and ignore the rest,
   because this class has no-op default methods for all events.

   If, however, you want to make certain that your class implements all
   important SAX events explicitly, a good choice is @class{content-handler},
   which has no-op default methods only for less important, DTD-related
   events, and requires subclasses to implement all events related to the
   content model.

   In some cases, it might be helpful to implement @class{abstract-handler}
   directly, which has no default event methods at all."


Hope that helps,
d.



More information about the cxml-devel mailing list