43#include <libxml/parser.h>
44#include <libxml/parserInternals.h>
51 static void StartElement(
void *fParser,
const xmlChar *
name,
const xmlChar **p);
54 static void Comment(
void *fParser,
const xmlChar *value);
56 static void Warning(
void *fParser,
const char *fmt, ...);
57 static void Error(
void *fParser,
const char *fmt, ...);
58 static void FatalError(
void *fParser,
const char *fmt, ...);
109 Emit(
"OnStartDocument()");
117 Emit(
"OnEndDocument()");
130 args[1] = (
Long_t)attributes;
132 Emit(
"OnStartElement(const char *, const TList *)", args);
140 Emit(
"OnEndElement(const char *)",
name);
149 Emit(
"OnCharacters(const char *)", characters);
157 Emit(
"OnComment(const char *)",
text);
165 Emit(
"OnWarning(const char *)",
text);
177 Emit(
"OnError(const char *)", errmsg.
Data());
190 Emit(
"OnFatalError(const char *)", errmsg.
Data());
203 Emit(
"OnCdataBlock(const char *, Int_t)", args);
218 xmlSAXHandlerPtr oldSAX =
fContext->sax;
249 fContext = xmlCreateFileParserCtxt(filename);
266 fContext = xmlCreateMemoryParserCtxt(contents, len);
302 for (
const xmlChar **cur = p; cur && *cur; cur += 2) {
304 (
const char*)*(cur + 1)));
333 char *str =
new char[len+1];
334 strlcpy(str, (
const char*) ch, len+1);
363 va_start(arg,
va_(fmt));
364 vsnprintf(buffer, 2048,
va_(fmt), arg);
384 va_start(arg,
va_(fmt));
385 vsnprintf(buffer, 2048,
va_(fmt), arg);
395 if (errorcode < 0 && parser->GetStopOnError()) {
413 va_start(arg,
va_(fmt));
414 vsnprintf(buffer, 2048,
va_(fmt), arg);
449 const TString kFunctionsName [] = {
452 "OnStartElement(const char *, const TList *)",
453 "OnEndElement(const char *)",
454 "OnCharacters(const char *)",
455 "OnComment(const char *)",
456 "OnWarning(const char *)",
457 "OnError(const char *)",
458 "OnFatalError(const char *)",
459 "OnCdataBlock(const char *, Int_t)"
464 for (
Int_t i = 0; i < 10; i++) {
466 cl, kFunctionsName[i]) != -1)
467 Connect(kFunctionsName[i], handlerName, handler, kFunctionsName[i]);
TClass instances represent classes, structs and namespaces in the ROOT type system.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual void Add(TObject *obj)
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
static Int_t CheckConnectArgs(TQObject *sender, TClass *sender_class, const char *signal, TClass *receiver_class, const char *slot)
Checking of consistency of sender/receiver methods/arguments.
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
static void Comment(void *fParser, const xmlChar *value)
Comment callback function.
static void StartDocument(void *fParser)
StartDocument Callback function.
static void CdataBlock(void *fParser, const xmlChar *value, Int_t len)
CdataBlock Callback function.
static void Characters(void *fParser, const xmlChar *ch, Int_t len)
Character callback function.
static void Warning(void *fParser, const char *fmt,...)
Warning callback function.
static void StartElement(void *fParser, const xmlChar *name, const xmlChar **p)
StartElement callback function, where name is the name of the element and p contains the attributes f...
static void Error(void *fParser, const char *fmt,...)
Error callback function.
static void EndDocument(void *fParser)
EndDocument callback function.
static void EndElement(void *fParser, const xmlChar *name)
EndElement callback function, where name is the name of the element.
static void FatalError(void *fParser, const char *fmt,...)
FactalError callback function.
TSAXParser is a subclass of TXMLParser, it is a wraper class to libxml library.
virtual void OnWarning(const char *text)
Emit a signal for OnWarning, where text is the warning.
virtual void OnCdataBlock(const char *text, Int_t len)
Emit a signal for OnCdataBlock.
virtual Int_t ParseBuffer(const char *contents, Int_t len)
It parse the contents, instead of a file.
virtual Int_t Parse()
This function parses the xml file, by initializing the parser and checks whether the parse context is...
virtual ~TSAXParser()
TSAXParser desctructor.
virtual Int_t OnFatalError(const char *text)
Emit a signal for OnFactalError, where text is the error and it returns the Parse Error Code,...
virtual Int_t ParseFile(const char *filename)
It creates the parse context of the xml file, where the xml file name is filename.
virtual void OnCharacters(const char *characters)
Emit a signal for OnCharacters, where characters are the characters outside of tags.
TSAXParser()
Create SAX parser.
virtual void OnComment(const char *text)
Emit a signal for OnComment, where text is the comment.
virtual void OnStartElement(const char *name, const TList *attr)
Emit a signal for OnStarElement, where name is the Element's name and attribute is a TList of (TObjSt...
virtual void OnEndDocument()
Emit a signal for OnEndDocument.
virtual void ConnectToHandler(const char *handlerName, void *handler)
A default TSAXParser to a user-defined Handler connection function.
virtual void OnStartDocument()
Emit a signal for OnStartDocument.
virtual void OnEndElement(const char *name)
Emit a signal for OnEndElement, where name is the Element's name.
virtual Int_t OnError(const char *text)
Emit a signal for OnError, where text is the error and it returns the Parse Error Code,...
_xmlSAXHandler * fSAXHandler
libxml2 SAX handler
const char * Data() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
TXMLAttribute is the attribute of an Element.
virtual void InitializeContext()
Initialize parser parameters, such as, disactivate non-standards libxml1 features,...
virtual void SetParseCode(Int_t code)
Set the parse code:
_xmlParserCtxt * fContext
Parse the xml file.
Int_t fParseCode
To keep track of the errorcodes.
virtual void ReleaseUnderlying()
To release any existing document.
virtual void StopParser()
Stops parsing.