Fleur: an XQuery implementation in Javascript

Fleur is an XQuery 3.1+XQuery Update Facility 3.0 implementation. It is written in vanilla Javascript allowing it to run, both, in browsers and with NodeJS.

Fleur includes its own DOM3 engine. It can also use browsers DOM for manipulating HTML pages, when used in "XQuery-in-the-browser" mode.

Fleur, primarily, was intended just to replace XSLTForms XPath 1.0 engine for XForms 2.0 support. It will do much more for XForms: no need for XForms 2.0 specific functions to construct nodes and XQuery Update Facility as a replacement for XForms actions XML notation.

Using the native HTTP server provided by NodeJS, Fleur can be used to fully develop small XForms-REST-XQuery (XRX) applications.

Fleur compiles XQuery expressions into a Javascript array of arrays. This Javascript array is an exact representation of the corresponding XQueryX notation. Compiling expressions is interesting when an expression is to be evaluated repeatedly (which is the case, for example, with XForms).

Fleur always evaluates expressions asynchronously (Javascript Promises) because it is a requirement for calls to functions such as doc() which can be located deeply within the XQueryX tree. It is also necessary not to use the single execution thread for too long time: periodically, Fleur allows other treatments to get access to the thread. At client side, a browser will not freeze and concurrent evaluations will terminate independently. At server side, the native HTTP server, for example, will start to treat another request when the current one is too time consuming.

It is possible to call any Javascript function in expressions prefixing with "js:".

Internally, Fleur is, by design, always manipulating nodes. Extra node types are defined: MAP and ENTRY, ARRAY, SEQUENCE, FUNCTION. Atomic values are stored in TEXT nodes with schemaTypeInfo associated.

Fleur can be launched from command line with usual parameters using the node program.

C:\Users\Alain Couthures>node fleur --help
Usage: node fleur ([-s:xmlfile] [-o:outfile] (-q:queryfile|-qs:querystring)
                   [params]|[-p:port] [-f:folder])
 -s:     XML input file (optional)
 -o:     output file (optional)
 -q:     query file
 -qs:    query string
 -p:     http server port
 -f:     http server folder
 params  name=value as externals