00001 // @(#)root/xmlparser:$Id: TSAXParser.h 29654 2009-07-31 14:34:14Z rdm $ 00002 // Author: Jose Lo 12/1/2005 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #ifndef ROOT_TSAXParser 00013 #define ROOT_TSAXParser 00014 00015 ////////////////////////////////////////////////////////////////////////// 00016 // // 00017 // TSAXParser // 00018 // // 00019 // TSAXParser is a subclass of TXMLParser, it is a wraper class to // 00020 // libxml library. // 00021 // // 00022 // SAX (Simple API for XML) is an event based interface, which doesn't // 00023 // maintain the DOM tree in memory, in other words, it's much more // 00024 // efficient for large document. // 00025 // // 00026 // TSAXParserCallback contains a number of callback routines to the // 00027 // parser in a xmlSAXHandler structure. The parser will then parse the // 00028 // document and call the appropriate callback when certain conditions // 00029 // occur. // 00030 // // 00031 ////////////////////////////////////////////////////////////////////////// 00032 00033 00034 #ifndef ROOT_TXMLParser 00035 #include "TXMLParser.h" 00036 #endif 00037 00038 00039 class TList; 00040 class TSAXParserCallback; 00041 struct _xmlSAXHandler; 00042 00043 00044 class TSAXParser : public TXMLParser { 00045 00046 friend class TSAXParserCallback; 00047 00048 private: 00049 _xmlSAXHandler *fSAXHandler; // libxml2 SAX handler 00050 00051 virtual Int_t Parse(); 00052 00053 TSAXParser(const TSAXParser&); // Not implemented 00054 TSAXParser& operator=(const TSAXParser&); // Not implemented 00055 00056 public: 00057 TSAXParser(); 00058 virtual ~TSAXParser(); 00059 00060 virtual Int_t ParseFile(const char *filename); 00061 virtual Int_t ParseBuffer(const char *contents, Int_t len); 00062 00063 virtual void OnStartDocument(); //*SIGNAL* 00064 virtual void OnEndDocument(); //*SIGNAL* 00065 virtual void OnStartElement(const char *name, const TList *attr); //*SIGNAL* 00066 virtual void OnEndElement(const char *name); //*SIGNAL* 00067 virtual void OnCharacters(const char *characters); //*SIGNAL* 00068 virtual void OnComment(const char *text); //*SIGNAL* 00069 virtual void OnWarning(const char *text); //*SIGNAL* 00070 virtual Int_t OnError(const char *text); //*SIGNAL* 00071 virtual Int_t OnFatalError(const char *text); //*SIGNAL* 00072 virtual void OnCdataBlock(const char *text, Int_t len); //*SIGNAL* 00073 00074 virtual void ConnectToHandler(const char *handlerName, void *handler); 00075 00076 ClassDef(TSAXParser,0); // SAX Parser 00077 }; 00078 00079 #endif