Changes

Jump to navigation Jump to search
No change in size ,  17:11, 18 February 2015
===Annotations===
The serialization can also be parameterized via <code>%output</code> annotations. The following example serializes XML nodes as JSON, using the [[JSON Module|JsonML]] format: <pre class="brush:xquery">declare %rest:path("cities") %output:method("json") %output:json("format=jsonml") function page:cities(){ element cities { db:open('factbook')//city/name }};</pre> The next function, when called, generates XHTML headers, and {{Code|text/html}} will be set as content type:
<pre class="brush:xquery">
<body>done</body>
</html>
};
</pre>
 
The next example serializes XML nodes as JSON, using the [[JSON Module|JsonML]] format:
 
<pre class="brush:xquery">
declare
%rest:path("cities")
%output:method("json")
%output:json("format=jsonml")
function page:cities()
{
element cities {
db:open('factbook')//city/name
}
};
</pre>
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu