XQuery/Getting POST Data
From Wikibooks, the open-content textbooks collection
< XQuery
Contents |
[edit] Motivation
You want to create an XQuery that will access data in the HTTP POST.
[edit] Method
To do this you use the request:get-data() XQuery function.
[edit] Sample echo-post.xq
xquery version "1.0";
(: echo-post.xq: Return all data from an HTTP post to the caller. :)
declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace xmldb="http://exist-db.org/xquery/xmldb";
declare namespace request="http://exist-db.org/xquery/request";
declare option exist:serialize "method=xml media-type=text/xml indent=yes";
let $post-data := request:get-data()
return
<post-data>
{$post-data}
</post-data>
[edit] Discussion
The program above (called echo-post.xq) is a very useful program for testing your web forms. It just takes the data sent to the XQuery service and returns it wrapped in a <post-data> tag.