From: Hungerburg <pc...@my...> - 2013-01-25 14:04:28
|
Am 2013-01-25 13:35, schrieb mountainbiker: > I am having difficulties with the MVC Framework to accept > my goal. In pseudo-code, this is my goal: > > (1) restful query > (2) post-formatting of the query results of (1) > (3) use the JSON serialization to convert (2) to JSON and display the > results in the browser > (4) write the JSON data out to a file using file:serialize-binary with > util:string-to-binary You can get (3,4) by forwarding to a script somewhere that does just that. If you dont want to do that, create a literal xquery in your controller: let $toJSONdoc := 'xquery version "1.0"; let $ret := util:declare-option("exist:serialize", "method=json media-type=text/javascript") return <json>{request:get-data()}</json> ' and then in your view use it as the source for the xquery servlet, eg. after xslt: <view> <forward servlet="XQueryServlet"> <set-attribute name="xquery.source" value="{$toJSONdoc}"/> </forward> </view> That way you get the core json serializer (3). Should work the same with (4). PS: In case of errors, the line numbers of the parser are then off by the number of lines in the multi-line declaration. -- peter |