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>
12 #include <xercesc/util/PlatformUtils.hpp>
20 XERCES_CPP_NAMESPACE_USE
33 XMLPlatformUtils::Terminate();
40 if(
parser) {
delete parser; XMLPlatformUtils::Terminate(); }
47 XMLPlatformUtils::Initialize();
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 unknown error occured during parsing\n " << std::endl;
87 std::cerr <<
"An error occured during parsing\n"
88 <<
"Please check your input with SAXCount or a similar tool.\n Exiting!\n" << std::endl;
98 if (n1->getNodeType() == DOMNode::ELEMENT_NODE )
break;
99 n1 = n1->getNextSibling();
102 if(strcmp(
"Calibration",XMLString::transcode(n1->getNodeName())))
105 else {
edm::LogInfo(
"XMLCalibration") <<
"Calibration found" ; }
115 DOMImplementation * theImpl = DOMImplementationRegistry::getDOMImplementation(XMLString::transcode(
"Core"));
116 DOMWriter * theSerializer = ((DOMImplementation*)theImpl)->createDOMWriter();
117 theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
118 XMLFormatTarget* myFormTarget =
new LocalFileFormatTarget(XMLString::transcode(xmlFileName.c_str()));
119 theSerializer->writeNode(myFormTarget, *
doc);
128 while(n1 && level < 100)
132 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