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 <<
"EcalClusterCrackCorrXMLTranslator::Error parsing document" << std::endl;
44 DOMElement* elementRoot = xmlDoc->getDocumentElement();
51 XMLPlatformUtils::Terminate();
60 XMLPlatformUtils::Initialize();
62 DOMImplementation* impl =
63 DOMImplementationRegistry::getDOMImplementation(
fromNative(
"LS").c_str());
66 static_cast<DOMImplementationLS*
>(impl)->createDOMWriter( );
67 writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
69 DOMDocumentType* doctype =
70 impl->createDocumentType(
fromNative(
"XML").c_str(), 0, 0 );
71 const std::string EcalClusterCrackCorr_tag(
"EcalClusterCrackCorr");
73 impl->createDocument( 0,
fromNative(EcalClusterCrackCorr_tag).c_str(), doctype );
76 doc->setEncoding(
fromNative(
"UTF-8").c_str() );
77 doc->setStandalone(
true);
80 DOMElement*
root = doc->getDocumentElement();
83 const std::string ECCC_tag[4] = {
"IPCloseEtaSide",
"IPFarEtaSide",
84 "IPClosePhiSide",
"IPFarPhiSide"};;
86 for ( EcalFunctionParameters::const_iterator it = record.
params().begin(); it != record.
params().end(); ++it ) {
90 std::stringstream
out;
93 std::string sw = ECCC_tag[side] +
"_" +
s;
95 root->getOwnerDocument()->createElement(
fromNative(sw).c_str());
96 root->appendChild(ECCC);
102 std::string
dump=
toNative(writer->writeToString(*root));
113 std::fstream fs(filename.c_str(),
ios::out);
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
XercesString fromNative(const char *str)
static int writeXML(const std::string &filename, const EcalCondHeader &header, const EcalFunParams &record)
static std::string dumpXML(const EcalCondHeader &header, const EcalFunParams &record)
std::string toNative(const XMLCh *str)
string root
initialization