Hi,
What is the current recommended method of implementing a custom SAX handler?
The documentation says that you just need to implement the generic functions for any old class but when you do that, you get lots of warnings like the following.
"deprecated SAX default method used by a handler that is not a subclass of SAX:ABSTRACT-HANDLER or HAX:ABSTRACT-HANDLER"
Should new code inherit from sax:default-handler?
Cheers, Andy
Hi,
Quoting Andy Chambers (achambers.home@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.