6 #include <xercesc/framework/LocalFileFormatTarget.hpp>
7 #include <xercesc/parsers/XercesDOMParser.hpp>
8 #include <xercesc/dom/DOM.hpp>
9 #include <xercesc/dom/DOMWriter.hpp>
10 #include <xercesc/sax/HandlerBase.hpp>
11 #include <xercesc/util/XMLString.hpp>
20 XERCES_CPP_NAMESPACE_USE
49 catch(
const XMLException& toCatch)
51 std::cerr <<
"Error during Xerces-c Initialization.\n"
52 <<
" Exception message:"
53 << XMLString::transcode(toCatch.getMessage()) << std::endl;
58 parser->setValidationScheme(XercesDOMParser::Val_Auto);
59 parser->setDoNamespaces(
false);
60 parser->setDoSchema(
false);
61 parser->setValidationSchemaFullChecking(
false);
64 parser->setCreateEntityReferenceNodes(
false);
66 bool errorsOccured =
false;
71 int errorCount =
parser->getErrorCount();
72 if (errorCount > 0) errorsOccured =
true;
74 catch (
const XMLException&
e)
76 std::cerr <<
"A DOM error occured during parsing\n DOMException code: "
77 << (
long unsigned int)e.getCode() << std::endl;
82 std::cerr <<
"An error occured during parsing\n"
83 <<
"Please check your input with SAXCount or a similar tool.\n Exiting!\n" << std::endl;
93 if (n1->getNodeType() == DOMNode::ELEMENT_NODE )
break;
94 n1 = n1->getNextSibling();
97 if(strcmp(
"Calibration",XMLString::transcode(n1->getNodeName())))
100 else {
edm::LogInfo(
"XMLCalibration") <<
"Calibration found" ; }
110 DOMImplementation * theImpl = DOMImplementationRegistry::getDOMImplementation(XMLString::transcode(
"Core"));
111 DOMWriter * theSerializer = ((DOMImplementation*)theImpl)->createDOMWriter();
112 theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
113 XMLFormatTarget* myFormTarget =
new LocalFileFormatTarget(XMLString::transcode(xmlFileName.c_str()));
114 theSerializer->writeNode(myFormTarget, *
doc);
123 while(n1 && level < 100)
127 n1 = n1->getParentNode();
129 if(dom->getFirstChild()==0)
130 dom->appendChild(dom->getOwnerDocument()->createTextNode(XMLString::transcode(indent.c_str())));
132 DOMElement *
child = (
DOMElement *)dom->appendChild(dom->getOwnerDocument()->createElement(XMLString::transcode(name.c_str())));
133 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