CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions
EcalClusterLocalContCorrXMLTranslator Class Reference

#include <EcalClusterLocalContCorrXMLTranslator.h>

Static Public Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalFunParams &record)
 
static int readXML (const std::string &filename, EcalCondHeader &header, EcalFunParams &record)
 
static int writeXML (const std::string &filename, const EcalCondHeader &header, const EcalFunParams &record)
 

Detailed Description

Translates a EcalClusterLocalContCorr record to XML and vice versa

Author
Version
Id:
EcalClusterLocalContCorrXMLTranslator.h,v 1.0
Date
October 2011

Definition at line 21 of file EcalClusterLocalContCorrXMLTranslator.h.

Member Function Documentation

std::string EcalClusterLocalContCorrXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalFunParams record 
)
static

Definition at line 55 of file EcalClusterLocalContCorrXMLTranslator.cc.

References asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EcalFunParams::params(), dbtoconf::root, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), xuti::Value_tag(), xuti::writeHeader(), xuti::WriteNodeWithValue(), and cms::concurrency::xercesInitialize().

Referenced by cond::PayLoadInspector< DataT >::dump().

57  {
58 
60 
61  DOMImplementation* impl =
62  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
63 
64  DOMWriter* writer =
65  static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
66  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
67 
68  DOMDocumentType* doctype =
69  impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
70  const std::string EcalClusterLocalContCorr_tag("EcalClusterLocalContCorr");
71  DOMDocument * doc =
72  impl->createDocument( 0, fromNative(EcalClusterLocalContCorr_tag).c_str(), doctype );
73 
74 
75  doc->setEncoding(fromNative("UTF-8").c_str() );
76  doc->setStandalone(true);
77  doc->setVersion(fromNative("1.0").c_str() );
78 
79 
80  DOMElement* root = doc->getDocumentElement();
81  xuti::writeHeader(root, header);
82 
83  const std::string ECEC_tag("ClusterLocal");
84  for ( EcalFunctionParameters::const_iterator it = record.params().begin(); it != record.params().end(); ++it ) {
85  DOMElement* ECEC =
86  root->getOwnerDocument()->createElement( fromNative(ECEC_tag).c_str());
87  root->appendChild(ECEC);
88 
89  WriteNodeWithValue(ECEC,Value_tag,*it);
90  }
91 
92  std::string dump= toNative(writer->writeToString(*root));
93  doc->release();
94  return dump;
95 }
void xercesInitialize()
Definition: Xerces.cc:17
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string Value_tag("Value")
EcalFunctionParameters & params()
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
tuple doc
Definition: asciidump.py:381
XercesString fromNative(const char *str)
Definition: XercesString.h:31
std::string toNative(const XMLCh *str)
Definition: XercesString.h:42
string root
initialization
Definition: dbtoconf.py:70
int EcalClusterLocalContCorrXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFunParams record 
)
static

Definition at line 21 of file EcalClusterLocalContCorrXMLTranslator.cc.

References gather_cfg::cout, geometryXMLtoCSV::parser, xuti::readHeader(), cms::concurrency::xercesInitialize(), and cms::concurrency::xercesTerminate().

24  {
25 
27 
28  XercesDOMParser* parser = new XercesDOMParser;
29  parser->setValidationScheme( XercesDOMParser::Val_Never );
30  parser->setDoNamespaces( false );
31  parser->setDoSchema( false );
32 
33  parser->parse(filename.c_str());
34 
35  DOMDocument* xmlDoc = parser->getDocument();
36 
37 
38  if (!xmlDoc) {
39  std::cout << "EcalClusterLocalContCorrXMLTranslator::Error parsing document" << std::endl;
40  return -1;
41  }
42 
43  DOMElement* elementRoot = xmlDoc->getDocumentElement();
44 
45  xuti::readHeader(elementRoot, header);
46 
47  // need some extra code here
48 
49  delete parser;
51  return 0;
52 }
void xercesTerminate()
Definition: Xerces.cc:22
void xercesInitialize()
Definition: Xerces.cc:17
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
int EcalClusterLocalContCorrXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFunParams record 
)
static

Definition at line 98 of file EcalClusterLocalContCorrXMLTranslator.cc.

References EcalCondTools::dumpXML(), and dbtoconf::out.

101  {
102 
103  std::fstream fs(filename.c_str(),ios::out);
104  fs<< dumpXML(header,record);
105  return 0;
106 }
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20