Re: Problems with missing properties accessExternalSchema accessExternalDTD in Xerces2

Stanimir Stamenkov <[email protected]> Tue, 16 Jan 2024 19:05:35 +0200
Newsgroups gmane.text.xml.xerces-j.user
Message-ID <[email protected]>
Tue, 16 Jan 2024, /Stanimir Stamenkov/:

>      EntityResolver
>              noExternalEntitiesResolver = (publicId, systemId) -> {
>          return new InputSource(new StringReader(""));
>      };
>      xmlReader.setEntityResolver(noExternalEntitiesResolver);
>
> [...]
> 
>      saxParser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
> 
> The latter configuration prohibits any external entities and will fail 
> the parse operation if an external reference is found...
> 
> The former example substitutes all external entities with empty content...

Essentially, configuring "accessExternalDTD" with an empty value is a 
convenience for setting up an entity resolver with the following example 
implementation:

     EntityResolver
             noExternalEntitiesResolver = (publicId, systemId) -> {
         throw new SAXException("External entity not allowed: " + systemId);
     };

-- 
Stanimir