0
votes

I'm trying to confirm that my implementation for registering Custom Resolvers is correct... I want the resolver to throw an "Unauthorized" error when a corresponding saxon xquery function is called.

First, I write a custom class along those lines:

class CustomURIResolver implements URIResolver{
            public Source resolve(String href, String base) throws XPathException {
                throw new XPathException("Illegal Operation");
            }]
        }

and then I set the resolver via the underlying config on the processor:

Processor proc = new Processor(false);
// Override SystemURIResolver
net.sf.saxon.Configuration xconfig = proc.getUnderlyingConfiguration();
xconfig.setURIResolver(new CustomURIResolver());

Is this reasonable or am I missing something?

1

1 Answers

0
votes

You should set the URIResolver on the XQueryEvaluator, not on the Configuration.

Also, it depends on what the "corresponding saxon xquery function" is. The URIResolver is used for the doc() function, for example, but not for unparsed-text().