Saxon.Api

 

 

Saxon.Api

Delegate XQueryResolver


public delegate TextResource[] XQueryResolver(string moduleUri, Uri baseUri, Uri[] locationHints)

Given a module URI and a set of location hints, return a set of query modules.

Parameters:

moduleUri - The URI of the required library module as written in the import module declaration. Although use of a URI is recommended, the specifications do not require it to be a valid URI, so it is passed as a string.
baseUri - The base URI of the module containing the import module declaration. This will be null if no base URI for the containing module is known.
locationHints - The sequence of URIs (if any) listed as location hints in the import module declaration in the query prolog. These are supplied as written in the query; an error will typically be reported (before calling the XQueryResolver if any of the location hints is not a valid absolute or relative URI.

Returns:

A set of XQueryModuleSource objects identifying the query modules to be loaded. There is no requirement that these correspond one-to-one with the URIs defined in the locationHints. If the result is an empty array, no query module is imported, which may or may not cause a compilation error in the importing module. If the result is null, Saxon attempts to resolve the import module declaration using its default rules, as if no XQueryResolver had been supplied.

Example:

xqueryCompiler.XQueryResolver = (moduleUri, baseUri, locations) => { if (moduleUri == "test.xq") { const string q = "module namespace t='test.xq'; declare variable $t:x := 'x';"; return new [] {new TextResource() {Content = q}}; } return null; };