You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by "Shtilkind, Igor" <SH...@northropgrumman.com> on 2003/01/24 21:32:00 UTC
EntityResolver question
Hi All,
I need some help. I am using Xerces-c ver 2.1.0 stable release. My
EntityResolver doesn't work. Even in Redirect example it does not stop at
resolveEntity method. Any ideas?
Thanks,
Igor
P.S.
snippets of code:
////////////////////////////////////////////////////////////////////////////
/////////////////////////
class DOMValidatorErrorHandler : public DOMErrorHandler,
public DOMEntityResolver
////////////////////////////////////////////////////////////////////////////
/////////////////////////
// Instantiate the DOM parser.
static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull };
DOMImplementation *impl =
DOMImplementationRegistry::getDOMImplementation(gLS);
DOMBuilder *parser =
((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYN
CHRONOUS, 0);
bool doNamespace = true;
bool doSchema = true;
bool doSchemaFullChecking = true;
AbstractDOMParser::ValSchemes schema = AbstractDOMParser::Val_Always;
if( m_szValidation.IsEmpty() ) {
doNamespace = false;
doSchemaFullChecking = false;
schema = AbstractDOMParser::Val_Auto;
}
parser->setFeature(XMLUni::fgDOMNamespaces, doNamespace);
parser->setFeature(XMLUni::fgXercesSchema, doSchema);
parser->setFeature(XMLUni::fgXercesSchemaFullChecking,
doSchemaFullChecking);
DOMValidatorErrorHandler errHandler;
errHandler.SetSchema(m_szValidation);
parser->setErrorHandler(&errHandler);
parser->setEntityResolver(&errHandler);
BOOL sawErrors = TRUE;
errHandler.resetErrors();
try {
// reset document pool
parser->resetDocumentPool();
DOMDocument* doc = parser->parseURI((LPCTSTR)m_szSrc);
// don't delete doc. It will be deleted by parsers destructor.
//delete doc; doc = NULL;
sawErrors = errHandler.getSawErrors();
if( !sawErrors)
bRes = TRUE;
}