6 #include <xercesc/framework/LocalFileFormatTarget.hpp> 7 #include <xercesc/parsers/XercesDOMParser.hpp> 8 #include <xercesc/dom/DOM.hpp> 9 #include <xercesc/sax/HandlerBase.hpp> 10 #include <xercesc/util/XMLString.hpp> 48 catch(
const XMLException& toCatch)
50 std::cerr <<
"Error during Xerces-c Initialization.\n" 51 <<
" Exception message:" 52 << XMLString::transcode(toCatch.getMessage()) << std::endl;
57 parser->setValidationScheme(XercesDOMParser::Val_Auto);
58 parser->setDoNamespaces(
false);
59 parser->setDoSchema(
false);
60 parser->setValidationSchemaFullChecking(
false);
63 parser->setCreateEntityReferenceNodes(
false);
65 bool errorsOccured =
false;
70 int errorCount =
parser->getErrorCount();
71 if (errorCount > 0) errorsOccured =
true;
73 catch (
const XMLException&
e)
75 std::cerr <<
"A DOM error occured during parsing\n DOMException code: " 76 << (
long unsigned int)e.getCode() << std::endl;
81 std::cerr <<
"An error occured during parsing\n" 82 <<
"Please check your input with SAXCount or a similar tool.\n Exiting!\n" << std::endl;
92 if (n1->getNodeType() == DOMNode::ELEMENT_NODE )
break;
93 n1 = n1->getNextSibling();
96 if(n1 ==
nullptr || strcmp(
"Calibration",XMLString::transcode(n1->getNodeName())))
99 else {
edm::LogInfo(
"XMLCalibration") <<
"Calibration found" ; }
109 DOMImplementation * theImpl = DOMImplementationRegistry::getDOMImplementation(XMLString::transcode(
"Core"));
110 DOMLSSerializer * theSerializer = ((DOMImplementation*)theImpl)->createLSSerializer();
111 DOMConfiguration* dc = theSerializer->getDomConfig();
112 dc->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
114 XMLFormatTarget* myFormTarget =
new LocalFileFormatTarget(XMLString::transcode(xmlFileName.c_str()));
115 DOMLSOutput* outputDesc = ((DOMImplementationLS*)theImpl)->createLSOutput();
116 outputDesc->setByteStream(myFormTarget);
118 theSerializer->write(
doc, outputDesc);
127 while(n1 && level < 100)
131 n1 = n1->getParentNode();
134 if(dom->getFirstChild()==0)
135 dom->appendChild(dom->getOwnerDocument()->createTextNode(XMLString::transcode(indent.c_str())));
137 DOMElement *
child = (
DOMElement *)dom->appendChild(dom->getOwnerDocument()->createElement(XMLString::transcode(name.c_str())));
138 dom->appendChild(dom->getOwnerDocument()->createTextNode(XMLString::transcode(indent.c_str())));
static DOMElement * addChild(DOMNode *dom, const std::string &name)
DOMElement * m_calibrationDOM
XERCES_CPP_NAMESPACE::HandlerBase HandlerBase
XERCES_CPP_NAMESPACE::DOMNode DOMNode
void openFile(const std::string &xmlFileName)
std::string m_xmlFileName
XERCES_CPP_NAMESPACE::DOMElement DOMElement
void saveFile(const std::string &xmlFileName)
XERCES_CPP_NAMESPACE::XercesDOMParser XercesDOMParser