1

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 Answers1

2

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.

chrisis
  • 1,983
  • 5
  • 20
  • 17
  • Would this a configuration more of tomcat, or the web app itself? – Nicholas Saunders Jun 20 '20 at 23:50
  • 1
    You didn't mention that you were running BaseX as a servlet or tag the question with Tomcat so I gave the configuration options as they would be set in the standalone application. – chrisis Jun 21 '20 at 04:39
  • ohhhhh. I don't know the options. If can just run Basex **as** a servlet that's probably my intention -- I'll have to look into that. The vagueness of the question is due to my lack of clarity on the capabilities of BaseX itself, and of how it interacts with a servlet container such as tomcat, or app servers. I'll try and ask a more focused question. – Nicholas Saunders Jun 21 '20 at 08:14
  • 1
    The basexhttp script that comes with the full BaseX download runs the http server using an embedded copy of the Jetty application server. You might find that the easier option if you don't have a specific requirement for Tomcat. – chrisis Jun 21 '20 at 09:08
  • looking at https://stackoverflow.com/q/42932689/4531180 I think that's the direction I'll go here -- but where is the `web.xml` located? I suppose that depends on version, OS, install method? Getting a bit off track, pardon. – Nicholas Saunders Jun 21 '20 at 11:09