SAXPrint_Handler.h

Go to the documentation of this file.
00001 // $Id: SAXPrint_Handler.h 78907 2007-07-16 10:22:58Z sowayaa $
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SAXPrint_Handler.h
00006  *
00007  *  $Id: SAXPrint_Handler.h 78907 2007-07-16 10:22:58Z sowayaa $
00008  *
00009  *  @author Nanbor Wang <nanbor@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACEXML_SAXPRINT_HANDLER_H
00014 #define ACEXML_SAXPRINT_HANDLER_H
00015 
00016 #include "ACEXML/common/DefaultHandler.h"
00017 
00018 /**
00019  * @class ACEXML_SAXPrint_Handler
00020  *
00021  * @brief ACEXML_SAXPrint_Handler is an example SAX event handler.
00022  *
00023  * This SAX event handler try to regenerate the XML document it
00024  * reads with correct indentation.
00025  */
00026 class ACEXML_SAXPrint_Handler : public ACEXML_DefaultHandler
00027 {
00028 public:
00029   /*
00030    * Default constructor.
00031    */
00032   ACEXML_SAXPrint_Handler (const ACEXML_Char* name);
00033 
00034   /*
00035    * Default destructor.
00036    */
00037   virtual ~ACEXML_SAXPrint_Handler (void);
00038 
00039   // Methods inherit from ACEXML_ContentHandler.
00040 
00041   /*
00042    * Receive notification of character data.
00043    */
00044   virtual void characters (const ACEXML_Char *ch,
00045                            size_t start,
00046                            size_t length
00047                            ACEXML_ENV_ARG_DECL)
00048     ;
00049 
00050   /*
00051    * Receive notification of the end of a document.
00052    */
00053   virtual void endDocument (ACEXML_ENV_SINGLE_ARG_DECL)
00054     ;
00055 
00056   /*
00057    * Receive notification of the end of an element.
00058    */
00059   virtual void endElement (const ACEXML_Char *namespaceURI,
00060                            const ACEXML_Char *localName,
00061                            const ACEXML_Char *qName ACEXML_ENV_ARG_DECL)
00062     ;
00063 
00064   /*
00065    * End the scope of a prefix-URI mapping.
00066    */
00067   virtual void endPrefixMapping (const ACEXML_Char *prefix ACEXML_ENV_ARG_DECL)
00068     ;
00069 
00070   /*
00071    * Receive notification of ignorable whitespace in element content.
00072    */
00073   virtual void ignorableWhitespace (const ACEXML_Char *ch,
00074                                     int start,
00075                                     int length ACEXML_ENV_ARG_DECL)
00076     ;
00077 
00078   /*
00079    * Receive notification of a processing instruction.
00080    */
00081   virtual void processingInstruction (const ACEXML_Char *target,
00082                                       const ACEXML_Char *data ACEXML_ENV_ARG_DECL)
00083     ;
00084 
00085   /*
00086    * Receive an object for locating the origin of SAX document events.
00087    */
00088   virtual void setDocumentLocator (ACEXML_Locator *locator) ;
00089 
00090   /*
00091    * Receive notification of a skipped entity.
00092    */
00093   virtual void skippedEntity (const ACEXML_Char *name ACEXML_ENV_ARG_DECL)
00094     ;
00095 
00096   /*
00097    * Receive notification of the beginning of a document.
00098    */
00099   virtual void startDocument (ACEXML_ENV_SINGLE_ARG_DECL)
00100     ;
00101 
00102   /*
00103    * Receive notification of the beginning of an element.
00104    */
00105   virtual void startElement (const ACEXML_Char *namespaceURI,
00106                              const ACEXML_Char *localName,
00107                              const ACEXML_Char *qName,
00108                              ACEXML_Attributes *atts ACEXML_ENV_ARG_DECL)
00109     ;
00110 
00111   /*
00112    * Begin the scope of a prefix-URI Namespace mapping.
00113    */
00114   virtual void startPrefixMapping (const ACEXML_Char *prefix,
00115                                    const ACEXML_Char *uri ACEXML_ENV_ARG_DECL)
00116     ;
00117 
00118   // *** Methods inherit from ACEXML_DTDHandler.
00119 
00120   /*
00121    * Receive notification of a notation declaration event.
00122    */
00123   virtual void notationDecl (const ACEXML_Char *name,
00124                              const ACEXML_Char *publicId,
00125                              const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
00126     ;
00127 
00128   /*
00129    * Receive notification of an unparsed entity declaration event.
00130    */
00131   virtual void unparsedEntityDecl (const ACEXML_Char *name,
00132                                    const ACEXML_Char *publicId,
00133                                    const ACEXML_Char *systemId,
00134                                    const ACEXML_Char *notationName ACEXML_ENV_ARG_DECL)
00135     ;
00136 
00137   // Methods inherit from ACEXML_EnitityResolver.
00138 
00139   /*
00140    * Allow the application to resolve external entities.
00141    */
00142   virtual ACEXML_InputSource *resolveEntity (const ACEXML_Char *publicId,
00143                                              const ACEXML_Char *systemId ACEXML_ENV_ARG_DECL)
00144     ;
00145 
00146   // Methods inherit from ACEXML_ErrorHandler.
00147 
00148   /*
00149    * Receive notification of a recoverable error.
00150    */
00151   virtual void error (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
00152     ;
00153 
00154   /*
00155    * Receive notification of a non-recoverable error.
00156    */
00157   virtual void fatalError (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
00158     ;
00159 
00160   /*
00161    * Receive notification of a warning.
00162    */
00163   virtual void warning (ACEXML_SAXParseException &exception ACEXML_ENV_ARG_DECL)
00164     ;
00165 
00166   void inc_indent ();
00167   void dec_indent ();
00168   void print_indent ();
00169 
00170 private:
00171 
00172   size_t indent_;
00173   ACEXML_Char* fileName_;
00174   ACEXML_Locator* locator_;
00175 };
00176 
00177 #if defined (__ACEXML_INLINE__)
00178 # include "SAXPrint_Handler.inl"
00179 #endif /* __ACEXML_INLINE__ */
00180 #endif /* ACEXML_SAXPRINT_HANDLER_H */

Generated on Sun Jan 27 13:04:15 2008 for ACEXML by doxygen 1.3.6