![]() |
![]() |
00001 #ifndef DDLSAX2HANDLER_H 00002 #define DDLSAX2HANDLER_H 00003 00004 // --------------------------------------------------------------------------- 00005 // Includes 00006 // --------------------------------------------------------------------------- 00007 00008 // Xerces C++ Dependencies 00009 #include <xercesc/sax2/Attributes.hpp> 00010 #include <xercesc/sax2/DefaultHandler.hpp> 00011 00012 #include <string> 00013 #include <vector> 00014 #include <iostream> 00015 00016 00018 00035 class DDLSAX2Handler : public xercesc_2_7::DefaultHandler 00036 { 00037 00038 public: 00039 typedef xercesc_2_7::Attributes Attributes; 00040 typedef xercesc_2_7::SAXParseException SAXParseException; 00041 00042 // ----------------------------------------------------------------------- 00043 // Constructor and Destructor 00044 // ----------------------------------------------------------------------- 00045 00046 DDLSAX2Handler(); 00047 ~DDLSAX2Handler(); 00048 00049 // ----------------------------------------------------------------------- 00050 // Getter methods 00051 // ----------------------------------------------------------------------- 00053 unsigned int getElementCount() const 00054 { 00055 return elementCount_; 00056 } 00058 unsigned int getAttrCount() const 00059 { 00060 return attrCount_; 00061 } 00063 unsigned int getCharacterCount() const 00064 { 00065 return characterCount_; 00066 } 00068 bool getSawErrors() const 00069 { 00070 return sawErrors_; 00071 } 00073 unsigned int getSpaceCount() const 00074 { 00075 return spaceCount_; 00076 } 00077 00078 // ----------------------------------------------------------------------- 00079 // Handlers for the SAX ContentHandler interface 00080 // ----------------------------------------------------------------------- 00081 00082 virtual void startElement(const XMLCh* const uri, const XMLCh* const localname 00083 , const XMLCh* const qname, const Attributes& attrs); 00084 virtual void endElement(const XMLCh* const uri, const XMLCh* const localname 00085 , const XMLCh* const qname); 00086 virtual void characters(const XMLCh* const chars, const unsigned int length); 00087 virtual void comment (const XMLCh *const chars, const unsigned int length ); 00088 virtual void ignorableWhitespace(const XMLCh* const chars, const unsigned int length); 00089 virtual void resetDocument(); 00090 00091 // ----------------------------------------------------------------------- 00092 // Handlers for the SAX ErrorHandler interface 00093 // ----------------------------------------------------------------------- 00094 virtual void warning(const SAXParseException& exception); 00095 virtual void error(const SAXParseException& exception); 00096 virtual void fatalError(const SAXParseException& exception); 00097 virtual void dumpStats(const std::string& fname); 00098 00099 protected: 00100 00101 // ----------------------------------------------------------------------- 00102 // Protected data members 00103 // 00104 // attrCount_ 00105 // characterCount_ 00106 // elementCount_ 00107 // spaceCount_ 00108 // These are just counters that are run upwards based on the input 00109 // from the document handlers. 00110 // 00111 // sawErrors 00112 // This is set by the error handlers, and is queryable later to 00113 // see if any errors occurred. 00114 // ----------------------------------------------------------------------- 00115 unsigned int attrCount_; 00116 unsigned int characterCount_; 00117 unsigned int elementCount_; 00118 unsigned int spaceCount_; 00119 bool sawErrors_; 00120 00121 std::string getnmspace(const std::string& fname); 00122 }; 00123 00124 #endif