Thanks David, this works for me.
________________________________
From: [email protected]
<[email protected]> on behalf of David Lee
<[email protected]>
Sent: Tuesday, January 3, 2017 6:39:28 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Json file
In v7 transform-to-json returns a string.
Try xdmp:save("file", text { $json })
-DavId Lee
Sent from my iPad
On Jan 3, 2017, at 5:24 AM, Kapoor, Pragya
<[email protected]<mailto:[email protected]>> wrote:
Hi,
I am getting this error:
XDMP-ARGTYPE: (err:XPTY0004) xdmp:save("C:\123",
"{"document":{"docID":"\/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]<mailto:[email protected]>
<[email protected]<mailto:[email protected]>>
on behalf of DK Singh <[email protected]<mailto:[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]<mailto:[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]<mailto:[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]<mailto:[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