Thank you David for your suggestions! On 02-Jan-2016 11:55 pm, "David Lee" <[email protected]> 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 > [email protected] > > > On Jan 2, 2016, at 1:15 PM, Indrajeet Verma <[email protected]> > 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 > [email protected] > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > > > _______________________________________________ > General mailing list > [email protected] > Manage your subscription at: > http://developer.marklogic.com/mailman/listinfo/general > >
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
