| 70 | } |
| 71 | |
| 72 | void parse(xercesc::InputSource* const source, XMLHandler* handler) |
| 73 | { |
| 74 | unique_ptr<xercesc::SAX2XMLReader> parser(xercesc::XMLReaderFactory::createXMLReader()); |
| 75 | |
| 76 | parser->setFeature(xercesc::XMLUni::fgSAX2CoreNameSpaces, false); |
| 77 | parser->setFeature(xercesc::XMLUni::fgSAX2CoreNameSpacePrefixes, false); |
| 78 | |
| 79 | parser->setContentHandler(handler); |
| 80 | parser->setErrorHandler(handler); |
| 81 | |
| 82 | |
| 83 | // try to parse file |
| 84 | try |
| 85 | { |
| 86 | parser->parse(*source); |
| 87 | } |
| 88 | catch (const xercesc::XMLException& toCatch) |
| 89 | { |
| 90 | throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "", String("XMLException: ") + StringManager().convert(toCatch.getMessage())); |
| 91 | } |
| 92 | catch (const xercesc::SAXException& toCatch) |
| 93 | { |
| 94 | throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "", String("SAXException: ") + StringManager().convert(toCatch.getMessage())); |
| 95 | } |
| 96 | catch (const XMLHandler::EndParsingSoftly& /*toCatch*/) |
| 97 | { |
| 98 | // nothing to do here, as this exception is used to softly abort the |
| 99 | // parsing for whatever reason. |
| 100 | } |
| 101 | catch (...) |
| 102 | { |
| 103 | // re-throw |
| 104 | throw; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | void XMLFile::parse_(const String & filename, XMLHandler * handler) |
| 109 | { |
no test coverage detected