You can import the library module in the evaluated expression. Example: 
https://github.com/transpect/control-backend/blob/main/webapp/control-backend.xqm#L60

Gerrit


Sent from MailDroid

-----Original Message-----
From: Graydon Saunders <graydon...@gmail.com>
To: BaseX <BaseX-Talk@mailman.uni-konstanz.de>
Sent: Wed, 16 Aug 2023 4:42
Subject: [basex-talk] mapping functions

Hello --

I have various databases that will be run through the same code after their
contents is regularized.  So the only different function is the one used
for regularization.

This can be handled by writing a wrapper function and passing in a label to
say which function to use, but I was wondering if there's a way to do it in
the configuration map directly.  The configuration map exists as a text
file and gets run through xquery:eval() at the start of the process.

declare namespace abc='http://some/uri';
'regularizationFunction': map {
     'typeOne': abc:regularizationOne#1,
     'typeTwo': abc:regularizationTwo#1
}

doesn't work, because the abc functions aren't known at evaluation time.
These functions are defined in the library module that's evaluating the
configuration file but xquery:eval() doesn't know that.  I don't see a way
to use bindings to get around this.

Is there a way to map a locally-defined function reference so xquery:eval()
will recognize it?

thanks!
Graydon

-- 
Graydon Saunders  | graydon...@fastmail.com
Þæs oferéode, ðisses swá mæg.
-- Deor  ("That passed, so may this.")

Reply via email to