Hello,

I face a problem with RESTXQ of a fairly general character, as it seems to me.

When the XQuery functions of a RESTXQ application construct HTML pages, I expect these pages to behave exactly as a static page with the same content would behave. But sometimes this is not the case.

As an attachment I send an example. The "webapp" folder contains an XQuery module with a RESTXQ function [2], and the "html" folder contains an HTML page [3] which is identical to the page generated by the RESTXQ function [4]. This page has been copied from [1], and it demonstrates auto completion in an input field.

However, auto completion works only when calling the HTML file; it does not work when calling the RESTXQ application.

In both cases, the HTML page references a JS file as well as a CSS file, located in a sibling folder "static". An alert box as well as the appearance of the page prove that JS and CSS are found and used in both cases. And yet the behaviour is different ...

~~~

This problem appears to me important, as the trust in RESTXQ would be damaged if the generated HTML "may or may not" behave as it should. On the other hand, if the reason of the problem is understood and a workaround is available, all would be well.

Kind regards,
Hans-Jürgen



[1] https://www.w3schools.com/howto/howto_js_autocomplete.asp

[2] $demo-autocomplete/webapp/autocomplete/demo-autocomplete.xq

[3] $demo-autocomplete/html/demo-autocomplete.html

[4] The contents of the HTML file have been created by (1) entering into a browser the URL of the RESTXQ application (localhost:8984/demo-autocomplete), (2) selecting from the context menu "Show source code", (3) copying the source code into the empty HTML file, (4) replacing <script .../> with <script...></script>.

[5] How to reproduce the problem:
a. Unzip the archive
b. Call $demo-autocomplete/html/demo-autocomplete.html - after acknowledging the alert box which shows that the imported JS function has been called, enter into the input field letter "a" - a list of completions appears.
c. Install the RESTXQ application: copy folder $demo-autocomplete/webapp/autocomplete into the webapp folder of a BaseX instance, and copy the files $demo-autocomplete/webapp/static/* into $BASEX/webapp/static.
d. Enter in a browser "localhost:8984/demo-autocomplete" - after acknowledging the alert box, enter into the input field letter "a" - no list of completions appears.