Skip to content

Instantly share code, notes, and snippets.

@zopyx
Created July 3, 2014 19:37
Show Gist options
  • Save zopyx/a71468be48ae70e21f26 to your computer and use it in GitHub Desktop.
Save zopyx/a71468be48ae70e21f26 to your computer and use it in GitHub Desktop.
xquery version "3.0";
module namespace services = "http://my/services";
import module namespace transform = "http://exist-db.org/xquery/transform";
declare namespace rest = "http://exquery.org/ns/restxq";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare
%rest:GET
%rest:path("/data.html")
%output:media-type("text/html")
%output:method("html5")
function services:home() {
transform:transform(services:example1(), doc("/db/my-xml-to-html.xslt"), ())
};
declare
%rest:GET
%rest:path("/data.json")
%rest:produces("application/json")
%output:method("json")
function services:home-json() {
services:example1()
};
declare
%rest:GET
%rest:path("/data.xml")
%rest:produces("application/xml")
function services:home-xml() {
services:example1()
};
declare
%private
function services:example1() {
<some>
<data>hello world</data>
</some>
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment