On 13.08.2023 04:15, Graydon Saunders wrote:
Hello --
I've got a module full of functions. I've got two (and expect more) queries which import the function module. The queries have slightly different requirements; for example, in one case, it's necessary to use normalize-unicode() during a data regularization step, and in the other case it isn't. These differences are generally not at the top level of function that the query itself calls; they're usually a couple levels down in the function module.
It doesn't look like the function module can have its own external variables; if it can, that'd be ideal.
A libary module can certainly have external variables:
PS C:\Users\marti\OneDrive\Documents\XQuery\module-var-test> type .\module1.xqm module namespace module1 = "http://example.com/module1";
declare variable $module1:var1 as xs:string external;
declare function module1:foo() { $module1:var1 }; PS C:\Users\marti\OneDrive\Documents\XQuery\module-var-test> type .\main-module1.xq import module namespace module1 = "http://example.com/module1" at "module1.xqm";
module1:foo() PS C:\Users\marti\OneDrive\Documents\XQuery\module-var-test> & 'C:\Program Files (x86)\BaseX\bin\basex.bat' '-b{http://example.com/module1%7Dvar1=test' .\main-module1.xq test