简体   繁体   English

MarkLogic 8 - 使用文档管理和结帐的XQuery

[英]MarkLogic 8 - XQuery using Document manage and checkout

I have tried the below mentioned xquery. 我尝试了下面提到的xquery。 If document is not managed I want to manage the document using a DLS query otherwise I want to checkout the document. 如果文档未被管理,我想使用DLS查询管理文档,否则我想签出文档。

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. 如果我身边有任何问题,请纠正我。

The xquery looks fine. xquery看起来很好。 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    
        ()

you cannot checkout and manage in the same transaction. 您无法在同一交易中结帐和管理。 You can checkout in 2 independent transactions in the same request, managed by a parent transaction (as long as you do not hold any locks before or during. 您可以在同一请求中签出2个独立事务,由父事务管理(只要您在之前或期间没有持有任何锁定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM