RestXQ

In 2012, Adam Retter presented a use of annotations to define a web interface [RESTXQ]. It is based on the Java standard RESTful Web Services [JAX-RS]. RESTXQ has since been implemented by many XQuery products as it provides a straightforward way to wire-up XQuery code to a web interface.

A simple RESTXQ example:

declare 
%rest:path("hello/{$who}") 
%rest:GET 
function page:hello($who) {
  <response>
    <title>Hello { $who }!</title>
  </response>
};  

Here the %rest:path annotation specifies a URL and the %rest:GET specifies an HTTP method. In a suitable Web server environment, a request for "/hello/fred" will be wired up to invoke the page:hello function with the argument "fred". The result of the function will be returned by web server.