Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XParsers.hpp
Go to the documentation of this file.
1 /*
2  * XParsers: service classes to support parsing of xml domuments
3  * using standard DOM parsing tools
4  *
5  * Class definition
6  * September 21, 2003
7  * Richard Jones
8  */
9 
10 #ifndef SAW_XPARSERS
11 #define SAW_XPARSERS true
12 
13 #include <xercesc/util/XercesDefs.hpp>
14 #include <xercesc/sax/ErrorHandler.hpp>
15 #include <xercesc/dom/DOM.hpp>
16 #include <xercesc/sax/EntityResolver.hpp>
17 
18 #include <iostream>
19 #include <vector>
20 #include <string>
21 
22 #include "XString.hpp"
23 
24 
25 // Filled by parseInputDocument using MyEntityResolver class
27 
28 
29 /* a simple error handler to install on XercesDOMParser */
30 
31 class MyOwnErrorHandler : public xercesc::ErrorHandler
32 {
33 public:
36 
37  bool getSawErrors() const;
38 
39 /* Implementation of the SAX ErrorHandler interface */
40  void warning(const xercesc::SAXParseException& e);
41  void error(const xercesc::SAXParseException& e);
42  void fatalError(const xercesc::SAXParseException& e);
43  void resetErrors();
44 
45 private :
47  void operator=(const MyOwnErrorHandler&);
48 
49  bool fSawErrors; // flag to record that an error occurred
50 };
51 
53 {
54  return fSawErrors;
55 }
56 
57 /* a simple error handler to install on DOMBuilder parser */
58 
59 class MyDOMErrorHandler : public xercesc::DOMErrorHandler
60 {
61 public:
64 
65  bool getSawErrors() const;
66  bool handleError(const xercesc::DOMError& domError);
67  void resetErrors();
68 
69 private :
71  void operator=(const MyDOMErrorHandler&);
72  bool fSawErrors;
73 };
74 
76 {
77  return fSawErrors;
78 }
79 
80 // A simple entity resolver to keep track of files being
81 // included from the top-level XML file so a full MD5 sum
82 // can be made
83 class MyEntityResolver : public xercesc::EntityResolver
84 {
85 public:
86  MyEntityResolver(const XString& xmlFile);
88 
89  xercesc::InputSource* resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId);
90 
91  std::vector<std::string> GetXMLFilenames(void);
93 
94 private:
95  std::vector<std::string> xml_filenames;
97 };
98 
99 xercesc::DOMDocument* parseInputDocument(const XString& file, bool keep);
100 xercesc::DOMDocument* buildDOMDocument(const XString& file, bool keep);
101 
102 #endif
MyEntityResolver(const XString &xmlFile)
Definition: XParsers.cpp:310
char string[256]
xercesc::DOMDocument * buildDOMDocument(const XString &xmlFile, bool keep)
Definition: XParsers.cpp:142
xercesc::DOMDocument * parseInputDocument(const XString &xmlFile, bool keep)
Definition: XParsers.cpp:73
std::vector< std::string > xml_filenames
Definition: XParsers.hpp:95
std::vector< std::string > GetXMLFilenames(void)
Definition: XParsers.cpp:363
TEllipse * e
void error(const xercesc::SAXParseException &e)
Definition: XParsers.cpp:229
std::string path
Definition: XParsers.hpp:96
bool getSawErrors() const
Definition: XParsers.hpp:75
bool getSawErrors() const
Definition: XParsers.hpp:52
void fatalError(const xercesc::SAXParseException &e)
Definition: XParsers.cpp:241
void operator=(const MyOwnErrorHandler &)
void warning(const xercesc::SAXParseException &e)
Definition: XParsers.cpp:253
bool handleError(const xercesc::DOMError &domError)
Definition: XParsers.cpp:280
std::string GetMD5_checksum(void)
Definition: XParsers.cpp:371
xercesc::InputSource * resolveEntity(const XMLCh *const publicId, const XMLCh *const systemId)
Definition: XParsers.cpp:332
std::string last_md5_checksum
Definition: XParsers.cpp:61
void operator=(const MyDOMErrorHandler &)