CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
XMLDOMBlock Class Reference

#include <CalibCalorimetry/HcalTPGAlgos/interface/XMLDOMBlock.h>

Inheritance diagram for XMLDOMBlock:
LutXml XMLLUTLoader

Public Member Functions

XERCES_CPP_NAMESPACE::DOMElement * add_element (XERCES_CPP_NAMESPACE::DOMElement *parent, XMLCh *tagname, XMLCh *value)
 
XERCES_CPP_NAMESPACE::DOMDocument * getDocument (void)
 
XERCES_CPP_NAMESPACE::DOMDocument * getDocumentConst (void) const
 
XERCES_CPP_NAMESPACE::DOMDocument * getNewDocument (std::string xmlFileName)
 
std::string & getString (void)
 
std::string & getString (XERCES_CPP_NAMESPACE::DOMNode *_node)
 
const char * getTagAttribute (const std::string &tagName, const std::string &attrName, int _item=0)
 
const char * getTagValue (const std::string &tagName, int _item, XERCES_CPP_NAMESPACE::DOMElement *_document)
 
const char * getTagValue (const std::string &tagName, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
 
std::string getTimestamp (time_t _time)
 
XMLDOMBlockoperator+= (const XMLDOMBlock &other)
 
void parse (XERCES_CPP_NAMESPACE::InputSource &_source)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (const std::string &tagName, const int &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const int &tagValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &tagValue, int _item=0)
 
int write (std::string target="stdout")
 
 XMLDOMBlock ()
 
 XMLDOMBlock (std::string _root, int rootElementName)
 
 XMLDOMBlock (std::string xmlFileName)
 
 XMLDOMBlock (XERCES_CPP_NAMESPACE::InputSource &_source)
 
virtual ~XMLDOMBlock ()
 

Protected Member Functions

int init (std::string _root)
 

Protected Attributes

XERCES_CPP_NAMESPACE::DOMDocument * document
 
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
 
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
 
std::string * the_string
 
std::string theFileName
 
XMLProcessortheProcessor
 

Friends

class XMLProcessor
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 39 of file XMLDOMBlock.h.

Constructor & Destructor Documentation

◆ XMLDOMBlock() [1/4]

XMLDOMBlock::XMLDOMBlock ( )

Definition at line 46 of file XMLDOMBlock.cc.

46  {
47  //std::cout << "XMLDOMBlock (or derived): default constructor called - this is meaningless!" << std::endl;
48  //std::cout << "XMLDOMBlock (or derived): use yourClass( loaderBaseConfig & ) instead." << std::endl;
49  init("ROOT");
50 }

References init.

◆ XMLDOMBlock() [2/4]

XMLDOMBlock::XMLDOMBlock ( std::string  xmlFileName)

Definition at line 180 of file XMLDOMBlock.cc.

180  {
181  //
182  //_____ following removed as a xalan-c component_____________________
183  //
184  /*
185  // xalan objects initialization
186  theSourceTreeInit = 0;
187  theDOMSupport = 0;
188  theLiaison = 0;
189  theInputSource = 0;
190  theDocument = 0;
191  thePrefixResolver = 0;
192  theEvaluator = 0;
193  */
194 
196 
197  theFileName = xmlFileName;
198 
199  // initialize the parser
200  parser = new XercesDOMParser();
201  parser->setValidationScheme(XercesDOMParser::Val_Always);
202  parser->setDoNamespaces(true); // optional
203 
204  errHandler = (ErrorHandler*)new HandlerBase();
205  parser->setErrorHandler(errHandler);
206 
207  // parse the input xml file
208  try {
209  parser->parse(theFileName.c_str());
210  } catch (const XMLException& toCatch) {
211  char* message = XMLString::transcode(toCatch.getMessage());
212  std::cout << "Exception message is: \n" << message << "\n";
213  XMLString::release(&message);
214  //return -1;
215  } catch (const DOMException& toCatch) {
216  char* message = XMLString::transcode(toCatch.msg);
217  std::cout << "Exception message is: \n" << message << "\n";
218  XMLString::release(&message);
219  //return -1;
220  } catch (...) {
221  std::cout << "Unexpected Exception \n";
222  //return -1;
223  }
224 
225  //get the XML document
226  document = parser->getDocument();
227 }

References gather_cfg::cout, XMLProcessor::getInstance(), writedatasetfile::parser, and fetchall_from_DQM_v2::release.

◆ XMLDOMBlock() [3/4]

XMLDOMBlock::XMLDOMBlock ( XERCES_CPP_NAMESPACE::InputSource &  _source)

◆ XMLDOMBlock() [4/4]

XMLDOMBlock::XMLDOMBlock ( std::string  _root,
int  rootElementName 
)

Definition at line 52 of file XMLDOMBlock.cc.

52  {
53  //std::cout << "XMLDOMBlock (or derived): default constructor called - this is meaningless!" << std::endl;
54  //std::cout << "XMLDOMBlock (or derived): use yourClass( loaderBaseConfig & ) instead." << std::endl;
55  init(_root);
56 }

References init.

◆ ~XMLDOMBlock()

XMLDOMBlock::~XMLDOMBlock ( )
virtual

Definition at line 278 of file XMLDOMBlock.cc.

278  {
279  delete parser;
280  delete errHandler;
281  //if (the_string) delete the_string;
282 
283  //
284  //_____ following removed as a xalan-c component_____________________
285  //
286  /*
287  // delete xalan objects
288  delete theSourceTreeInit;
289  delete theDOMSupport;
290  delete theLiaison;
291  delete theInputSource;
292  //delete theDocument; // noneed to delete - belongs to theLiaison
293  delete thePrefixResolver;
294  delete theEvaluator;
295  */
296 }

References writedatasetfile::parser.

Member Function Documentation

◆ add_element()

DOMElement * XMLDOMBlock::add_element ( XERCES_CPP_NAMESPACE::DOMElement *  parent,
XMLCh *  tagname,
XMLCh *  value 
)

Definition at line 474 of file XMLDOMBlock.cc.

474  {
475  DOMElement* _elem = document->createElement(tagname);
476  parent->appendChild(_elem);
477  DOMText* _value = document->createTextNode(value);
478  _elem->appendChild(_value);
479  return _elem;
480 }

References class-composition::parent, and createPayload::tagname.

◆ getDocument()

DOMDocument * XMLDOMBlock::getDocument ( void  )

◆ getDocumentConst()

DOMDocument * XMLDOMBlock::getDocumentConst ( void  ) const

Definition at line 270 of file XMLDOMBlock.cc.

270 { return document; }

◆ getNewDocument()

DOMDocument * XMLDOMBlock::getNewDocument ( std::string  xmlFileName)

Definition at line 229 of file XMLDOMBlock.cc.

229  {
230  delete document;
231 
233 
234  theFileName = xmlFileName;
235 
236  // initialize the parser
237  parser = new XercesDOMParser();
238  parser->setValidationScheme(XercesDOMParser::Val_Always);
239  parser->setDoNamespaces(true); // optional
240 
241  errHandler = (ErrorHandler*)new HandlerBase();
242  parser->setErrorHandler(errHandler);
243 
244  // parse the input xml file
245  try {
246  parser->parse(theFileName.c_str());
247  } catch (const XMLException& toCatch) {
248  char* message = XMLString::transcode(toCatch.getMessage());
249  std::cout << "Exception message is: \n" << message << "\n";
250  XMLString::release(&message);
251  //return -1;
252  } catch (const DOMException& toCatch) {
253  char* message = XMLString::transcode(toCatch.msg);
254  std::cout << "Exception message is: \n" << message << "\n";
255  XMLString::release(&message);
256  //return -1;
257  } catch (...) {
258  std::cout << "Unexpected Exception \n";
259  //return -1;
260  }
261 
262  //get the XML document
263  document = parser->getDocument();
264 
265  return document;
266 }

References gather_cfg::cout, XMLProcessor::getInstance(), writedatasetfile::parser, and fetchall_from_DQM_v2::release.

◆ getString() [1/2]

std::string & XMLDOMBlock::getString ( void  )

Definition at line 419 of file XMLDOMBlock.cc.

419 { return getString(this->getDocument()); }

Referenced by LutXml::getCurrentBrick().

◆ getString() [2/2]

std::string& XMLDOMBlock::getString ( XERCES_CPP_NAMESPACE::DOMNode *  _node)

◆ getTagAttribute()

const char * XMLDOMBlock::getTagAttribute ( const std::string &  tagName,
const std::string &  attrName,
int  _item = 0 
)

Definition at line 356 of file XMLDOMBlock.cc.

356  {
357  DOMElement* _tag = (DOMElement*)(document->getElementsByTagName(XMLProcessor::_toXMLCh(tagName))->item(_item));
358  const char* _result = XMLString::transcode(_tag->getAttribute(XMLProcessor::_toXMLCh(attrName)));
359 
360  return _result;
361 }

References XMLProcessor::_toXMLCh(), and JetPartonCorrections_cff::tagName.

◆ getTagValue() [1/2]

const char* XMLDOMBlock::getTagValue ( const std::string &  tagName,
int  _item,
XERCES_CPP_NAMESPACE::DOMElement *  _document 
)

◆ getTagValue() [2/2]

const char* XMLDOMBlock::getTagValue ( const std::string &  tagName,
int  _item = 0,
XERCES_CPP_NAMESPACE::DOMDocument *  _document = nullptr 
)

◆ getTimestamp()

string XMLDOMBlock::getTimestamp ( time_t  _time)

Definition at line 410 of file XMLDOMBlock.cc.

410  {
411  char timebuf[50];
412  //strftime( timebuf, 50, "%c", gmtime( &_time ) );
413  strftime(timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime(&_time));
414  std::string creationstamp = timebuf;
415 
416  return creationstamp;
417 }

References AlCaHLTBitMon_QueryRunRegistry::string.

◆ init()

int XMLDOMBlock::init ( std::string  _root)
protected

Definition at line 142 of file XMLDOMBlock.cc.

142  {
144 
145  //theFileName = xmlFileName;
146 
147  // initialize the parser
148  parser = new XercesDOMParser();
149  parser->setValidationScheme(XercesDOMParser::Val_Always);
150  parser->setDoNamespaces(true); // optional
151 
152  errHandler = (ErrorHandler*)new HandlerBase();
153  parser->setErrorHandler(errHandler);
154 
155  DOMImplementation* impl = DOMImplementation::getImplementation();
156 
157  document = impl->createDocument(nullptr, // root element namespace URI.
158  //XMLString::transcode("ROOT"), // root element name
159  XMLProcessor::_toXMLCh(_root), // root element name
160  nullptr); // document type object (DTD).
161 
162  the_string = nullptr;
163 
164  //
165  //_____ following removed as a xalan-c component_____________________
166  //
167  /*
168  // xalan objects initialization
169  theSourceTreeInit = 0;
170  theDOMSupport = 0;
171  theLiaison = 0;
172  theInputSource = 0;
173  theDocument = 0;
174  thePrefixResolver = 0;
175  theEvaluator = 0;
176  */
177  return 0;
178 }

References XMLProcessor::_toXMLCh(), XMLProcessor::getInstance(), and writedatasetfile::parser.

◆ operator+=()

XMLDOMBlock & XMLDOMBlock::operator+= ( const XMLDOMBlock other)

Definition at line 33 of file XMLDOMBlock.cc.

33  {
34  DOMNodeList* _children = other.getDocumentConst()->getDocumentElement()->getChildNodes();
35  int _length = _children->getLength();
36  //std::cout << "Children nodes:" << _length << std::endl;
37  DOMNode* _node;
38  for (int i = 0; i != _length; i++) {
39  _node = _children->item(i);
40  DOMNode* i_node = this->getDocument()->importNode(_node, true);
41  this->getDocument()->getDocumentElement()->appendChild(i_node);
42  }
43  return *this;
44 }

References mps_fire::i, and trackingPlots::other.

◆ parse()

void XMLDOMBlock::parse ( XERCES_CPP_NAMESPACE::InputSource &  _source)

Definition at line 107 of file XMLDOMBlock.cc.

107  {
109 
110  //theFileName = xmlFileName;
111 
112  // initialize the parser
113  parser = new XercesDOMParser();
114  parser->setValidationScheme(XercesDOMParser::Val_Always);
115  parser->setDoNamespaces(true); // optional
116 
117  errHandler = (ErrorHandler*)new HandlerBase();
118  parser->setErrorHandler(errHandler);
119 
120  // parse the input xml file
121  try {
122  parser->parse(_source);
123  } catch (const XMLException& toCatch) {
124  char* message = XMLString::transcode(toCatch.getMessage());
125  std::cout << "Exception message is: \n" << message << "\n";
126  XMLString::release(&message);
127  //return -1;
128  } catch (const DOMException& toCatch) {
129  char* message = XMLString::transcode(toCatch.msg);
130  std::cout << "Exception message is: \n" << message << "\n";
131  XMLString::release(&message);
132  //return -1;
133  } catch (...) {
134  std::cout << "Unexpected Exception \n";
135  //return -1;
136  }
137 
138  //get the XML document
139  document = parser->getDocument();
140 }

References gather_cfg::cout, XMLProcessor::getInstance(), writedatasetfile::parser, and fetchall_from_DQM_v2::release.

◆ setTagAttribute() [1/4]

DOMNode * XMLDOMBlock::setTagAttribute ( const std::string &  tagName,
const std::string &  attrName,
const int &  attrValue,
int  _item = 0 
)

Definition at line 388 of file XMLDOMBlock.cc.

391  {
392  DOMNode* the_tag = document->getElementsByTagName(XMLProcessor::_toXMLCh(tagName))->item(_item);
393  DOMElement* _tag = (DOMElement*)the_tag;
394  _tag->setAttribute(XMLProcessor::_toXMLCh(attrName), XMLProcessor::_toXMLCh(attrValue));
395  return the_tag;
396 }

References XMLProcessor::_toXMLCh(), and JetPartonCorrections_cff::tagName.

◆ setTagAttribute() [2/4]

DOMNode * XMLDOMBlock::setTagAttribute ( const std::string &  tagName,
const std::string &  attrName,
const std::string &  attrValue,
int  _item = 0 
)

Definition at line 363 of file XMLDOMBlock.cc.

366  {
367  DOMNode* the_tag = document->getElementsByTagName(XMLProcessor::_toXMLCh(tagName))->item(_item);
368  DOMElement* _tag = (DOMElement*)the_tag;
369  _tag->setAttribute(XMLProcessor::_toXMLCh(attrName), XMLProcessor::_toXMLCh(attrValue));
370  return the_tag;
371 }

References XMLProcessor::_toXMLCh(), and JetPartonCorrections_cff::tagName.

Referenced by XMLLUTLoader::XMLLUTLoader().

◆ setTagAttribute() [3/4]

XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagAttribute ( XERCES_CPP_NAMESPACE::DOMElement *  _elem,
const std::string &  tagName,
const std::string &  attrName,
const int &  attrValue,
int  _item = 0 
)

◆ setTagAttribute() [4/4]

XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagAttribute ( XERCES_CPP_NAMESPACE::DOMElement *  _elem,
const std::string &  tagName,
const std::string &  attrName,
const std::string &  attrValue,
int  _item = 0 
)

◆ setTagValue() [1/4]

XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagValue ( const std::string &  tagName,
const int &  tagValue,
int  _item = 0,
XERCES_CPP_NAMESPACE::DOMDocument *  _document = nullptr 
)

◆ setTagValue() [2/4]

XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagValue ( const std::string &  tagName,
const std::string &  tagValue,
int  _item = 0,
XERCES_CPP_NAMESPACE::DOMDocument *  _document = nullptr 
)

◆ setTagValue() [3/4]

XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagValue ( XERCES_CPP_NAMESPACE::DOMElement *  _elem,
const std::string &  tagName,
const int &  tagValue,
int  _item = 0 
)

◆ setTagValue() [4/4]

XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagValue ( XERCES_CPP_NAMESPACE::DOMElement *  _elem,
const std::string &  tagName,
const std::string &  tagValue,
int  _item = 0 
)

◆ write()

int XMLDOMBlock::write ( std::string  target = "stdout")

Definition at line 272 of file XMLDOMBlock.cc.

272  {
273  theProcessor->write(this, target);
274 
275  return 0;
276 }

References filterCSVwithJSON::target.

Referenced by XMLLUTLoader::createLoader(), pkg.AbstractPkg::generate(), mergeLUTs(), and querying.connection::write_and_commit().

Friends And Related Function Documentation

◆ XMLProcessor

friend class XMLProcessor
friend

Definition at line 40 of file XMLDOMBlock.h.

Member Data Documentation

◆ document

XERCES_CPP_NAMESPACE::DOMDocument* XMLDOMBlock::document
protected

◆ errHandler

XERCES_CPP_NAMESPACE::ErrorHandler* XMLDOMBlock::errHandler
protected

Definition at line 116 of file XMLDOMBlock.h.

◆ parser

XERCES_CPP_NAMESPACE::XercesDOMParser* XMLDOMBlock::parser
protected

◆ the_string

std::string* XMLDOMBlock::the_string
protected

Definition at line 119 of file XMLDOMBlock.h.

◆ theFileName

std::string XMLDOMBlock::theFileName
protected

Definition at line 118 of file XMLDOMBlock.h.

◆ theProcessor

XMLProcessor* XMLDOMBlock::theProcessor
protected

Definition at line 114 of file XMLDOMBlock.h.

XMLProcessor::_toXMLCh
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:172
XMLDOMBlock::theProcessor
XMLProcessor * theProcessor
Definition: XMLDOMBlock.h:114
mps_fire.i
i
Definition: mps_fire.py:355
XMLProcessor::getInstance
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:134
gather_cfg.cout
cout
Definition: gather_cfg.py:144
XMLDOMBlock::errHandler
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
Definition: XMLDOMBlock.h:116
XMLDOMBlock::document
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:117
XMLDOMBlock::theFileName
std::string theFileName
Definition: XMLDOMBlock.h:118
XMLDOMBlock::getString
std::string & getString(void)
Definition: XMLDOMBlock.cc:419
XMLDOMBlock::getDocument
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:268
trackingPlots.other
other
Definition: trackingPlots.py:1465
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
value
Definition: value.py:1
XMLDOMBlock::init
int init(std::string _root)
Definition: XMLDOMBlock.cc:142
createPayload.tagname
tagname
Definition: createPayload.py:183
impl
Definition: trackAlgoPriorityOrder.h:18
XMLProcessor::write
int write(XMLDOMBlock *doc, std::string target="stdout")
Definition: XMLProcessor.cc:207
XMLDOMBlock::parser
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
Definition: XMLDOMBlock.h:115
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
class-composition.parent
parent
Definition: class-composition.py:88
JetPartonCorrections_cff.tagName
tagName
Definition: JetPartonCorrections_cff.py:12
XMLDOMBlock::the_string
std::string * the_string
Definition: XMLDOMBlock.h:119