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;
    }
Actions #1

Updated by Michael Kay almost 2 years ago

  • Category set to Internals
  • Status changed from New to In Progress
  • Assignee set to Michael Kay
  • Applies to branch 11, trunk added
  • Fix Committed on Branch 11, trunk added
  • Platforms Java added

I've implemented the suggestion of changing ChainedEntityResolver so it can fall back to using the plain EntityResolver interface.

I'm less comfortable with changing the order of resolvers. This seems to be related to bug #5582 and I think it needs more careful consideration of use cases.

Actions #2

Updated by Radu Coravu over 1 year ago

Thanks, I understand.

Actions #3

Updated by Norm Tovey-Walsh 6 months ago

  • Status changed from In Progress to Won't fix

Changing the order of the resolvers is likely to be much too disruptive.

Please register to edit this issue

Also available in: Atom PDF