On Thu, Aug 17, 2023 at 02:07:52AM +0200, Imsieke, Gerrit, le-tex scripsit: > Hi Graydon,
Hi Gerrit -- > Replying to the list for posterity. I hope you don’t mind. Not in the slightest. > When you dynamically evaluate an expression (xquery:eval(), > job:eval(), …), you start with the default values of the static > context [1]. Nothing of the XQuery module from which you evaluate the > expression is known (unless supplied by binding, but ordinary function > declarations are not amenable to binding), therefore no risk of > circularity. That makes sense; xquery:eval() has only the supplied static context. > As stated in the table in [1], you can use module import [2] to > augment this clean slate. In particular the module’s function > declarations/signatures will be available then. If you don’t want the > dynamically evaluated expression to import the whole module, you can > store functions into variables and supply these variables to the > evaluation through bindings. Haven’t tried it yet. The thing that has me croggled is that the dynamically evaluated expression is in the module being imported, where it is bound to a public variable in the module namespace. https://www.w3.org/TR/xquery-31/#id-module-import does say that public variable declaration are included in what's imported. I'm pleased that it works, but I wouldn't claim I understand how it works. My (somewhat reduced) library module starts off as: module namespace xc = "http://example.com/stuff"; (: load the list of parameters:) declare variable $xc:paramsFile external; declare variable $xc:params as map(*) := file:read-text($xc:paramsFile) => xquery:eval(); followed by various functions, and the parameters start off: import module namespace xc="http://example.com/stuff" at "library.xqm"; map { (: many parameters :) } While I think I get that the xquery:eval() only has the static context provided to it, and by default has nothing, why the xquery:eval() doesn't try to evaluate the variable again when the library module is provided as context isn't at all clear to me. I suppose there has to be something in the import process that avoids infinite loops. Thanks! Graydon -- Graydon Saunders | graydon...@fastmail.com Þæs oferéode, ðisses swá mæg. -- Deor ("That passed, so may this.")