How to configure a "hello world" HTML page using BaseX with RestXQ?

457 Views Asked by At

More of a usage question than a programming question, in relation to:

BaseX RESTXQ "hello world" example

How do I use RESTXQ with BaseX for a simple web app?

basex/rest - blog complete app

Is there a way to make BaseX serve an HTML document?

Certainly, it's easy enough to fork the blog app. However, it's also eight years old.

The sample from the documentation is:

module namespace page = 'http://basex.org/examples/web-page';
declare %rest:path("hello/{$who}") %rest:GET function page:hello($who) {
  <response>
    <title>Hello { $who }!</title>
  </response>
};

where is this saved to, precisely? Is it added to a database within BaseX itself or does this exist outside as a file?

1

There are 1 best solutions below

5
On BEST ANSWER

Your hello world module should be saved in the web application directory or in a directory specify using the RESTXQPATH configuration option. BaseX scans modules in these locations, and their sub-directories, for rest:path annotations. Where the web application directory is depends on the application server and operating system you are using and on the WEBPATHconfiguration option. You can find more information in the documentation.

If you are running BaseX as a servlet then the configuration options can be set in the web.xml file as context-param entries.RESTXQPATH would be the context-param org.basex.restxqpath. There are examples in the 'Web Application' section of the BaseX documentation.