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;
26 XMLPlatformUtils::Initialize();
28 XercesDOMParser*
parser =
new XercesDOMParser;
29 parser->setValidationScheme( XercesDOMParser::Val_Never );
30 parser->setDoNamespaces(
false );
31 parser->setDoSchema(
false );
33 parser->parse(filename.c_str());
35 DOMDocument* xmlDoc = parser->getDocument();
39 std::cout <<
"EcalClusterLocalContCorrXMLTranslator::Error parsing document" << std::endl;
43 DOMElement* elementRoot = xmlDoc->getDocumentElement();
50 XMLPlatformUtils::Terminate();
59 XMLPlatformUtils::Initialize();
61 DOMImplementation* impl =
62 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
65 static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
66 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
68 DOMDocumentType* doctype =
69 impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
70 const std::string EcalClusterLocalContCorr_tag(
"EcalClusterLocalContCorr");
72 impl->createDocument( 0,
fromNative(EcalClusterLocalContCorr_tag).c_str(), doctype );
75 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
76 doc->setStandalone(
true);
80 DOMElement*
root = doc->getDocumentElement();
83 const std::string ECEC_tag(
"ClusterLocal");
84 for ( EcalFunctionParameters::const_iterator it = record.
params().begin(); it != record.
params().end(); ++it ) {
86 root->getOwnerDocument()->createElement(
fromNative(ECEC_tag).c_str());
87 root->appendChild(ECEC);
92 std::string
dump=
toNative(writer->writeToString(*root));
103 std::fstream fs(filename.c_str(),
ios::out);
static int readXML(const std::string &filename, EcalCondHeader &header, 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 writeXML(const std::string &filename, const EcalCondHeader &header, const EcalFunParams &record)
void readHeader(xercesc::DOMNode *parentNode, EcalCondHeader &header)
read header from
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)
EcalFunctionParameters & params()
void writeHeader(xercesc::DOMNode *parentNode, const EcalCondHeader &header)
write
XercesString fromNative(const char *str)
std::string toNative(const XMLCh *str)
string root
initialization