5 #include <xercesc/dom/DOMNode.hpp>
6 #include <xercesc/dom/DOM.hpp>
7 #include <xercesc/parsers/XercesDOMParser.hpp>
8 #include <xercesc/util/PlatformUtils.hpp>
9 #include <xercesc/util/XMLString.hpp>
10 #include <xercesc/sax/SAXException.hpp>
11 #include <xercesc/framework/LocalFileFormatTarget.hpp>
16 using namespace XERCES_CPP_NAMESPACE;
27 XMLPlatformUtils::Initialize();
29 XercesDOMParser*
parser =
new XercesDOMParser;
30 parser->setValidationScheme( XercesDOMParser::Val_Never );
31 parser->setDoNamespaces(
false );
32 parser->setDoSchema(
false );
34 parser->parse(filename.c_str());
36 DOMDocument* xmlDoc = parser->getDocument();
40 std::cout <<
"EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::Error parsing document"
45 DOMElement* elementRoot = xmlDoc->getDocumentElement();
52 XMLPlatformUtils::Terminate();
61 XMLPlatformUtils::Initialize();
63 DOMImplementation* impl =
64 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
67 static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
68 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
70 DOMDocumentType* doctype =
71 impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
72 const std::string ECECOS_tag(
"EcalClusterEnergyCorrectionObjectSpecific");
74 impl->createDocument( 0,
fromNative(ECECOS_tag).c_str(), doctype );
77 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
78 doc->setStandalone(
true);
82 DOMElement*
root = doc->getDocumentElement();
85 const std::string ECEC_tag[9] = {
"fEta",
"fBremEtaElectrons",
"fBremEtaPhotons",
86 "fEtElectronsEB",
"fEtElectronsEE",
"fEtPhotonsEB",
"fEtPhotonsEE",
87 "fEnergyElectronsEE",
"fEnergyPhotonsEE"};
90 for ( EcalFunctionParameters::const_iterator it = record.
params().begin(); it != record.
params().end(); ++it ) {
92 else if(par < 86) tit = 1;
93 else if(par < 170) tit = 2;
94 else if(par < 177) tit = 3;
95 else if(par < 184) tit = 4;
96 else if(par < 191) tit = 5;
97 else if(par < 198) tit = 6;
98 else if(par < 203) tit = 7;
101 root->getOwnerDocument()->createElement(
fromNative(ECEC_tag[tit]).c_str());
102 root->appendChild(ECEC);
109 std::string
dump=
toNative(writer->writeToString(*root));
120 std::fstream fs(filename.c_str(),
ios::out);
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalFunParams &record)
void WriteNodeWithValue(xercesc::DOMNode *parentNode, const std::string &tag, const T &value)
write a node with
const std::string Value_tag("Value")
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFunParams &record)
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
EcalFunctionParameters & params()
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)
XercesString fromNative(const char *str)
std::string toNative(const XMLCh *str)
string root
initialization