00001 //----------------------------------------------------- 00002 //msdSax2Parser.h 00003 // 00004 // Project: PDBe API Framework 00005 // Module: Definition of classes and validation method for validating 00006 // a given xml file / URL according to a given XML schema. 00007 // 00008 // Data Layer 00009 // Last updated: 25 February 2004 10:17 00010 // (C) Siamak Sobhany 00011 //------------------------------------------------------ 00012 00013 #ifndef __MSD_SAX_2_PARSER__ 00014 #define __MSD_SAX_2_PARSER__ 00015 00016 #include <sstream> 00017 00018 00019 #include <xercesc/sax2/DefaultHandler.hpp> 00020 00021 // Classes/data/variables must be namespace qualified since 00022 // C++ Namespace support is ENABLED in Xerces. 00023 //using namespace std; 00024 #define XERCES_HAS_CPP_NAMESPACE 00025 00026 using namespace xercesc; 00027 00028 class msdSax2Handler : public DefaultHandler { 00029 public: 00030 // ----------------------------------------------------------------------- 00031 // Constructors and Destructor 00032 // ----------------------------------------------------------------------- 00033 msdSax2Handler(){}; 00034 ~msdSax2Handler(){}; 00035 00036 // ----------------------------------------------------------------------- 00037 // Getter methods 00038 // ----------------------------------------------------------------------- 00039 bool getSawErrors() const 00040 { 00041 return fSawErrors; 00042 } 00043 00044 // ----------------------------------------------------------------------- 00045 // Handlers for the SAX ErrorHandler interface 00046 // ----------------------------------------------------------------------- 00047 void warning(const SAXParseException& exception); 00048 void error(const SAXParseException& exception); 00049 void fatalError(const SAXParseException& exception); 00050 const char* msdSax2Handler::getErrors(); 00051 00052 private: 00053 // ----------------------------------------------------------------------- 00054 // Private data members 00055 // 00056 // fSawErrors 00057 // This is set by the error handlers, and is queryable later to 00058 // see if any errors occured. 00059 // ----------------------------------------------------------------------- 00060 bool fSawErrors; 00061 std::ostringstream errors; 00062 }; 00063 00064 class msdSax2Parser { 00065 public: 00066 msdSax2Parser(){}; 00067 ~msdSax2Parser(){}; 00068 const char* validate(char* xmlFile); 00069 00070 }; 00071 00072 #endif 00073
1.3.4-20031005