CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESGainXMLTranslator.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <fstream>
4 #include <xercesc/dom/DOMNode.hpp>
5 #include <xercesc/dom/DOM.hpp>
6 #include <xercesc/parsers/XercesDOMParser.hpp>
8 #include <xercesc/util/XMLString.hpp>
9 #include <xercesc/sax/SAXException.hpp>
10 #include <xercesc/framework/LocalFileFormatTarget.hpp>
11 
12 
16 
17 using namespace XERCES_CPP_NAMESPACE;
18 using namespace xuti;
19 using namespace std;
20 
22  const EcalCondHeader& header,
23  const ESGain& record){
24  std::fstream fs(filename.c_str(),ios::out);
25  fs<< dumpXML(header,record);
26  return 0;
27 
28 }
29 
31  const ESGain& record){
32 
34 
35  DOMImplementation* impl =
36  DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
37 
38  DOMWriter* writer =static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
39  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
40 
41  DOMDocumentType* doctype = impl->createDocumentType(fromNative("XML").c_str(), 0, 0 );
42  DOMDocument * doc =
43  impl->createDocument( 0, fromNative(ADCToGeVConstant_tag).c_str(), doctype );
44 
45 
46  doc->setEncoding(fromNative("UTF-8").c_str() );
47  doc->setStandalone(true);
48  doc->setVersion(fromNative("1.0").c_str() );
49 
50  DOMElement* root = doc->getDocumentElement();
51 
52  xuti::writeHeader(root,header);
53 
55 
56  std::string dump= toNative(writer->writeToString(*root));
57  doc->release();
58 
59  // cms::concurrency::xercesTerminate();
60 
61  return dump;
62 }
63 
static std::string dumpXML(const EcalCondHeader &header, const ESGain &record)
Definition: ESGain.h:5
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 ESGain_tag("ESGain")
const std::string ADCToGeVConstant_tag("EcalADCToGeVConstant")
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
tuple doc
Definition: asciidump.py:381
tuple out
Definition: dbtoconf.py:99
static int writeXML(const std::string &filename, const EcalCondHeader &header, const ESGain &record)
float getESGain() const
Definition: ESGain.h:11
tuple filename
Definition: lut2db_cfg.py:20
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