Hi Patrick,
I don't think bxs scripts have something like variables (but I may have missed the point with all the work BaseX team achieves).
Bindings are way to parametrize XQuery scripts, and you can indeed set external variables' value in bxs, or on command line.

Best regards,
Fabrice

Here are a few examples :
https://docs.basex.org/wiki/Options#BINDINGS

https://docs.basex.org/wiki/Command-Line_Options



De: BaseX-Talk de la part de Patrick Durusau
Envoyé: Mercredi 02 mars 2022 01:38
À: basex-talk@mailman.uni-konstanz.de
Objet: [basex-talk] Declaring a variable in bxs that carries over to called xquery scripts

Greetings!

What I thought would be a simple task has turned out to not be so simple.

I wrote:

SET CHOP false
SET EXPORTER indent=no,omit-xml-declaration=no
SET BINDINGS $ndb=Ruth
CREATE DB $ndb ./sources/Ruth.xml

In BaseX 9.6.4, and when testing it I got this result:

CHOP: false
EXPORTER: indent=no,omit-xml-declaration=no
BINDINGS: $ndb=Ruth
Database '$ndb' created in 544.5 ms.

What? Why isn't the mapping of Ruth to the variable $ndb effective in
the bxs file?

Moreover, there are query files that follow in the bxs file that I want
to have resolve $ndb to Ruth (the desired name of the database).

1) How should I declare a variable in a bxs file?

2) In such a way that it carries over to following xquery files?

BTW, I've seen this posting by Christian:
https://stackoverflow.com/questions/28018354/how-to-run-a-xquery-with-xml-file-containing-value-as-one-of-the-bound-variabl


but it doesn't seem to be working for me.

What am I missing?

Thanks!

Patrick
<https://twitter.com/servicenow>--

Patrick Durusau
patrick@durusau.net
Technical Advisory Board, OASIS (TAB)
Editor, OpenDocument Format TC (OASIS), Project Editor ISO/IEC 26300
Co-Editor, ISO/IEC 13250-1, 13250-5 (Topic Maps)

Another Word For It (blog): http://tm.durusau.net
Homepage: http://www.durusau.net
Twitter: patrickDurusau