本文整理汇总了C++中ErrorHandler::getSawErrors方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorHandler::getSawErrors方法的具体用法?C++ ErrorHandler::getSawErrors怎么用?C++ ErrorHandler::getSawErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::getSawErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
bool VART::XmlBase::ParseFile(const std::string& fileName)
{
static XercesDOMParser::ValSchemes ValScheme = XercesDOMParser::Val_Auto; //Val_Never Val_Always
bool bDoNamespaces = false;
bool bDoSchema = false;
bool bSchemaFullChecking = false;
bool bDoCreate = false;
ErrorHandler* errorHPtr;
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException &toCatch)
{
cerr << "Error during Xerces-c Initialization.\n"
<< " Exception message:"
<< TempCString(toCatch.getMessage()) << endl;
return false;
}
if (parserPtr)
delete parserPtr;
parserPtr = new XercesDOMParser;
parserPtr->setValidationScheme(ValScheme);
parserPtr->setDoNamespaces(bDoNamespaces);
parserPtr->setDoSchema(bDoSchema);
parserPtr->setValidationSchemaFullChecking(bSchemaFullChecking);
parserPtr->setCreateEntityReferenceNodes(bDoCreate);
// Create the error handler and install it
errorHPtr = new ErrorHandler;
parserPtr->setErrorHandler(errorHPtr);
// Parse the XML file, catching any XML exceptions that might propogate
// out of it.
try
{
parserPtr->parse(fileName.c_str());
}
catch (const OutOfMemoryException&)
{
cerr << "OutOfMemoryException" << endl;
delete errorHPtr;
return false;
}
catch (const XMLException& e)
{
cerr << "An error occurred during parsing\n Message: "
<< TempCString(e.getMessage()) << endl;
delete errorHPtr;
return false;
}
catch (const DOMException& e)
{
const unsigned int maxChars = 2047;
XMLCh errText[maxChars + 1];
cerr << "\nDOM Error during parsing: '" << fileName << "'\n"
<< "DOMException code is: " << e.code << endl;
if (DOMImplementation::loadDOMExceptionMsg(e.code, errText, maxChars))
cerr << "Message is: " << TempCString(errText) << endl;
delete errorHPtr;
return false;
}
catch (...)
{
cerr << "An error occurred during parsing\n " << endl;
delete errorHPtr;
return false;
}
if (errorHPtr->getSawErrors())
{
// Clean up the error handler. The parser does not adopt handlers
// since they could be many objects or one object installed for multiple
// handlers.
delete errorHPtr;
return false;
}
else
{
//...clean up the error handler. The parser does not adopt handlers
// since they could be many objects or one object installed for multiple
// handlers.
delete errorHPtr;
// Since parsing was sucessful, intialize the document pointer, i.e.:
// extract the DOM tree, get the list of all the elements.
documentPtr = parserPtr->getDocument();
return true;
}
}