所以我有一个有趣的问题,假设我在MarkLogic数据库中有此文档(example.xml):
<Enrolls>
<Enroll>
<Status> Active </Status>
<boom> boom2 </boom>
</Enroll>
<Enroll>
<Status> Active </Status>
<boom> boom </boom>
</Enroll>
<Enroll>
<Status> Inactive </Status>
<boom> boom </boom>
</Enroll>
</Enrolls>
我想用一个节点替换所有“有效”的Enroll元素,因此,基本上我的最终结果应该是:
<Enrolls>
<boom> boom for the actives </boom>
<Enroll>
<Status> Inactive </Status>
<boom> boom </boom>
</Enroll>
</Enrolls>
要完成此操作,这是我编写的代码:
xdmp:node-replace((doc("example.xml")/Enrolls/Enroll[Status eq " Active "]), <boom> boom for the actives </boom>)
但这是我得到的结果:
<Enrolls>
<boom> boom for the actives </boom>
<boom> boom for the actives </boom>
<Enroll>
<Status> Inactive </Status>
<boom> boom </boom>
</Enroll>
</Enrolls>
该代码用我指定替换的相同节点替换了每个活动的注册。我希望它用一个节点同时替换两个节点。我该怎么做并得到想要的结果?