Created
February 18, 2015 12:09
-
-
Save zopyx/a0219e145d86dc154e5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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