44 #include <xercesc/sax2/SAX2XMLReader.hpp>
45 #include <xercesc/sax2/XMLReaderFactory.hpp>
46 #include <xercesc/util/XMLString.hpp>
59 template<
class UserParser,
class OutputStructure>
60 int loadXercesXmlData(
const std::string& p_xml_file, OutputStructure& o_xml_data)
67 xercesc::XMLPlatformUtils::Initialize();
69 catch (
const xercesc::XMLException& toCatch) {
75 xercesc::SAX2XMLReader* parser = xercesc::XMLReaderFactory::createXMLReader();
78 parser->setFeature(xercesc::XMLUni::fgSAX2CoreValidation,
true);
81 UserParser* handler =
new UserParser( o_xml_data );
84 parser->setContentHandler(handler);
85 parser->setErrorHandler(handler);
91 parser->parse( p_xml_file.c_str() );
94 catch (
const xercesc::XMLException& toCatch)
96 char* message = xercesc::XMLString::transcode(toCatch.getMessage());
97 std::cerr <<
"Возникло исключение: \n" << message << std::ends;
98 xercesc::XMLString::release(&message);
110 xercesc::XMLPlatformUtils::Terminate();
113 std::clog <<
"load_xerces_xml_data: XML данные НЕ загружены!\n";