Project

Profile

Help

Bug #5605

closed

Prefer to prioritize the XML reader's entity resolver

Added by Radu Coravu almost 2 years ago. Updated 6 months ago.

Status:
Won't fix
Priority:
Low
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2022-07-14
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
11, trunk
Fix Committed on Branch:
11, trunk
Fixed in Maintenance Release:
Platforms:
Java

Description

In the net.sf.saxon.Configuration class in the two places where the ChainedResourceResolver is created, it should add the xml reader's entity resolver as the first resolver in the chain, otherwise the other resolver has the habit of returning a source even if it cannot resolve the reference and the xml reader's entity resolver would never get called. In the class ChainedEntityResolver on the net.sf.saxon.lib.ChainedEntityResolver.resolveEntity(String, String, String, String) method if the "first" and "second" are not EntityResolver2, but plain EntityResolver you could fallback to the EntityResolver API like:

    public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException {
        InputSource is = null;
        if (first instanceof EntityResolver2) {
            is = ((EntityResolver2) first).resolveEntity(name, publicId, baseURI, systemId);
        } else {
        	is = first.resolveEntity(publicId, systemId);
        }
        if (is == null) {
        	if(second instanceof EntityResolver2) {
            is = ((EntityResolver2) second).resolveEntity(name, publicId, baseURI, systemId);
          } else {
            is = second.resolveEntity(publicId, systemId);
          }
        }
        return is;
    }

Please register to edit this issue

Also available in: Atom PDF