Logo ROOT   6.14/05
Reference Guide
Go to the documentation of this file.
1 // @(#)root/xmlparser:$Id$
2 // Author: Jose Lo 12/4/2005
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  *************************************************************************/
12 #ifndef ROOT_TXMLParser
13 #define ROOT_TXMLParser
15 #include "TQObject.h"
17 #include "TObject.h"
19 #include "TString.h"
21 struct _xmlParserCtxt;
24 class TXMLParser : public TObject, public TQObject {
26 private:
27  TXMLParser(const TXMLParser&); // Not implemented
28  TXMLParser& operator=(const TXMLParser&); // Not implemented
30 protected:
31  _xmlParserCtxt *fContext; ///< Parse the xml file
32  Bool_t fValidate; ///< To validate the parse context
33  Bool_t fReplaceEntities; ///< Replace entities
34  Bool_t fStopError; ///< Stop when parse error occurs
35  TString fValidateError; ///< Parse error
36  TString fValidateWarning; ///< Parse warning
37  Int_t fParseCode; ///< To keep track of the errorcodes
39  virtual void InitializeContext();
40  virtual void ReleaseUnderlying();
41  virtual void OnValidateError(const TString& message);
42  virtual void OnValidateWarning(const TString& message);
43  virtual void SetParseCode(Int_t code);
45 public:
46  TXMLParser();
47  virtual ~TXMLParser();
49  void SetValidate(Bool_t val = kTRUE);
50  Bool_t GetValidate() const { return fValidate; }
52  void SetReplaceEntities(Bool_t val = kTRUE);
55  virtual Int_t ParseFile(const char *filename) = 0;
56  virtual Int_t ParseBuffer(const char *contents, Int_t len) = 0;
57  virtual void StopParser();
59  Int_t GetParseCode() const { return fParseCode; }
61  const char *GetParseCodeMessage(Int_t parseCode) const;
63  void SetStopOnError(Bool_t stop = kTRUE);
64  Bool_t GetStopOnError() const { return fStopError; }
66  const char *GetValidateError() const { return fValidateError; }
67  const char *GetValidateWarning() const { return fValidateWarning; }
69  ClassDef(TXMLParser,0); // XML SAX parser
70 };
72 #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:49
virtual void ReleaseUnderlying()
To release any existing document.
Definition: TXMLParser.cxx:93
Int_t fParseCode
To keep track of the errorcodes.
Definition: TXMLParser.h:37
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t GetValidate() const
Definition: TXMLParser.h:50
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:31
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
const char * GetParseCodeMessage(Int_t parseCode) const
Returns the parse code message.
Definition: TXMLParser.cxx:123
void SetStopOnError(Bool_t stop=kTRUE)
Set parser stops in case of error:
Definition: TXMLParser.cxx:192
Initializes parser variables.
Definition: TXMLParser.cxx:60
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void StopParser()
Stops parsing.
Definition: TXMLParser.cxx:167
virtual Int_t ParseFile(const char *filename)=0
Int_t GetParseCode() const
Definition: TXMLParser.h:59
const char * GetValidateError() const
Definition: TXMLParser.h:66
Bool_t GetStopOnError() const
Definition: TXMLParser.h:64
TXMLParser is an abstract class which interfaces with Libxml2.
Definition: TXMLParser.h:24
TXMLParser & operator=(const TXMLParser &)
virtual ~TXMLParser()
Definition: TXMLParser.cxx:68
Bool_t fValidate
To validate the parse context.
Definition: TXMLParser.h:32
Mother of all ROOT objects.
Definition: TObject.h:37
TString fValidateWarning
Parse warning.
Definition: TXMLParser.h:36
Bool_t fReplaceEntities
Replace entities.
Definition: TXMLParser.h:33
Bool_t fStopError
Stop when parse error occurs.
Definition: TXMLParser.h:34
TString fValidateError
Parse error.
Definition: TXMLParser.h:35
Bool_t GetReplaceEntities() const
Definition: TXMLParser.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
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:67