test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
HcalChannelDataXml HcalHardwareXml HcalTriggerKey LMapLoader LutXml XMLHTRPatternLoader XMLHTRZeroSuppressionLoader XMLLUTLoader XMLRBXPedestalsLoader

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=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
 
const char * getTagValue (const std::string &tagName, int _item, XERCES_CPP_NAMESPACE::DOMElement *_document)
 
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 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 std::string &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (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 int &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &tagValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (const std::string &tagName, const int &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const int &tagValue, int _item=0)
 
int write (std::string target="stdout")
 
 XMLDOMBlock ()
 
 XMLDOMBlock (std::string xmlFileName)
 
 XMLDOMBlock (XERCES_CPP_NAMESPACE::InputSource &_source)
 
 XMLDOMBlock (std::string _root, int rootElementName)
 
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 42 of file XMLDOMBlock.h.

Constructor & Destructor Documentation

XMLDOMBlock::XMLDOMBlock ( )

Definition at line 50 of file XMLDOMBlock.cc.

References init.

51 {
52  //std::cout << "XMLDOMBlock (or derived): default constructor called - this is meaningless!" << std::endl;
53  //std::cout << "XMLDOMBlock (or derived): use yourClass( loaderBaseConfig & ) instead." << std::endl;
54  init( "ROOT" );
55 }
int init(std::string _root)
Definition: XMLDOMBlock.cc:167
XMLDOMBlock::XMLDOMBlock ( std::string  xmlFileName)

Definition at line 209 of file XMLDOMBlock.cc.

References gather_cfg::cout, XMLProcessor::getInstance(), geometryXMLtoCSV::parser, fetchall_from_DQM_v2::release, XERCES_CPP_NAMESPACE_USE::transcode(), and BuildIsoConfigs::xmlFileName.

210 {
211  //
212  //_____ following removed as a xalan-c component_____________________
213  //
214  /*
215  // xalan objects initialization
216  theSourceTreeInit = 0;
217  theDOMSupport = 0;
218  theLiaison = 0;
219  theInputSource = 0;
220  theDocument = 0;
221  thePrefixResolver = 0;
222  theEvaluator = 0;
223  */
224 
226 
228 
229  // initialize the parser
230  parser = new XercesDOMParser();
231  parser->setValidationScheme(XercesDOMParser::Val_Always);
232  parser->setDoNamespaces(true); // optional
233 
234  errHandler = (ErrorHandler*) new HandlerBase();
235  parser->setErrorHandler(errHandler);
236 
237  // parse the input xml file
238  try
239  {
240  parser->parse( theFileName . c_str() );
241  }
242  catch (const XMLException& toCatch) {
243  char* message = XMLString::transcode(toCatch.getMessage());
244  std::cout << "Exception message is: \n"
245  << message << "\n";
246  XMLString::release(&message);
247  //return -1;
248  }
249  catch (const DOMException& toCatch) {
250  char* message = XMLString::transcode(toCatch.msg);
251  std::cout << "Exception message is: \n"
252  << message << "\n";
253  XMLString::release(&message);
254  //return -1;
255  }
256  catch (...) {
257  std::cout << "Unexpected Exception \n" ;
258  //return -1;
259  }
260 
261  //get the XML document
262  document = parser -> getDocument();
263 
264 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
XMLProcessor * theProcessor
Definition: XMLDOMBlock.h:93
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
Definition: XMLDOMBlock.h:95
std::string theFileName
Definition: XMLDOMBlock.h:97
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
XMLCh * transcode(const T &fInput)
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
Definition: XMLDOMBlock.h:94
tuple cout
Definition: gather_cfg.py:121
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:145
XMLDOMBlock::XMLDOMBlock ( XERCES_CPP_NAMESPACE::InputSource &  _source)
XMLDOMBlock::XMLDOMBlock ( std::string  _root,
int  rootElementName 
)

Definition at line 57 of file XMLDOMBlock.cc.

References init.

58 {
59  //std::cout << "XMLDOMBlock (or derived): default constructor called - this is meaningless!" << std::endl;
60  //std::cout << "XMLDOMBlock (or derived): use yourClass( loaderBaseConfig & ) instead." << std::endl;
61  init( _root );
62 }
int init(std::string _root)
Definition: XMLDOMBlock.cc:167
XMLDOMBlock::~XMLDOMBlock ( )
virtual

Definition at line 329 of file XMLDOMBlock.cc.

References geometryXMLtoCSV::parser.

330 {
331  delete parser;
332  delete errHandler;
333  //if (the_string) delete the_string;
334 
335  //
336  //_____ following removed as a xalan-c component_____________________
337  //
338  /*
339  // delete xalan objects
340  delete theSourceTreeInit;
341  delete theDOMSupport;
342  delete theLiaison;
343  delete theInputSource;
344  //delete theDocument; // noneed to delete - belongs to theLiaison
345  delete thePrefixResolver;
346  delete theEvaluator;
347  */
348 }
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
Definition: XMLDOMBlock.h:95
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
Definition: XMLDOMBlock.h:94

Member Function Documentation

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

Definition at line 523 of file XMLDOMBlock.cc.

523  {
524  DOMElement * _elem = document -> createElement( tagname );
525  parent -> appendChild(_elem);
526  DOMText * _value = document -> createTextNode(value);
527  _elem->appendChild(_value);
528  return _elem;
529 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
list parent
Definition: dbtoconf.py:74
DOMDocument * XMLDOMBlock::getDocument ( void  )
DOMDocument * XMLDOMBlock::getDocumentConst ( void  ) const

Definition at line 317 of file XMLDOMBlock.cc.

Referenced by operator+=().

318 {
319  return document;
320 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
DOMDocument * XMLDOMBlock::getNewDocument ( std::string  xmlFileName)

Definition at line 266 of file XMLDOMBlock.cc.

References gather_cfg::cout, XMLProcessor::getInstance(), geometryXMLtoCSV::parser, fetchall_from_DQM_v2::release, XERCES_CPP_NAMESPACE_USE::transcode(), and BuildIsoConfigs::xmlFileName.

267 {
268  delete document;
269 
271 
273 
274  // initialize the parser
275  parser = new XercesDOMParser();
276  parser->setValidationScheme(XercesDOMParser::Val_Always);
277  parser->setDoNamespaces(true); // optional
278 
279  errHandler = (ErrorHandler*) new HandlerBase();
280  parser->setErrorHandler(errHandler);
281 
282  // parse the input xml file
283  try
284  {
285  parser->parse( theFileName . c_str() );
286  }
287  catch (const XMLException& toCatch) {
288  char* message = XMLString::transcode(toCatch.getMessage());
289  std::cout << "Exception message is: \n"
290  << message << "\n";
291  XMLString::release(&message);
292  //return -1;
293  }
294  catch (const DOMException& toCatch) {
295  char* message = XMLString::transcode(toCatch.msg);
296  std::cout << "Exception message is: \n"
297  << message << "\n";
298  XMLString::release(&message);
299  //return -1;
300  }
301  catch (...) {
302  std::cout << "Unexpected Exception \n" ;
303  //return -1;
304  }
305 
306  //get the XML document
307  document = parser -> getDocument();
308 
309  return document;
310 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
XMLProcessor * theProcessor
Definition: XMLDOMBlock.h:93
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
Definition: XMLDOMBlock.h:95
std::string theFileName
Definition: XMLDOMBlock.h:97
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
XMLCh * transcode(const T &fInput)
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
Definition: XMLDOMBlock.h:94
tuple cout
Definition: gather_cfg.py:121
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:145
std::string & XMLDOMBlock::getString ( void  )

Definition at line 459 of file XMLDOMBlock.cc.

Referenced by LutXml::getCurrentBrick().

460 {
461  return getString( this->getDocument() );
462 }
std::string & getString(void)
Definition: XMLDOMBlock.cc:459
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
std::string& XMLDOMBlock::getString ( XERCES_CPP_NAMESPACE::DOMNode *  _node)
const char * XMLDOMBlock::getTagAttribute ( const std::string &  tagName,
const std::string &  attrName,
int  _item = 0 
)

Definition at line 400 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh(), and XERCES_CPP_NAMESPACE_USE::transcode().

Referenced by XMLRBXPedestalsLoader::addRBXSlot().

401 {
402  DOMElement * _tag = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( tagName ) ) -> item( _item ));
403  const char * _result = XMLString::transcode( _tag -> getAttribute( XMLProcessor::_toXMLCh( attrName ) ) );
404 
405  return _result;
406 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
XMLCh * transcode(const T &fInput)
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
const char* XMLDOMBlock::getTagValue ( const std::string &  tagName,
int  _item = 0,
XERCES_CPP_NAMESPACE::DOMDocument *  _document = NULL 
)
const char* XMLDOMBlock::getTagValue ( const std::string &  tagName,
int  _item,
XERCES_CPP_NAMESPACE::DOMElement *  _document 
)
string XMLDOMBlock::getTimestamp ( time_t  _time)

Definition at line 446 of file XMLDOMBlock.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

447 {
448  char timebuf[50];
449  //strftime( timebuf, 50, "%c", gmtime( &_time ) );
450  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &_time ) );
451  std::string creationstamp = timebuf;
452 
453  return creationstamp;
454 }
int XMLDOMBlock::init ( std::string  _root)
protected

Definition at line 167 of file XMLDOMBlock.cc.

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

168 {
170 
171  //theFileName = xmlFileName;
172 
173  // initialize the parser
174  parser = new XercesDOMParser();
175  parser->setValidationScheme(XercesDOMParser::Val_Always);
176  parser->setDoNamespaces(true); // optional
177 
178  errHandler = (ErrorHandler*) new HandlerBase();
179  parser->setErrorHandler(errHandler);
180 
181  DOMImplementation* impl = DOMImplementation::getImplementation();
182 
183  document = impl->createDocument(
184  0, // root element namespace URI.
185  //XMLString::transcode("ROOT"), // root element name
186  XMLProcessor::_toXMLCh(_root), // root element name
187  0); // document type object (DTD).
188 
189  the_string = 0;
190 
191  //
192  //_____ following removed as a xalan-c component_____________________
193  //
194  /*
195  // xalan objects initialization
196  theSourceTreeInit = 0;
197  theDOMSupport = 0;
198  theLiaison = 0;
199  theInputSource = 0;
200  theDocument = 0;
201  thePrefixResolver = 0;
202  theEvaluator = 0;
203  */
204  return 0;
205 }
std::string * the_string
Definition: XMLDOMBlock.h:98
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
XMLProcessor * theProcessor
Definition: XMLDOMBlock.h:93
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
Definition: XMLDOMBlock.h:95
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
Definition: XMLDOMBlock.h:94
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:145
XMLDOMBlock & XMLDOMBlock::operator+= ( const XMLDOMBlock other)

Definition at line 35 of file XMLDOMBlock.cc.

References getDocumentConst(), and i.

36 {
37  DOMNodeList * _children = other.getDocumentConst()->getDocumentElement()->getChildNodes();
38  int _length = _children->getLength();
39  //std::cout << "Children nodes:" << _length << std::endl;
40  DOMNode * _node;
41  for(int i=0;i!=_length;i++){
42  _node = _children->item(i);
43  DOMNode * i_node = this->getDocument()->importNode(_node,true);
44  this->getDocument()->getDocumentElement()->appendChild(i_node);
45  }
46  return *this;
47 }
int i
Definition: DBlmapReader.cc:9
XERCES_CPP_NAMESPACE::DOMDocument * getDocumentConst(void) const
Definition: XMLDOMBlock.cc:317
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
void XMLDOMBlock::parse ( XERCES_CPP_NAMESPACE::InputSource &  _source)

Definition at line 122 of file XMLDOMBlock.cc.

References gather_cfg::cout, XMLProcessor::getInstance(), geometryXMLtoCSV::parser, fetchall_from_DQM_v2::release, and XERCES_CPP_NAMESPACE_USE::transcode().

Referenced by HcalTriggerKey::HcalTriggerKey().

123 {
124 
126 
127  //theFileName = xmlFileName;
128 
129  // initialize the parser
130  parser = new XercesDOMParser();
131  parser->setValidationScheme(XercesDOMParser::Val_Always);
132  parser->setDoNamespaces(true); // optional
133 
134  errHandler = (ErrorHandler*) new HandlerBase();
135  parser->setErrorHandler(errHandler);
136 
137  // parse the input xml file
138  try
139  {
140  parser->parse( _source );
141  }
142  catch (const XMLException& toCatch) {
143  char* message = XMLString::transcode(toCatch.getMessage());
144  std::cout << "Exception message is: \n"
145  << message << "\n";
146  XMLString::release(&message);
147  //return -1;
148  }
149  catch (const DOMException& toCatch) {
150  char* message = XMLString::transcode(toCatch.msg);
151  std::cout << "Exception message is: \n"
152  << message << "\n";
153  XMLString::release(&message);
154  //return -1;
155  }
156  catch (...) {
157  std::cout << "Unexpected Exception \n" ;
158  //return -1;
159  }
160 
161  //get the XML document
162  document = parser -> getDocument();
163 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
XMLProcessor * theProcessor
Definition: XMLDOMBlock.h:93
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
Definition: XMLDOMBlock.h:95
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
XMLCh * transcode(const T &fInput)
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
Definition: XMLDOMBlock.h:94
tuple cout
Definition: gather_cfg.py:121
static XMLProcessor * getInstance()
Definition: XMLProcessor.h:145
DOMNode * XMLDOMBlock::setTagAttribute ( const std::string &  tagName,
const std::string &  attrName,
const std::string &  attrValue,
int  _item = 0 
)

Definition at line 408 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh().

Referenced by XMLHTRPatternLoader::XMLHTRPatternLoader(), XMLHTRZeroSuppressionLoader::XMLHTRZeroSuppressionLoader(), XMLLUTLoader::XMLLUTLoader(), and XMLRBXPedestalsLoader::XMLRBXPedestalsLoader().

409 {
410  DOMNode * the_tag = document -> getElementsByTagName( XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
411  DOMElement * _tag = (DOMElement *)the_tag;
412  _tag -> setAttribute( XMLProcessor::_toXMLCh( attrName ), XMLProcessor::_toXMLCh( attrValue ) );
413  return the_tag;
414 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
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 
)
DOMNode * XMLDOMBlock::setTagAttribute ( const std::string &  tagName,
const std::string &  attrName,
const int &  attrValue,
int  _item = 0 
)

Definition at line 427 of file XMLDOMBlock.cc.

References XMLProcessor::_toXMLCh().

428 {
429  DOMNode * the_tag = document -> getElementsByTagName( XMLProcessor::_toXMLCh( tagName ) ) -> item( _item );
430  DOMElement * _tag = (DOMElement *)the_tag;
431  _tag -> setAttribute( XMLProcessor::_toXMLCh( attrName ), XMLProcessor::_toXMLCh( attrValue ) );
432  return the_tag;
433 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
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 
)
XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagValue ( const std::string &  tagName,
const std::string &  tagValue,
int  _item = 0,
XERCES_CPP_NAMESPACE::DOMDocument *  _document = NULL 
)
XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagValue ( XERCES_CPP_NAMESPACE::DOMElement *  _elem,
const std::string &  tagName,
const std::string &  tagValue,
int  _item = 0 
)
XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagValue ( const std::string &  tagName,
const int &  tagValue,
int  _item = 0,
XERCES_CPP_NAMESPACE::DOMDocument *  _document = NULL 
)
XERCES_CPP_NAMESPACE::DOMNode* XMLDOMBlock::setTagValue ( XERCES_CPP_NAMESPACE::DOMElement *  _elem,
const std::string &  tagName,
const int &  tagValue,
int  _item = 0 
)
int XMLDOMBlock::write ( std::string  target = "stdout")

Definition at line 322 of file XMLDOMBlock.cc.

References TablePrint::write.

Referenced by WriteL1TriggerObjetsXml::analyze(), XMLLUTLoader::createLoader(), XMLHTRPatternLoader::createLoader(), and pkg.AbstractPkg::generate().

323 {
324  theProcessor -> write( this, target );
325 
326  return 0;
327 }
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:322
XMLProcessor * theProcessor
Definition: XMLDOMBlock.h:93

Friends And Related Function Documentation

friend class XMLProcessor
friend

Definition at line 45 of file XMLDOMBlock.h.

Member Data Documentation

XERCES_CPP_NAMESPACE::DOMDocument* XMLDOMBlock::document
protected
XERCES_CPP_NAMESPACE::ErrorHandler* XMLDOMBlock::errHandler
protected

Definition at line 95 of file XMLDOMBlock.h.

XERCES_CPP_NAMESPACE::XercesDOMParser* XMLDOMBlock::parser
protected

Definition at line 94 of file XMLDOMBlock.h.

std::string* XMLDOMBlock::the_string
protected

Definition at line 98 of file XMLDOMBlock.h.

std::string XMLDOMBlock::theFileName
protected

Definition at line 97 of file XMLDOMBlock.h.

XMLProcessor* XMLDOMBlock::theProcessor
protected

Definition at line 93 of file XMLDOMBlock.h.