BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
XmlParser.h
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/xmlBase/xmlBase/XmlParser.h,v 1.1.1.1 2005/10/17 06:10:27 maqm Exp $
2// Author: J. Bogart
3
4#ifndef xmlBase_XmlParser_h
5#define xmlBase_XmlParser_h
6
8 // following indirectly includes DOMDocument, DOMElement...
9#include <xercesc/parsers/XercesDOMParser.hpp>
10#include <string>
11#include <iosfwd>
12
13
14namespace xmlBase {
15 /// This class provides an interface to the Xerces DOM parser
16 /// with validation turned on if the file to be parsed has a dtd.
17 class EResolver;
18 using XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument;
19 using XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser;
20
21
22 class XmlParser {
23 public:
24 XmlParser(bool throwErrors = false);
25
26 /// Call this method to turn on schema processing (else it's off)
27 void doSchema(bool doit);
28 ~XmlParser();
29
30 /// Parse an xml file, returning document node if successful
31 DOMDocument* parse(const char* const filename,
32 const std::string& docType=std::string(""));
33
34
35 /// Parse an xml file as a string, returning document node if successful
36 DOMDocument* parse(const std::string& buffer,
37 const std::string& docType=std::string("") );
38
39 /// Reset the parser so it may be used to parse another document (note
40 /// this destroys old DOM)
41 void reset() {m_parser->reset();}
42 private:
43 /// Xerces-supplied parser which does the real work
44 XercesDOMParser* m_parser;
45 XmlErrorHandler* m_errorHandler;
46 /// Entity resolver
47 EResolver* m_resolver;
48 bool m_throwErrors;
49 bool m_errorsOccurred;
50 bool m_doSchema;
51 static int didInit;
52 };
53}
54#endif
DOMDocument * parse(const char *const filename, const std::string &docType=std::string(""))
Parse an xml file, returning document node if successful.
Definition: XmlParser.cxx:108
void doSchema(bool doit)
Call this method to turn on schema processing (else it's off)
Definition: XmlParser.cxx:92