Hi Mark, With Corb (and I assume it is pretty much the same with Corb2), you effectively split your code into two parts:
declare namespace xh="http://library/"; let $uris := for $t in /xh:books/xh:title return xdmp:node-uri($t) return (count($uris), $uris) And then the execution part: declare namespace xh="http://library/"; declare variable $URI external let $t := doc($URI)/xh:books/xh:title return if ($t='Moby Dick’) then xdmp:node-replace($t/text(), text{"Moby Dick (Classic)"} ) else if ($t='War of the Worlds’) then xdmp:node-replace($t/text(), text{"War of the Worlds (Classic)"} ) else () Cheers, Geert From: Mark Shanks <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Wednesday, May 27, 2015 at 7:59 PM To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: [MarkLogic Dev General] Corb transform query Hi, I've worked out how to run Corb2. However, it's not clear to me how to access elements using a query that is equivalent to what you would run in the query console. For instance, I can run the following in the query console: declare namespace xh="http://library/"; for $t in (/xh:books)/xh:title return if ($t='Moby Dick')then xdmp:node-replace($t/text(), text{"Moby Dick (Classic)"} ) else if ($t='War of the Worlds')then xdmp:node-replace($t/text(), text{"War of the Worlds (Classic)"} ) else () This goes through all of the documents in the namespace and converts the relevant titles. With corb, the get-uris.qry returns each of the individual uris. How does one then access the correct element to change it in the transform-docs.xqy? Ideally, I would like to be able to run the query in the query console first to test, using something like: xquery version "1.0-ml"; let $URI := "16780628" **Code to do the transform based on the $URI that identifies a specific document** Thanks, Mark
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
