Changes

Jump to navigation Jump to search
921 bytes added ,  19:38, 1 July 2013
By default, all results will be returned with content type {{Code|application/xml}}.
Similar to our the [[REST#Content Type|REST]] interface, result serialization can be modified via [[XQuery 3.0#Serialization|XQuery 3.0 serialization parameters]]. In RESTXQ, all serialization parameters are may be specified in the query prolog, via annotations using the {{Code|output}} prefix, or within annotations.the query:
The ===Query Prolog=== In main modules, serialization parameters may be specified in the query prolog. These parameters will then apply to all functions in a module. In the following example, the content type can be of the response is overwritten with the {{Code|media-type}} annotationparameter: <pre class="brush:xquery">declare option output:media-type 'text/plain'; declare %rest:path("") function page:version1() { 'Keep it simple, stupid'};</pre> ===Annotations=== The serialization can also be parameterized via annotations:
<pre class="brush:xquery">
declare %output:media-type("text/plain") %rest:path("")
function page:kissversion2() { 'keep it Still somewhat simple, stupid.' };
</pre>
Next===Query=== The following example demonstrates how serialization parameters can be dynamically set within a query: <pre class="brush:xquery">declare %rest:path("") function page:version3() { <rest:response> <output:serialization-parameters> <output:method value='xml'/> </output:serialization-parameters> </rest:response>, the 'Well, not that simple anymore'};</pre>  The content type can also be overwritten by specifying an output {{Code|method}}. The following method mappings are available:
* <code>xml</code> → <code>application/xml</code>
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu