Hi Pragya,

Above code is perfect working on my ML environment just i have copied paste
your code on query console but i am using ML8, however please try the below
mentioned code.


import module namespace json = "http://marklogic.com/xdmp/json"; at
"/MarkLogic/json/json.xqy";
declare variable $xml :=
'<document
docID="/docs/0000002-0000468-0004456-ISDA-COL-XXXX_2015-04-01_06-33-57-639.xml"
action="add">
<metadata>
<name>XYZ</name>
<value>fsddddddddddddddddddddddddddddddd sdgsdsdsdsdsdsdsdsdsdsd</value>
<type>text</type>
</metadata>
<metadata>
<name>Period</name>
<value>aertw hegheh eheheh ghhehe</value>
<type>text</type>
</metadata>
</document> ' ;

let $document := xdmp:unquote($xml)
let $uri := "123"
let $custom :=
  let $config := json:config("custom")
  let $_ := map:put( $config, "whitespace", "ignore" )
  let $_ := map:put( $config, "array-element-names", "metadata" )
  return $config

let $json :=  json:transform-to-json($document,$custom)

return

  (

     xdmp:save(concat('D:\test\', $uri), $json)

  )

Regards
Dharmendra Kumar Singh

On Tue, Jan 3, 2017 at 3:54 PM, Kapoor, Pragya <[email protected]>
wrote:

> Hi,
>
>
> I am getting this error:
>
> XDMP-ARGTYPE: (err:XPTY0004) xdmp:save("C:\123",
> "{&quot;document&quot;:{&quot;docID&quot;:&quot;\/docs\/0000002-0...") --
> arg2 is not of type node()
>
> I am using MarkLogic 7.
>
>
> declare variable $xml :=
> <document 
> docID="/docs/0000002-0000468-0004456-ISDA-COL-XXXX_2015-04-01_06-33-57-639.xml"
> action="add">
> <metadata>
> <name>XYZ</name>
> <value>fsddddddddddddddddddddddddddddddd sdgsdsdsdsdsdsdsdsdsdsd</value>
> <type>text</type>
> </metadata>
> <metadata>
> <name>Period</name>
> <value>aertw hegheh eheheh ghhehe</value>
> <type>text</type>
> </metadata>
> </document>;
>
> let $uri := "123"
> let $custom :=
>   let $config := json:config("custom")
>   let $_ := map:put( $config, "whitespace", "ignore" )
>   let $_ := map:put( $config, "array-element-names", "metadata" )
>   return $config
>
> let $json :=  json:transform-to-json($xml,$custom)
>
> return
>
>   (
>
>      xdmp:save(concat('C:\test\', $uri), $json)
>
>   )
>
> Thanks
> Pragya
>
> ------------------------------
> *From:* [email protected] <
> [email protected]> on behalf of DK Singh <
> [email protected]>
> *Sent:* Monday, January 2, 2017 1:06:24 PM
> *To:* MarkLogic Developer Discussion
> *Subject:* Re: [MarkLogic Dev General] Json file
>
> Hi Pragya,
>
> You can try out the below mentioned code:
>
> import module namespace json = "http://marklogic.com/xdmp/json"; at
> "/MarkLogic/json/json.xqy";
> for $xmls in fn:collection('MarcVideo')[1 to 10]
> let $xmls1 := xdmp:quote($xmls)
> let $xmls2 := xdmp:unquote($xmls1)
> let $uri := base-uri($xmls)
> let $token := tokenize($uri,'/')[last()]
> let $custom :=
>   let $config := json:config("custom")
>   let $_ := map:put( $config, "whitespace", "ignore" )
>   let $_ := map:put( $config, "array-element-names", "Video" )
>   return $config
>
> let $json :=  json:transform-to-json($xmls,$custom)
>
> return
>
>   (
>
>      xdmp:save(concat('D:\test\', $token), $json)
>
>   )
>
>
> Regards
>
> Dharmendra Kumar Singh
> On Mon, Jan 2, 2017 at 12:28 PM, Kapoor, Pragya <[email protected]>
> wrote:
>
>> Hi,
>>
>>
>> Requirement:
>>
>> 1. Convert xmls stored in marklogic db to json then save them to file
>> system.
>>
>> 2. Store in-memory json  in ML DB
>>
>>
>> How can we achieve the same?
>>
>>
>> Thanks
>>
>> Pragya
>> "This e-mail and any attachments transmitted with it are for the sole use
>> of the intended recipient(s) and may contain confidential , proprietary or
>> privileged information. If you are not the intended recipient, please
>> contact the sender by reply e-mail and destroy all copies of the original
>> message. Any unauthorized review, use, disclosure, dissemination,
>> forwarding, printing or copying of this e-mail or any action taken in
>> reliance on this e-mail is strictly prohibited and may be unlawful."
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
> "This e-mail and any attachments transmitted with it are for the sole use
> of the intended recipient(s) and may contain confidential , proprietary or
> privileged information. If you are not the intended recipient, please
> contact the sender by reply e-mail and destroy all copies of the original
> message. Any unauthorized review, use, disclosure, dissemination,
> forwarding, printing or copying of this e-mail or any action taken in
> reliance on this e-mail is strictly prohibited and may be unlawful."
>
> _______________________________________________
> 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

Reply via email to