passing complex parameters to modules
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. Otherwise, it seems like the thing to do is to have each query load a parameter map, but then I have to include that map as a parameter in all the functions calls in the function module, which feels inelegant. And I definitely don't want to start introducing a haze of individual values. Is there a better way to do this? It seems like I'm missing something. Thanks! Graydon -- Graydon Saunders | graydonish@fastmail.com Þæs oferéode, ðisses swá mæg. -- Deor ("That passed, so may this.")
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}var1=test' .\main-module1.xq test
On Sun, Aug 13, 2023 at 12:12:43PM +0200, Martin Honnen scripsit:
On 13.08.2023 04:15, Graydon Saunders wrote: [snip]
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:
And so it can. (At least if I go for the minimal example.) Thank you, Martin; hopefully I can figure out why I was getting error messages in the full example. -- Graydon -- Graydon Saunders | graydonish@fastmail.com Þæs oferéode, ðisses swá mæg. -- Deor ("That passed, so may this.")
participants (3)
-
Graydon -
Graydon Saunders -
Martin Honnen