Validating document in Xerces C++

谁说我不能喝 提交于 2019-11-28 12:21:41

问题


I want to load an XML document in Xerces-C++ (version 2.8, under Linux), and validate it using a DTD schema not referenced from the document. I tried the following:

XercesDOMParser parser;
parser.loadGrammar("grammar.dtd", Grammar::DTDGrammarType);
parser.setValidationScheme(XercesDOMParser::Val_Always);
parser.parse("xmlfile.xml");

But it doesn't indicate an error if the document is not valid. What am I missing?


回答1:


You'll need to set an error handler before calling parse if you want to see anything:

Handler handler;    
parser.setErrorHandler( &handler );

where Handler is a class derived from ErrorHandler



来源:https://stackoverflow.com/questions/2455071/validating-document-in-xerces-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!