DefaultHandler vs ContentHandler

Imran J
2009-07-21
2012-10-08
  • Imran J
    Imran J
    2009-07-21

    Hi Folks,

    • What is the difference between DefaultHandler and ContentHandler in java Saxon...?

    • Please provide me example and usage of the above specified classes

    • Thanks in advance for valuable help

    Regards,
    JavaImran

     
    • Imran J
      Imran J
      2009-07-21

      Thanks for your quick reply.........

       
    • Michael Kay
      Michael Kay
      2009-07-21

      DefaultHandler and ContentHandler belong to the SAX package - they are nothing to do with Saxon, except that Saxon uses them. ContentHandler is an interface that works with a SAX parser to receive notification of parsing events. DefaultHandler is a class that implements the ContentHandler interface - it's provided for convenience so that by writing a class that extends DefaultHandler, you create an implementation of ContentHandler that provides a default "do nothing" implementation of all the parser callback methods.

      Most good general-purpose books on XML (especially XML with Java) will include a chapter on SAX programming. I would recommend the one by Elliotte Rusty Harold, which devotes almost 50 pages to the subject.