I don't understand entities and why I need to extend class EntityResolver.
 Based on the documentation, it seems like I don't need to go through this
step.  When I read about entities, I see the usual &apos, &amp, &quot, et
al.  I don't have any custom entities.

I have an XML document, call it authNotify.  I use an XSD (authNotify.xsd)
& SAX2 to validate this document.  If I don't call setEntityResolver() in
my code, the parser bombs with a message like the following:

Warning at file , line=0, column=0, An exception occurred!
Type:RuntimeException, Message:Warning: The primary document entity could
not be opened. Id=/tmp/authNotify.xsd


So, based on my understanding of how to set up SAX2, my basic flow is to do
something like so:

        XMLPlatformUtils::Initialize();

        parser = XMLReaderFactory::createXMLReader();
        parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
        parser->setFeature(XMLUni::fgXercesDynamic, true);
        parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
        parser->setFeature(XMLUni::fgXercesValidationErrorAsFatal, false);

        defaultHandler = new AuthNotifyHandler();
        AuthNotifyResolver *authResolver = new AuthNotifyResolver();
        parser->setContentHandler(defaultHandler);
        parser->setErrorHandler(defaultHandler);
        parser->setEntityResolver(authResolver);

Where AuthNotifyHandler is derived from DefaultHandler and
AuthNotifyResolver is derived from EntityResolver.

When resolveEntity() is called, the parameters publicID and systemID are
both set to authNotify.xsd.  In the traditional compareString(), if I
change the comparison to return 0, all heck breaks loose.

I don't know if I'm doing something wrong in the parser set-up, or if
something is wrong elsewhere.

So, lost here.  Any help?

-- 
Kelly Beard

Reply via email to