11/23/2014 - 4:04 AM

A starter template for a RestXQ module

A starter template for a RestXQ module

xquery version "3.0";

module namespace my-app = "http://my/app";

(: A starter template for a RestXQ module.
    Save this file into eXist anywhere (e.g., /db/restxq-template.xqm or /db/apps/my-app/modules/restxq-template.xqm),
    And access at http://localhost:8080/exist/restxq/index.html.
    (Why? Because /restxq is the URL space for RestXQ, and the function's %rest:path annotation is for requests to "/index.html".) 
    Note that the collection configuration file where you store the module must invoke the RestXQ trigger:
        <collection xmlns="">
                <trigger class="org.exist.extensions.exquery.restxq.impl.RestXqTrigger"/>
    But this should already be in place, since /db/system/config/db/collection.xconf will apply to any collection
    unless overridden by another collection.xconf file.

declare namespace rest = "";
declare namespace output = "";

function my-app:hello() {
    let $title := 'Hello world!'
        <html xmlns="">