Hi Christian, Thanx for the quick response. I get it. In my case I want the result of the first snippet but then in a xquery-module. I can't use the: "declare option ....." in a module. Can you give me a suggestion how to realize this? Thanx in advance, Rob -----Oorspronkelijk bericht----- Van: Christian Grün [mailto:christian.gruen@gmail.com] Verzonden: donderdag 27 november 2014 11:53 Aan: Rob Stapper CC: BaseX Onderwerp: Re: [basex-talk] unexpected behaviour Hi Rob the behavior is correct:
declare option output:method 'json'; serialize( <a>test</a> )
The result is: "<a>test</a>" …as specified in [1].
serialize( <a>test</a> , map{ 'method' : 'json'} )
The result is: "<a>test</a>" The node will first be serialized to a string, and the query result (i.e., this string) will be serialized according to the XML serialization rules. You can switch to plain text serialization as follows: declare option output:method 'text'; serialize( <a>test</a>, map{ 'method' : 'json'} )
declare option output:method 'json'; serialize( <a>test</a> , map{ 'method' : 'json'} )
The result is: "\"<a>test</a>\"" The node will first be serialized to a string, and the query result (i.e., this string) will be serialized according to the JSON serialization rules. In a JSON string, quotes will be backslashed. Cheers, Christian [1] http://www.w3.org/TR/xslt-xquery-serialization-31/#JSON_JSON-NODE-OUTPUT-MET... --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. http://www.avast.com