Hi Christian --

Thank you!

I have been finding that passing in a single XML config file and using xquery:eval() on the XPath-syntax maps therein has been working.

(Locally, we use Python for scripting, so I am going to save the pattern but keep the config files for now. :)

Much appreciated!

-- Graydon

On Wed, Sep 22, 2021 at 4:52 AM Christian Grün <christian.gruen@gmail.com> wrote:
Hi Graydon,

I guess this question didn’t get any response so far:

> How does one go about binding a literal map to an external variable?  (I am going to want to do this in a script later; the GUI version is strictly for testing.)

External variable bindings via the GUI are limited to atomic items. If
you use Java for scripting, you could proceed as follows:

import org.basex.core.*;
import org.basex.query.*;
import org.basex.query.value.*;

public class BindMap {
  public static void main(String... whatever) throws Exception {
    Context ctx = new Context();
    String input = "map { 'structure': '/some/path/name' }";
    Value map = new QueryProcessor(input, ctx).value();

    String query = "declare variable $map external; $map";
    QueryProcessor qp = new QueryProcessor(query, ctx);
    System.out.println(qp.bind("map", map).value());
  }
}

Hope this helps,
Christian