Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MarkLogic 8 - XQuery using Document manage and checkout

I have tried the below mentioned xquery. If document is not managed I want to manage the document using a DLS query otherwise I want to checkout the document.

xquery version "1.0-ml";
import module namespace dls = "http://marklogic.com/xdmp/dls"  at "/MarkLogic/dls.xqy";

let $uri :="/root/189966_01.xml"

let $i := dls:document-is-managed($uri)

return 
  if ($i = fn:false())
  then 

    dls:document-manage($uri,  fn:false(),   "Baz is now a managed document") 

    (:  dls:document-checkout($uri, fn:true(), "updating doc", 3600) :)

  else if ($i = fn:true())
  then

      dls:document-checkout($uri, fn:true(), "updating doc", 3600) 

  else 

    "No action"

please correct me if anything is wrong on my side.

like image 878
Antony Avatar asked Dec 19 '25 12:12

Antony


1 Answers

The xquery looks fine. Just a restructuring of the above query -

xquery version "1.0-ml";
import module namespace dls = "http://marklogic.com/xdmp/dls"  at "/MarkLogic/dls.xqy";    
let $uri :="/root/189966_01.xml"    
let $i := dls:document-is-managed($uri)    
return 
    if ($i = fn:false()) then     
        dls:document-manage($uri,  fn:false(),   "Baz is now a managed document")    
    else     
        if ($i = fn:true()) then    
            dls:document-checkout($uri, fn:true(), "updating doc", 3600)     
    else    
        ()
like image 92
Ankit Bhardwaj Avatar answered Dec 21 '25 07:12

Ankit Bhardwaj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!