Transactions 在同一事务中使用marklogic dls API更新内容摄取和属性 导入模块命名空间dls=”http://marklogic.com/xdmp/dls“at”/MarkLogic/dls.xqy”; 让$uri:=“/ml workflow/test2.xml” let$content:=苹果 let$properties:=芒果 返回 (dls:文档插入和管理($uri,fn:false(),$content),dls:文档集属性($uri,$properties))

Transactions 在同一事务中使用marklogic dls API更新内容摄取和属性 导入模块命名空间dls=”http://marklogic.com/xdmp/dls“at”/MarkLogic/dls.xqy”; 让$uri:=“/ml workflow/test2.xml” let$content:=苹果 let$properties:=芒果 返回 (dls:文档插入和管理($uri,fn:false(),$content),dls:文档集属性($uri,$properties)),transactions,xquery,marklogic,Transactions,Xquery,Marklogic,问:我试图在同一事务中插入文档并使用Marklogic dls API设置其属性,但它不允许我这样做。 请帮忙 这将在下面的代码示例中解释 试着这样做: import module namespace dls = "http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy"; let $uri := "/ml-workflow/test2.xml" let $content := <apple>APPLE</apple&g

问:我试图在同一事务中插入文档并使用Marklogic dls API设置其属性,但它不允许我这样做。
请帮忙

这将在下面的代码示例中解释

试着这样做:

import module namespace dls = "http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy";

let $uri := "/ml-workflow/test2.xml" 

let $content := <apple>APPLE</apple>

let $properties := <prop>MANGO</prop>

return

(dls:document-insert-and-manage($uri,fn:false(),$content),dls:document-set-properties($uri,$properties) )
导入模块命名空间dls=”http://marklogic.com/xdmp/dls"
位于“/MarkLogic/dls.xqy”;
声明选项xdmp:事务模式“更新”;
让$uri:=“/ml workflow/test2.xml”
let$content:=苹果
返回dls:documentinsert和manage($uri,fn:false(),$content)
;
导入模块命名空间dls=”http://marklogic.com/xdmp/dls"
位于“/MarkLogic/dls.xqy”;
让$uri:=“/ml workflow/test2.xml”
let$properties:=芒果
返回dls:文档集属性($uri,$properties)
xdmp:commit()

如果使用外部变量,可以避免重复的值。

如果出现冲突的更新错误,简短的回答是不能。但您可以使用多语句事务(MST)在单独的事务中有效地执行这两项操作,但同时提交它们。
import module namespace dls = "http://marklogic.com/xdmp/dls"
  at "/MarkLogic/dls.xqy";

declare option xdmp:transaction-mode "update";

let $uri := "/ml-workflow/test2.xml" 
let $content := <apple>APPLE</apple>
return dls:document-insert-and-manage($uri,fn:false(),$content)
;

import module namespace dls = "http://marklogic.com/xdmp/dls"
  at "/MarkLogic/dls.xqy";

let $uri := "/ml-workflow/test2.xml" 
let $properties := <prop>MANGO</prop>
return dls:document-set-properties($uri,$properties)
xdmp:commit()