Skip to content

Commit

Permalink
Fixed bug where XML validation error was not printed, Fixes #146
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewThe committed Apr 21, 2016
1 parent 73c1380 commit 8c45d4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/XMLInterface.cpp
Expand Up @@ -87,7 +87,6 @@ int XMLInterface::readAndScorePin(istream& dataStream, std::vector<double>& rawW

string schemaDefinition = Globals::getInstance()->getXMLDir()+PIN_SCHEMA_LOCATION+string("percolator_in.xsd");
parser p;
std::string xmlInputFN = "";
xml_schema::dom::auto_ptr<DOMDocument> doc(p.start(
dataStream, xmlInputFN.c_str(), schemaValidation_,
schemaDefinition, PIN_VERSION_MAJOR, PIN_VERSION_MINOR));
Expand Down Expand Up @@ -275,14 +274,14 @@ int XMLInterface::readAndScorePin(istream& dataStream, std::vector<double>& rawW
}

} catch (const xml_schema::exception& e) {
std::cerr << e << endl;
std::cerr << "ERROR: xml schema error " << e << endl;
return 0;
} catch (const std::ios_base::failure&) {
std::cerr << "ERROR: unable to open or read" << std::endl;
return 0;
} catch (const xercesc::DOMException& e) {
char * tmpStr = XMLString::transcode(e.getMessage());
std::cerr << "ERROR: catched xercesc::DOMException=" << tmpStr << std::endl;
char* tmpStr = XMLString::transcode(e.getMessage());
std::cerr << "ERROR: caught xercesc::DOMException=" << tmpStr << std::endl;
XMLString::release(&tmpStr);
return 0;
}
Expand Down Expand Up @@ -335,7 +334,7 @@ PSMDescription* XMLInterface::readPsm(

if (psm.occurence().size() <= 0) {
ostringstream temp;
temp << "Error: adding PSM " << psm.id() << " to the dataset.\n\
temp << "Error: cannot add PSM " << psm.id() << " to the dataset.\n\
The PSM does not contain protein occurences." << std::endl;
throw MyException(temp.str());
}
Expand Down
10 changes: 7 additions & 3 deletions src/parser.cxx
Expand Up @@ -241,13 +241,17 @@ void error_handler::handle(const SAXParseException& e, severity s) {

if (xid == 0)
xid = e.getSystemId();


if (xid == 0) // MT: this should not happen, but it does...
xid = XMLString::transcode("input.xml");

char* id(XMLString::transcode(xid));
char* msg(XMLString::transcode(e.getMessage()));

ostringstream temp;
temp << id << ":" << e.getLineNumber () << ":" << e.getColumnNumber ()
<< " " << (s == s_warning ? "warning: " : "error: ") << msg << endl;
temp << "XML parser " << (s == s_warning ? "warning" : "error")
<< " at " << id << ":" << e.getLineNumber() << ":" << e.getColumnNumber()
<< "\n " << (s == s_warning ? "warning: " : "error: ") << msg << endl;
XMLString::release (&id);
XMLString::release (&msg);

Expand Down

0 comments on commit 8c45d4b

Please sign in to comment.