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