ROOT  6.06/09
Reference Guide
TXMLParser.h
Go to the documentation of this file.
1 // @(#)root/xmlparser:$Id$
2 // Author: Jose Lo 12/4/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TXMLParser
13 #define ROOT_TXMLParser
14 
15 #ifndef ROOT_TQObject
16 #include "TQObject.h"
17 #endif
18 
19 #ifndef ROOT_TObject
20 #include "TObject.h"
21 #endif
22 
23 #ifndef ROOT_TString
24 #include "TString.h"
25 #endif
26 
27 struct _xmlParserCtxt;
28 
29 
30 class TXMLParser : public TObject, public TQObject {
31 
32 private:
33  TXMLParser(const TXMLParser&); // Not implemented
34  TXMLParser& operator=(const TXMLParser&); // Not implemented
35 
36 protected:
37  _xmlParserCtxt *fContext; ///< Parse the xml file
38  Bool_t fValidate; ///< To validate the parse context
39  Bool_t fReplaceEntities; ///< Replace entities
40  Bool_t fStopError; ///< Stop when parse error occurs
41  TString fValidateError; ///< Parse error
42  TString fValidateWarning; ///< Parse warning
43  Int_t fParseCode; ///< To keep track of the errorcodes
44 
45  virtual void InitializeContext();
46  virtual void ReleaseUnderlying();
47  virtual void OnValidateError(const TString& message);
48  virtual void OnValidateWarning(const TString& message);
49  virtual void SetParseCode(Int_t code);
50 
51 public:
52  TXMLParser();
53  virtual ~TXMLParser();
54 
55  void SetValidate(Bool_t val = kTRUE);
56  Bool_t GetValidate() const { return fValidate; }
57 
58  void SetReplaceEntities(Bool_t val = kTRUE);
60 
61  virtual Int_t ParseFile(const char *filename) = 0;
62  virtual Int_t ParseBuffer(const char *contents, Int_t len) = 0;
63  virtual void StopParser();
64 
65  Int_t GetParseCode() const { return fParseCode; }
66 
67  const char *GetParseCodeMessage(Int_t parseCode) const;
68 
69  void SetStopOnError(Bool_t stop = kTRUE);
70  Bool_t GetStopOnError() const { return fStopError; }
71 
72  const char *GetValidateError() const { return fValidateError; }
73  const char *GetValidateWarning() const { return fValidateWarning; }
74 
75  ClassDef(TXMLParser,0); // XML SAX parser
76 };
77 
78 #endif
virtual void InitializeContext()
Initialize parser parameters, such as, disactivate non-standards libxml1 features, on/off validation, clear error and warning messages.
Definition: TXMLParser.cxx:153
void SetReplaceEntities(Bool_t val=kTRUE)
The parser will replace/expand entities.
Definition: TXMLParser.cxx:85
This is the ROOT implementation of the Qt object communication mechanism (see also http://www...
Definition: TQObject.h:53
static const char * filename()
virtual void ReleaseUnderlying()
To release any existing document.
Definition: TXMLParser.cxx:93
Int_t fParseCode
To keep track of the errorcodes.
Definition: TXMLParser.h:43
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetValidate(Bool_t val=kTRUE)
The parser will validate the xml file if val = true.
Definition: TXMLParser.cxx:77
virtual Int_t ParseBuffer(const char *contents, Int_t len)=0
_xmlParserCtxt * fContext
Parse the xml file.
Definition: TXMLParser.h:37
Bool_t GetValidate() const
Definition: TXMLParser.h:56
virtual void SetParseCode(Int_t code)
Set the parse code:
Definition: TXMLParser.cxx:182
virtual void OnValidateError(const TString &message)
This function is called when an error from the parser has occured.
Definition: TXMLParser.cxx:106
Bool_t GetReplaceEntities() const
Definition: TXMLParser.h:59
void SetStopOnError(Bool_t stop=kTRUE)
Set parser stops in case of error:
Definition: TXMLParser.cxx:192
TXMLParser()
Initializes parser variables.
Definition: TXMLParser.cxx:60
Int_t GetParseCode() const
Definition: TXMLParser.h:65
virtual void StopParser()
Stops parsing.
Definition: TXMLParser.cxx:167
virtual Int_t ParseFile(const char *filename)=0
ClassDef(TXMLParser, 0)
const char * GetParseCodeMessage(Int_t parseCode) const
Returns the parse code message.
Definition: TXMLParser.cxx:123
TXMLParser is an abstract class which interfaces with Libxml2.
Definition: TXMLParser.h:30
TXMLParser & operator=(const TXMLParser &)
Bool_t GetStopOnError() const
Definition: TXMLParser.h:70
virtual ~TXMLParser()
Cleanup.
Definition: TXMLParser.cxx:68
Bool_t fValidate
To validate the parse context.
Definition: TXMLParser.h:38
Mother of all ROOT objects.
Definition: TObject.h:58
TString fValidateWarning
Parse warning.
Definition: TXMLParser.h:42
Bool_t fReplaceEntities
Replace entities.
Definition: TXMLParser.h:39
Bool_t fStopError
Stop when parse error occurs.
Definition: TXMLParser.h:40
TString fValidateError
Parse error.
Definition: TXMLParser.h:41
string message
Definition: ROOT.py:94
const Bool_t kTRUE
Definition: Rtypes.h:91
const char * GetValidateError() const
Definition: TXMLParser.h:72
virtual void OnValidateWarning(const TString &message)
This function is called when a warning from the parser has occured.
Definition: TXMLParser.cxx:115
const char * GetValidateWarning() const
Definition: TXMLParser.h:73