本文整理汇总了C++中SAX2XMLReader::setEntityResolver方法的典型用法代码示例。如果您正苦于以下问题:C++ SAX2XMLReader::setEntityResolver方法的具体用法?C++ SAX2XMLReader::setEntityResolver怎么用?C++ SAX2XMLReader::setEntityResolver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SAX2XMLReader
的用法示例。
在下文中一共展示了SAX2XMLReader::setEntityResolver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isValid
bool XMLValidator::isValid(const String & filename, const String & schema, std::ostream & os)
{
filename_ = filename;
os_ = &os;
//try to open file
if (!File::exists(filename))
{
throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
}
// initialize parser
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException & toCatch)
{
throw Exception::ParseError(__FILE__, __LINE__, __PRETTY_FUNCTION__, "", String("Error during initialization: ") + Internal::StringManager().convert(toCatch.getMessage()));
}
SAX2XMLReader * parser = XMLReaderFactory::createXMLReader();
parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
parser->setFeature(XMLUni::fgXercesDynamic, false);
parser->setFeature(XMLUni::fgXercesSchema, true);
parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
//set this class as error handler
parser->setErrorHandler(this);
parser->setContentHandler(NULL);
parser->setEntityResolver(NULL);
//load schema
LocalFileInputSource schema_file(Internal::StringManager().convert(schema));
parser->loadGrammar(schema_file, Grammar::SchemaGrammarType, true);
parser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);
// try to parse file
LocalFileInputSource source(Internal::StringManager().convert(filename.c_str()));
try
{
parser->parse(source);
delete(parser);
}
catch (...)
{
/// nothing to do here
}
return valid_;
}