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> 45 }
catch (
const XMLException& toCatch) {
46 std::cerr <<
"Error during Xerces-c Initialization.\n" 47 <<
" Exception message:" << XMLString::transcode(toCatch.getMessage()) << std::endl;
52 parser->setValidationScheme(XercesDOMParser::Val_Auto);
53 parser->setDoNamespaces(
false);
54 parser->setDoSchema(
false);
55 parser->setValidationSchemaFullChecking(
false);
58 parser->setCreateEntityReferenceNodes(
false);
60 bool errorsOccured =
false;
64 int errorCount =
parser->getErrorCount();
67 }
catch (
const XMLException&
e) {
68 std::cerr <<
"A DOM error occured during parsing\n DOMException code: " << (
long unsigned int)
e.getCode()
74 std::cerr <<
"An error occured during parsing\n" 75 <<
"Please check your input with SAXCount or a similar tool.\n Exiting!\n" 85 if (n1->getNodeType() == DOMNode::ELEMENT_NODE)
87 n1 = n1->getNextSibling();
90 if (n1 ==
nullptr || strcmp(
"Calibration", XMLString::transcode(n1->getNodeName())))
101 DOMImplementation* theImpl = DOMImplementationRegistry::getDOMImplementation(XMLString::transcode(
"Core"));
102 DOMLSSerializer* theSerializer = ((DOMImplementation*)theImpl)->createLSSerializer();
103 DOMConfiguration* dc = theSerializer->getDomConfig();
104 dc->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
106 XMLFormatTarget* myFormTarget =
new LocalFileFormatTarget(XMLString::transcode(xmlFileName.c_str()));
107 DOMLSOutput* outputDesc = ((DOMImplementationLS*)theImpl)->createLSOutput();
108 outputDesc->setByteStream(myFormTarget);
110 theSerializer->write(
doc, outputDesc);
118 while (n1 &&
level < 100) {
121 n1 = n1->getParentNode();
124 if (
dom->getFirstChild() ==
nullptr)
125 dom->appendChild(
dom->getOwnerDocument()->createTextNode(XMLString::transcode(
indent.c_str())));
128 (
DOMElement*)
dom->appendChild(
dom->getOwnerDocument()->createElement(XMLString::transcode(
name.c_str())));
129 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)
Log< level::Info, false > LogInfo
std::string m_xmlFileName
XERCES_CPP_NAMESPACE::DOMElement DOMElement
void saveFile(const std::string &xmlFileName)
XERCES_CPP_NAMESPACE::XercesDOMParser XercesDOMParser