【发布时间】:2012-12-06 12:41:12
【问题描述】:
如何在 MarkLogic 中为特定属性进行节点替换?例如如下:
<chapters>
<title id="primary">first primary content</title>
<title id="primary">second primary content</title>
<title id="secondary">this is amy middle content</title>
<title id="terciary">this is amy last content</title>
</chapters>
我想要如下:
<chapters>
<title id="primary">third primary content</title>
<title id="secondary">this is amy middle content</title>
<title id="terciary">this is amy last content</title>
</chapters>
我的意思是假设 A.xml 文件存储在 MarkLogic 数据库服务器中,其中包含类似 bleow 的数据:
<chaptermetadata>
<chapters>
<title id="primary">first content</title>
<title id="primary">second content</title>
<title id="secondary">This is middle content</title>
<title id="terciary">This is last content</title>
</chapters>
<chapters>
<title id="primary">fouth content</title>
<title id="primary">fifth content</title>
<title id="primary">sixth content</title>
<title id="secondary">This is new content</title>
<title id="terciary">This is old content</title>
</chapters>
<chaptermetadata>
现在,我想在所有章节中替换所有元素 title 中的一个节点,其中包含属性 @id='primary',如下所示:
<chaptermetadata>
<chapters>
<title id="primary">common content</title>
<title id="secondary">This is middle content</title>
<title id="terciary">This is last content</title>
</chapters>
<chapters>
<title id="primary">common content</title>
<title id="secondary">This is new content</title>
<title id="terciary">This is old content</title>
</chapters>
<chaptermetadata>
【问题讨论】:
-
鉴于两个代码块之间的差异,很难理解您要求进行何种转换