Skip to content

Instantly share code, notes, and snippets.

@zopyx
Created February 18, 2015 12:09
Show Gist options
  • Save zopyx/a0219e145d86dc154e5e to your computer and use it in GitHub Desktop.
Save zopyx/a0219e145d86dc154e5e to your computer and use it in GitHub Desktop.
xquery version "3.0";
module namespace services = 'http://basex.org/modules/web-page';
declare namespace request="http://exist-db.org/xquery/request";
declare namespace rest = "http://exquery.org/ns/restxq";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace json="http://www.json.org";
declare
%rest:GET
%rest:path("/all-documents.json")
%rest:produces("application/json")
%output:method("json")
function services:home-json() {
services:func()
};
declare
%rest:GET
%rest:path("/all-documents.xml")
%rest:produces("application/xml")
function services:home-xml() {
services:func()
};
declare
%private
function services:func() {
<items> {
let $data-collection := 'onkopedia'
for $doc in collection($data-collection)[ends-with(base-uri(.), '.xml')]
return
<item>
<uri>{base-uri($doc)}</uri>
</item>
}
</items>
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment