Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TDOMParser.cxx
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/**
13\class TDomParser
14\ingroup IO
15
16DOM stands for the Document Object Model; this is an API for
17accessing XML or HTML structured documents.
18The Document Object Model is a platform and language-neutral
19interface that will allow programs and scripts to dynamically
20access and update the content, structure and style of documents.
21
22The parser returns a tree built during the document analysis.
23*/
24
25#include "TDOMParser.h"
26#include "TXMLDocument.h"
27
28#include <libxml/tree.h>
29#include <libxml/parserInternals.h>
30
31
32
33////////////////////////////////////////////////////////////////////////////////
34/// TDOMParser constructor.
35
37{
38}
39
40////////////////////////////////////////////////////////////////////////////////
41/// TDOMParser destructor, it calls ReleaseUnderlying().
42
47
48////////////////////////////////////////////////////////////////////////////////
49/// Release any existing document.
50
52{
53 if (fTXMLDoc) {
54 delete fTXMLDoc;
55 fTXMLDoc = 0;
56 }
57
58 SetParseCode(0);
59
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Parse the XML file where filename is the XML file name.
65/// It will create a TXMLDocument if the file is parsed without
66/// any error. It returns parse code error in case of parse error,
67/// see TXMLParser.
68
70{
72
74
75 if (!fContext) {
76 SetParseCode(-2);
77 return -2;
78 }
79
81
82 if (!fContext->directory) {
83 const char *dir = xmlParserGetDirectory(filename);
84 fContext->directory = (char *)xmlStrdup((const xmlChar *)dir);
85 }
86
87 return ParseContext();
88}
89
90////////////////////////////////////////////////////////////////////////////////
91/// It parses a buffer, much like ParseFile().
92
94{
96
98
99 if (!fContext) {
100 SetParseCode(-2);
101 return -2;
102 }
103
105
106 return ParseContext();
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// Creates a XML document for the parser.
111/// It returns 0 on success, and
112/// - \b -1 if no XML document was created,
113/// - \b -5 if the document is not well formated,
114/// - \b -6 if document is not valid.
115
117{
119
120 if (!fContext->myDoc) {
121 SetParseCode(-1);
122 return -1;
123 }
124
125 if (!fContext->wellFormed) {
126 SetParseCode(-5);
127 return -5;
128 }
129
130 if (!fContext->valid) {
131 SetParseCode(-6);
132 return -6;
133 }
134
135 fTXMLDoc = new TXMLDocument(fContext->myDoc);
136
137 return 0;
138}
139
140////////////////////////////////////////////////////////////////////////////////
141/// Returns the TXMLDocument.
142
144{
145 return fTXMLDoc;
146}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
virtual TXMLDocument * GetXMLDocument() const
Returns the TXMLDocument.
void ReleaseUnderlying() override
Release any existing document.
Int_t ParseContext()
Creates a XML document for the parser.
TDOMParser()
TDOMParser constructor.
Int_t ParseBuffer(const char *buffer, Int_t len) override
It parses a buffer, much like ParseFile().
TXMLDocument * fTXMLDoc
xmlDoc
Definition TDOMParser.h:23
Int_t ParseFile(const char *filename) override
Parse the XML file where filename is the XML file name.
~TDOMParser() override
TDOMParser destructor, it calls ReleaseUnderlying().
TXMLDocument contains a pointer to an xmlDoc structure, after the parser returns a tree built during ...
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.
Definition TXMLParser.h:31
virtual void ReleaseUnderlying()
To release any existing document.