You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by "Dantzler, DeWayne C" <de...@boeing.com> on 2007/10/30 22:45:25 UTC
How to get the Parser to recognize the setDisableDefaultEntityResolution option
I'm trying to get the Parser to check only for well-formness and ignore
external Entities. I've set the option to disable the default entity
resolver and overridden the resovler to return NULL, but the Parser
still attempts to open the DTD referenced in the document.
Since the DTD is not local, the Parser reports::
Parser Error Message: An exception occurred!
Type:RuntimeException, Message:Could not open DTD file
Code snippet:
/* This method gives users the option to not perform default
entity
* resolution. If the user's resolveEntity method returns
NULL the
* parser will try to resolve the entity on its own. When
this option
* is set to true, the parser will not attempt to resolve
the entity
* when the resolveEntity method returns NULL.
*/
_XmlDOMParser->setDisableDefaultEntityResolution(true);
//turn off the features to allow validation by
Schema/DTD
_XmlDOMParser->setValidationScheme(_XmlDOMParser->Val_Never);//turn off
validation
_XmlDOMParser->setDoSchema(false);//disable the parser's
schema processing.
_XmlDOMParser->setDisableDefaultEntityResolution(true);//disable default
entity resolution
_XmlDOMParser->setSkipDTDValidation(true);
Re: How to get the Parser to recognize the setDisableDefaultEntityResolution
option
Posted by David Bertoni <db...@apache.org>.
Dantzler, DeWayne C wrote:
> I'm trying to get the Parser to check only for well-formness and ignore
> external Entities. I've set the option to disable the default entity
> resolver and overridden the resovler to return NULL, but the Parser
> still attempts to open the DTD referenced in the document.
Returning a null pointer tells the parser the EntityResolver instance did
not try to resolve the entity. Instead, return an InputSource instance
that's empty. An easy way to do that is to return a MemBufInputSource that
has a length of 0.
Dave