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 Options - BaseX Documentationhttps://docs.basex.org/wiki/Options#BINDINGS This page is linked from the Getting Started Section.. The options listed on this page influence the way how database commands are executed and XQuery expressions are evaluated. Two kinds of options exist: Global Options are valid for all BaseX instances in the same JVM. This is particularly relevant if you are working with the client/server architecture. docs.basex.org
https://docs.basex.org/wiki/Command-Line_Options Command-Line Options - BaseX Documentationhttps://docs.basex.org/wiki/Command-Line_Options Standalone []. The following options are available for the standalone Command-Line Client: $ basex -h BaseX [Standalone] Usage: basex [-bcdiIoqrRstuvVwxz] [input] [input] XQuery or command file, or query string -b<args> Bind external query variables -c<input> Execute commands from file or string -d Toggle debugging output -i<input> Bind file or database to context -I<input> Bind input string ... docs.basex.org
________________________________ 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-fi...
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
basex-talk@mailman.uni-konstanz.de