简体   繁体   English

如何在MarkLogic中更改元素的名称

[英]How to change the name of element in MarkLogic

I want to do this change 我想做这个改变

From: 从:

〈aaa〉 bbbbbb 〈/aaa〉 〈aaa〉 bbbbbb 〈/ aaa〉

To: 至:

〈bbb〉 bbbbbb 〈/bbb〉 〈bbb〉 bbbbbb 〈/ bbb〉

by using MarkLogic, XQuery. 通过使用MarkLogic,XQuery。

How to do that? 怎么做?

This can be done using xdmp:node-replace() Refer - xdmp:node-replace 可以使用xdmp:node-replace()来完成此操作-xdmp:node-replace

HTH! HTH!

The simplest thing to do is often to use xdmp:node-replace . 最简单的操作通常是使用xdmp:node-replace However, this assumes both that the data you wish to modify is already inside a document in the database and that you are not performing any conflicting updates to that document. 但是,这既假设您要修改的数据已经在数据库中的文档内部,又没有对该文档执行任何冲突的更新。

When it's not possible to use xdmp:node-replace, your next best option is to modify the document in-memory and then insert the entire document into the database. 当无法使用xdmp:node-replace时,下一个最佳选择是修改内存中的文档,然后将整个文档插入数据库中。

The easiest way to modify the document in-memory is to use mem:replace from the XQuery Memory Operations library . 修改内存中文档的最简单方法是使用XQuery Memory Operations库中的 mem:replace。

The most performant way to modify a document in memory is to write a recursive descent tree optimized to the structure of that document. 修改内存中文档的最有效方法是编写针对该文档结构进行优化的递归下降树

如果该节点不在文档中,则总是存在幼稚的方法:

〈aaa〉 bbbbbb 〈/aaa〉 ! <bbb>{.}</bbb>

XSLT也内置在服务器中。

xquery version "1.0-ml";
xdmp:document-insert("/test1.xml",
<root>
<child1>
<aaa>bbbbbb</aaa>
</child1>
</root>
);
doc("/test1.xml");
xdmp:node-replace(doc("/test1.xml")/root/child1/aaa,<bbb>bbbbbb</bbb>);
doc("/test1.xml");

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

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