Is there any way to make json module (mainly json:serialize) handle namespaces? I tried following:

 

let $str := '{"name":"Mike Mac","address":{"postnumber":20221,"city":"NYC","street":"23 west A 22"},"email":"mm@gmail.com"}'

let $json := json:parse($str)

return json:serialize($json)

 

and I get the string, with linefeed etc.

 

But I would like to add the $json element inside another element,  which have default namespace.

 

let $str := '{"name":"Mike Mac","address":{"postnumber":20221,"city":"NYC","street":"23 west A 22"},"email":"mm@gmail.com"}'

let $json := json:parse($str)

let $wrapper := copy $x := <wrapper xmlns="namespace-uri"/>

    modify (insert node $json into $x)

   return $x

let $json2 := $wrapper/*[1]

return json:serialize($json2)

 

(That is, insert the $json inside the <wrapper> -element, get it out and serialize it.)

 

Instead of the same result as in the first case, I get ‘BXJS0001 JSON serialization: Element <json> has invalid attribute “xmlns”. ‘

 

But since it is default namespace, there is no easy way to drop it.

 

My  question is: is there any way to let json:serialize handle or ignore namespaces; at least default namespaces?

 

--

Arto Viitanen

Microteam Oy

Tampere, Finland