[MarkLogic Dev General] json:transform-to-json() with custom configuration is suppressing some content in XML to JSON transformation

Indrajeet Verma indrajeet.verma at gmail.com
Sat Jan 2 10:29:35 PST 2016


Thank you David for your suggestions!
On 02-Jan-2016 11:55 pm, "David Lee" <David.Lee at marklogic.com> wrote:

> The custom strategy will not work on arbitrary content.
> The 'full' strategy will.
>
> https://docs.marklogic.com/json:config
>
> At the expense of much more verbose and 'ugly' Markup.
>
> You can specify a set of names in the custom strategy to format as full
> See:
>
> full-element-names
>
> A list of XML element names which will be treated as an full expansion in
> JSON similar to the full strategy. These can be xs:QName or xs:string. If
> an xs:string is used then the default namespace is used to construct the
> QName.
>
>
>
>
> Another approach is to preprocessing the XML into a form that that
> Eliminates mixed text and repeated element children
>
> Similarly the resultant. JSON, if it is full fidelity , can be post
> processed
> To your final desired form
>
>
>
>
> Sent from my iPad
> David A Lee
> dlee at marklogic.com
>
>
> On Jan 2, 2016, at 1:15 PM, Indrajeet Verma <indrajeet.verma at gmail.com>
> wrote:
>
> Hi,
>
> I am using json:transform-to-json() function to convert XML node to json
> however for a nested xml node and with custom configuration, this function
> is suppressing some content.
>
> Could you please suggest where I am doing mistake or this is not the right
> conversion (json is not fit for mixed content )?
>
> import module namespace json = "http://marklogic.com/xdmp/json"
>     at "/MarkLogic/json/json.xqy";
>
> let $node := <p>This is my test data <i>this should be italic</i> sample
> content</p>
> let $custom :=
>     let $config := json:config("custom")
>     let $_ := map:put( $config, "whitespace", "ignore" )
>     return $config
>   return
>     json:transform-to-json( $node, $custom )
>
>
> Result-
>
> {
> "p":
> {
> "i": "this should be italic",
> "_value": " sample content"
> }
> }
>
>
> import module namespace json = "http://marklogic.com/xdmp/json"
>     at "/MarkLogic/json/json.xqy";
>
> let $node := <p>This is my test data <i>this should be italic</i> sample
> content</p>
> return
>     json:transform-to-json( $node, json:config("full") )
>
> Result-
>
> {
> "p":
> {
> "_children":
> [
> "This is my test data ",
> {
> "i":
> {
> "_children":
> [
> "this should be italic"
> ]
> }
> }
> ,
> " sample content"
> ]
> }
> }
>
> Regards,
> Indrajeet
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20160102/72e888d5/attachment.html 


More information about the General mailing list