user8420733
user8420733

Reputation:

Updating document in MarkLogic

am newbie to ML and would like to know how to update XML document with keeping old data's canonical part.

What I would like to achieve is, after adding a canonical part, and want to update and replace only original data part. Since we are using same URI, canonical part disappears if I do an update. Is there any merging option or way to do?

Upvotes: 0

Views: 161

Answers (1)

asusu
asusu

Reputation: 321

See xdmp:node-replace. If /mydoc.xml is

<mydoc>
<canonical>my canonical stuff</canonical>
<original>my original stuff</original>
</mydoc>

then

xdmp:node-replace (
    fn:doc ('/mydoc.xml')/mydoc/original,
    <original>my new original stuff</original>
)

changes the store document to

<mydoc>
<canonical>my canonical stuff</canonical>
<original>my new original stuff</original>
</mydoc>

Upvotes: 1

Related Questions