(apologies if I don’t respond to the list in the proper format…)
This worked like a charm. I made a new “DotNetModuleURIResolver2” class, so I can specify the IQueryResolver.
The only difference between your solution and my final one is that I had to use
myProcessor.Implementation.setConfigurationProperty(net.sf.saxon.lib.FeatureKeys.MODULE_URI_RESOLVER, new DotNetModuleURIResolver2(myQueryResolver));
… since the Processor.SetProperty() method only accepts strings.
I think this can be achieved, but it's not straightforward.
If you get hold of the source code, you'll find that in the .NET code there's a file XQuery.cs which includes an internal class called DotNetModuleURIResolver. This class wraps an IQueryResolver (as used in the .NET API) to a ModuleURIResolver (as used in the Java API). Make a copy of this class and wrap your IQueryResolver in an instance of this class. Then set the ModuleURIResolver in the Saxon configuration by calling Processor.SetProperty(name, value) where name is "http://saxon.sf.net/feature/moduleURIResolver" and value is the instance of the wrapper class.
Let us know how you get on.
On 06/06/2012 22:01, scott dallamura wrote:
I’m using Saxon 9.4 (PE) on .NET. I have an XSLT that needs to run an arbitrary XQuery (supplied as part of the input to the XSLT transformation). I’m using the saxon:compile-query and saxon:query functions to compile and run the XQuery. Everything was working fine until I had a need to factor out some common functionality into an XQuery module. Because the XQuery is dynamically supplied as the content of an XML element, the running application doesn’t know anything about “where” the XSLT or XQuery files are stored, and the XSLT files are agnostic about location as well, and I’d like to keep it this way.
In other words, my files are stored like
where “root” is determined by the deployment location, and is not necessarily a file path – it could be using a virtual file system, where the “files” are stored as blobs in a database. My XQuery prolog looks something like
declare base-uri “../”;
import module namespace my-lib = “urn:my-library-module” at “xquery/my-library-module.xq”;
I have a small test harness to test out the XQuery that uses an IQueryResolver, and this works fine. The problem arises when I try to run the XQuery from my XSLT file – I don’t see any way to supply the IQueryResolver to the XsltCompiler, XsltExecutable or XsltTransformer. When saxon:compile-query runs, I get an error stating that my library can’t be found, with (as expected) a path relative to my application’s executable. I’ve considered implementing a new extension function, but I’d rather use the built-in stuff if I can.
So, my question is: how do I specify an IQueryResolver implementation to be used by saxon:compile-query?
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
saxon-help mailing list archived at http://saxon.markmail.org/