Hi Geert, One more thing I am using marklogic 7.5
Thanks & Regards, Siva -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Wednesday, May 25, 2016 11:17 AM To: [email protected] Subject: General Digest, Vol 143, Issue 36 Send General mailing list submissions to [email protected] To subscribe or unsubscribe via the World Wide Web, visit http://developer.marklogic.com/mailman/listinfo/general or, via email, send a message with subject or body 'help' to [email protected] You can reach the person managing the list at [email protected] When replying, please edit your Subject line so it is more specific than "Re: Contents of General digest..." Today's Topics: 1. Regarding spwan function (Mani, Sivasubramani (ELS)) 2. Re: Regarding spwan function (Geert Josten) ---------------------------------------------------------------------- Message: 1 Date: Wed, 25 May 2016 10:01:50 +0000 From: "Mani, Sivasubramani (ELS)" <[email protected]> Subject: [MarkLogic Dev General] Regarding spwan function To: "[email protected]" <[email protected]> Message-ID: <cy1pr0801mb10199a9b76d3fc26f2b8deeff4...@cy1pr0801mb1019.namprd08.prod.outlook.com> Content-Type: text/plain; charset="us-ascii" Hi All, I am new marklogic I writed a spwan function to update the documents and I use xdmp:node-replace and xdmp:node-insert-child inside the spwan function but there is no update is happen inside the cod. My code is below let $start := 225001 let $end := 226000 return xdmp:spawn-function(function() { let $log := xdmp:log(concat("Running update for chunk", $start, " to ",$end)) for $uri in cts:uris((),(),cts:and-query((cts:element-query(xs:QName("dp:document-properties"), "*"))))[$start to $end] let $itemPii := (tokenize($uri, "/")[last()-1]) let $uri := replace("https://acc.vtw.elsevier.com/property/pii/itempii?category=cs:consyn", "itempii", $itemPii) let $psResponse := json:transform-from-json(xdmp:quote( xdmp:http-get($uri, <options xmlns="xdmp:http"> <authentication method="digest"> <username>{xs:string("")}</username> <password>{xs:string("")}</password> </authentication> <verify-cert>false</verify-cert> </options>)[2])) let $copyright_info := eninglib:construct-copyright-notice-element($itemPii,$psResponse) let $license_info := eninglib:construct-copyright-licenseLine-element($itemPii,$psResponse) return ( if(exists($copyright_info) or exists($license_info)) then ( let $log := xdmp:log(concat("Copyright update-", $itemPii, "Copyright Info - ",$copyright_info,"License Info -",$license_info)) let $node := doc($uri)//dp:document-properties/dp:copyrightInformation let $cp := if (exists($node)) then (xdmp:node-replace($node,<dp:copyrightInformation>{$copyright_info,$license_info}</dp:copyrightInformation>)) else (xdmp:node-insert-child(doc($uri)//dp:document-properties,<dp:copyrightInformation>{$copyright_info,$license_info}</dp:copyrightInformation>)) let $oanode := doc($uri)//cps:consyn-properties/cps:oa-last-updated-timestamp let $oa := if(exists($oanode)) then(xdmp:node-replace($oanode,<cps:oa-last-updated-timestamp>{current-dateTime()}</cps:oa-last-updated-timestamp>)) else(xdmp:node-insert-child(doc($uri)//cps:consyn-properties,<cps:oa-last-updated-timestamp>{current-dateTime()}</cps:oa-last-updated-timestamp>)) return () ) else() ) },<options xmlns="xdmp:eval"> <transaction-mode>update-auto-commit </transaction-mode> </options>) Kindly do needful. Thanks & Regards, Siva -------------- next part -------------- An HTML attachment was scrubbed... URL: http://developer.marklogic.com/pipermail/general/attachments/20160525/a62dc7ae/attachment-0001.html ------------------------------ Message: 2 Date: Wed, 25 May 2016 10:16:37 +0000 From: Geert Josten <[email protected]> Subject: Re: [MarkLogic Dev General] Regarding spwan function To: MarkLogic Developer Discussion <[email protected]> Message-ID: <d36b480c.dbfad%[email protected]> Content-Type: text/plain; charset="us-ascii" Did you check your code outside a spawn on a few documents? Cheers, Geert From: <[email protected]<mailto:[email protected]>> on behalf of "Mani, Sivasubramani (ELS)" <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Wednesday, May 25, 2016 at 12:01 PM To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: [MarkLogic Dev General] Regarding spwan function Hi All, I am new marklogic I writed a spwan function to update the documents and I use xdmp:node-replace and xdmp:node-insert-child inside the spwan function but there is no update is happen inside the cod. My code is below let $start := 225001 let $end := 226000 return xdmp:spawn-function(function() { let $log := xdmp:log(concat("Running update for chunk", $start, " to ",$end)) for $uri in cts:uris((),(),cts:and-query((cts:element-query(xs:QName("dp:document-properties"), "*"))))[$start to $end] let $itemPii := (tokenize($uri, "/")[last()-1]) let $uri := replace("https://acc.vtw.elsevier.com/property/pii/itempii?category=cs:consyn", "itempii", $itemPii) let $psResponse := json:transform-from-json(xdmp:quote( xdmp:http-get($uri, <options xmlns="xdmp:http"> <authentication method="digest"> <username>{xs:string("")}</username> <password>{xs:string("")}</password> </authentication> <verify-cert>false</verify-cert> </options>)[2])) let $copyright_info := eninglib:construct-copyright-notice-element($itemPii,$psResponse) let $license_info := eninglib:construct-copyright-licenseLine-element($itemPii,$psResponse) return ( if(exists($copyright_info) or exists($license_info)) then ( let $log := xdmp:log(concat("Copyright update-", $itemPii, "Copyright Info - ",$copyright_info,"License Info -",$license_info)) let $node := doc($uri)//dp:document-properties/dp:copyrightInformation let $cp := if (exists($node)) then (xdmp:node-replace($node,<dp:copyrightInformation>{$copyright_info,$license_info}</dp:copyrightInformation>)) else (xdmp:node-insert-child(doc($uri)//dp:document-properties,<dp:copyrightInformation>{$copyright_info,$license_info}</dp:copyrightInformation>)) let $oanode := doc($uri)//cps:consyn-properties/cps:oa-last-updated-timestamp let $oa := if(exists($oanode)) then(xdmp:node-replace($oanode,<cps:oa-last-updated-timestamp>{current-dateTime()}</cps:oa-last-updated-timestamp>)) else(xdmp:node-insert-child(doc($uri)//cps:consyn-properties,<cps:oa-last-updated-timestamp>{current-dateTime()}</cps:oa-last-updated-timestamp>)) return () ) else() ) },<options xmlns="xdmp:eval"> <transaction-mode>update-auto-commit </transaction-mode> </options>) Kindly do needful. Thanks & Regards, Siva -------------- next part -------------- An HTML attachment was scrubbed... URL: http://developer.marklogic.com/pipermail/general/attachments/20160525/a78ec4d6/attachment.html ------------------------------ _______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general End of General Digest, Vol 143, Issue 36 **************************************** _______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
