Project

Profile

Help

Bug #5970

closed

DirectResourceResolver - unresolved XML classpath resources

Added by Steven Dürrenmatt about 1 year ago. Updated almost 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Resolvers
Sprint/Milestone:
-
Start date:
2023-04-10
Due date:
% Done:

100%

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

Description

Seems identical to https://saxonica.plan.io/issues/5271 but for XML resources.

From Saxon 11, when trying to load an XML document from the classpath, java.net.MalformedURLException: unknown protocol: classpath exception can be thrown.

StringWriter sw = new StringWriter();
Configuration config = new Configuration();
XQueryExpression expression = config.newStaticQueryContext().compileQuery("doc('classpath:books.xml')");
expression.run(new DynamicQueryContext(config), new StreamResult(sw), new Properties());
System.out.println(sw);

In this example the resource is lastly resolved by the DirectResourceResolver, which relies on ResourceLoader.

For XSLT resources we have the following patch (could it be applied to all natures of resources?)

if (request.uri.startsWith("classpath:")) {
    String s = request.uri.substring(10);
    if (s.startsWith("/")) {
        s = s.substring(1);
    }
    stream = config.getDynamicLoader().getResourceAsStream(s);
}

Please register to edit this issue

Also available in: Atom PDF