Hello Mark,If the value of the title that you are interested in is the 
complete field value then you can use cts:element-value-query else you can use 
cts:element-word-query.
the selector code can be enhanced to select the uris that contain the title 
value that you are interested in.

declare namespace xh="http://library/";;
let $uris := 
cts:uris((),(),cts:element-query(xs:QName("xh:books"),cts:element-value-query(xs:QName("xh:title"),("Moby
 Dick","War of the Worlds"))))
return (count($uris), $uris)

Sai.



     On Thursday, May 28, 2015 4:58 AM, Geert Josten 
<[email protected]> wrote:
   

 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:titlereturn    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]>
Reply-To: MarkLogic Developer Discussion <[email protected]>
Date: Wednesday, May 27, 2015 at 7:59 PM
To: "[email protected]" <[email protected]>
Subject: [MarkLogic Dev General] Corb transform query

#yiv4087567889 #yiv4087567889 --.yiv4087567889hmmessage 
P{margin:0px;padding:0px;}#yiv4087567889 
body.yiv4087567889hmmessage{font-size:12pt;font-family:Calibri;}#yiv4087567889 
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:titlereturn 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


  
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to