如何构造这个 XQuery 以在 CORB 作业中运行?处理具有匹配候选 URI 的每个文档的第二个模块不起作用。
优利斯模块
(:a module to select the candidate URIs to process:)
xquery version "1.0-ml";
declare variable $target-collection := "/activity";
declare variable $update-collection := "/activity/analytics-read-added"
let $uris := cts:uris( (),
(),
cts:and-query((
cts:collection-query($target-collection),
cts:not-query(cts:collection-query($update-collection))
))
)
return (count($uris), $uris)
过程模块
(:a module to process each doc with a matching candidate URI:)
declare variable $URI as xs:string external;
xdmp:document-add-permission($URI,xdmp:permission("act-read-role","read")),
xdmp:document-add-collections($URI,$update-collection)
您的流程模块有几个小问题:
- 如果要使用它,还需要在 URIS 模块中声明的变量
$update-collection
在流程模块中声明。 - 添加权限的函数拼写错误。它是复数:
xdmp:document-add-permissions()
将这些更改应用于流程模块:
xquery version "1.0-ml";
(:a module to process each doc with a matching candidate URI:)
declare variable $URI as xs:string external;
declare variable $update-collection := "/activity/analytics-read-added";
xdmp:document-add-permissions($URI, xdmp:permission("act-read-role","read")),
xdmp:document-add-collections($URI, $update-collection)
如果需要排除故障并调查流程模块无法正常工作的原因,有时最简单的方法是将流程模块 XQuery 的内容粘贴到查询控制台中,为$URI
变量分配一个值,然后在 QConsole 中执行。
例如:
declare variable $URI as xs:string external := "/some/test/doc.xml";