Project

Profile

Help

Bug #2111

closed

setConfigurationProperty prevents propagation of ModuleURIResolver

Added by Michael Kay almost 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XQuery Java API
Sprint/Milestone:
Start date:
2014-07-23
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.5, 9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

Description

Reported by Gunther Rademacher on saxon-help list.

When the XQUERY_VERSION configuration property is set before installing a

module URI resolver in the configuration, that URI resolver is not propagated

to XQueryCompiler instances based on that configuration.

This may not be the intended behaviour. Or is it?

Some sample code is shown below. It will complain about the module missing,

but can be fixed by omitting setConfigurationProperty, or by explicitly setting

the module URI resolver in the XQueryCompiler (e.g. by getting from the

configuration).

Best regards,

Gunther

public class ImportModule {

  public static void main(String[] args) throws Exception {

    final Configuration configuration = new Configuration();


    configuration.setConfigurationProperty(FeatureKeys.XQUERY_VERSION, "1.0");


    configuration.setModuleURIResolver(new ModuleURIResolver() {

      @Override

      public StreamSource[] resolve(String moduleURI, String baseURI, String[] locations) throws XPathException {

        StringReader reader = new StringReader("module namespace x='x'; declare variable $x:x := 'x';");

        StreamSource module = new StreamSource(reader);

        module.setSystemId(moduleURI);

        return new StreamSource[] {module};

      }

    });


    Processor processor = new Processor(configuration);

    XQueryCompiler xqueryCompiler = processor.newXQueryCompiler();

    xqueryCompiler.setBaseURI(new File(".").toURI());


    XQueryExecutable executable = xqueryCompiler.compile("import module namespace x='x'; $x:x\n");

    executable.load().run(new Serializer(System.out));

  }

}

Related issues

Related to Saxon - Bug #2392: java.lang.RuntimeException: Cannot instantiate a ConfigurationClosedO'Neil Delpratt2015-06-06

Actions

Please register to edit this issue

Also available in: Atom PDF