XML节点替换失败

XML node replace failure

我尝试使用 Corb 在大量文档中搜索和更新节点:

示例输入:

<hcmt xmlns="http://horn.thoery">
  <susceptible>X</susceptible>
  <reponsible>foresee–intervention</reponsible>
  <intend>Benefit Protagonist</intend>
  <justified>Goal Outwiegen</justified>
</hcmt> 

Xquery:

(: let $resp   :=  "foresee–intervention" :)
 
let $docs :=    
  cts:search(doc(),
  cts:and-query((
  cts:collection-query("hcmt"),
  cts:path-range-query("/horn:hcmt/horn:responsible", "=", $resp)
        ))
    )
return
  for $doc in $docs
return
  xdmp:node-replace($doc/horn:hcmt/horn:responsible, "Foresee Intervention")

预期输出:

<hcmt xmlns="http://horn.thoery">
  <susceptible>X</susceptible>
  <reponsible>Foresee Intervention</reponsible>
  <intend>Benefit Protagonist</intend>
  <justified>Goal Outwiegen</justified>
</hcmt>

但是 Corb 中没有发生节点替换,也没有错误 returns。其他查询在 Corb 中工作正常。节点替换如何在 Corb 中正常工作?

在此先感谢您的帮助。

I create functions to reconcile the encoding matters. This not only mitigates potential API transaction failures but also is a requisite to validate & encode parameter or element/property/uri name.

That said, a sample MarkLogic Java API implementation is:

  1. 在文件系统中创建一个动态查询结构,在我的例子中,product-query-option.xml(直接使用查询值:Chooser–Option
<search xmlns="http://marklogic.com/appservices/search">
    <query>
        <and-query>
            <collection-constraint-query>
                <constraint-name>Collection</constraint-name>
                <uri>proto</uri>
            </collection-constraint-query>
            <range-constraint-query>
                <constraint-name>ProductType</constraint-name>
                <value>Chooser–Option</value>
            </range-constraint-query>
        </and-query>
    </query>
</search>
  1. 将持久查询选项部署到模块数据库,在我的例子中,search-lexis.xml,选项文件如下:
<options xmlns="http://marklogic.com/appservices/search">
     <constraint name="Collection">
         <collection prefix=""/>
     </constraint>
     <constraint name="ProductType">
        <range type="xs:string" collation="http://marklogic.com/collation/en/S1">
          <path-index xmlns:prod="schema://fc.fasset/product">/prod:requestProduct/prod:_metaData/prod:productType</path-index>
        </range>
     </constraint>
</options>
  1. Dynamic Java Search
  2. 开始关注
        File file = new File("src/main/resources/queryoption/product-query-option.xml");

        FileHandle fileHandle = new FileHandle(file);

        RawCombinedQueryDefinition rcqDef = queryMgr.newRawCombinedQueryDefinition(fileHandle, queryOption);
  • 您当然可以将查询和选项合并为 QueryDefinition 中的一个句柄。
  1. 你原来的node-replace被翻译成Java Partial Update
  • 确保 DocumentPatchBuilder setNamespaces 与正确的 NamespaceContext.
  1. 对于批量数据操作,高效的方法是 MarkLogic 数据移动:用搜索到的 Uris 实例化 QueryBatcher,提供替换值或数据片段 PatchBuilder.replaceValue ,并完成批处理 dbClient.newXMLDocumentManager().patch(uri, patchHandle);

MarkLogic Data Services: If you succeed above, perhaps, then go at a more robust and scalable enterprise SOA approach, please review Data Services.

  • Gradle 的实现如下:

(注意,所有的转换指标都应该是参数,包括path/element/property名称、命名空间、值...等。没有硬编码。)在service.json中声明的一个代理服务可以服务多个端点(在 /root/df-ds/fxd 下)具有不同类型的模块,让您可以自由地开发纯 Java 或扩展开发平台以处理复杂的数据操作。

If these operations are persistent node update, you should consider in-memory node transform before the ingestion. Besides the MarkLogic data transformation tools, you can harness the power of XSLT2+.

Saxon XPathFactory could be a serviceable vehicle to query/transform node. Not sure if it is a reciprocity, ML Java API implements the XPath compile to split large paths and stream transaction. XSLT/Saxon is not my forte; therefore, I can’t comment how comparable it is with this encode/decode particularity or how it handles transaction (insert, update…etc) streaming.