Hi, Krishna:

The persisted document has a serious problem.  Everything up to the item 
element is persisted as XML.

The contents of the item element are also XML but are persisted as text.  
That's why you have to unquote to get at the nested XML.

You should take a look at the code that's persisting the document and fix that 
code so the whole tree is persisted as XML.

Then, xdmp:node-replace() will work without issue on the nested elements.


Hoping that helps,


Erik Hennum


________________________________
From: [email protected] 
[[email protected]] on behalf of krishnanghri reddy 
[[email protected]]
Sent: Thursday, March 31, 2016 9:15 AM
To: [email protected]
Subject: Re: [MarkLogic Dev General] Need help in updating xml

Hi,

I have an xml in the below format. I am trying to update Version element inside 
<item> tag and facing an issue.

"cannot update constructed nodes"

I tried "in-mem-update.xqy" ,it updated the node on the fly and is not updating 
in the database.
How to update the node  in the database ?

Here is the query I used:

let $_ := 
mem:node-replace(xdmp:unquote(doc($uri")/*:pod_catalog_pod/*:item/text(),(),"repair-full")/*:pod/*:metadata/*:Version,<Version
 xmlns="http://podmetadata";>0</Version>)
return $_

XML in the database.

<?xml  version="1.0" encoding="UTF-8"?>
<pod_catalog_pod xmlns="http://services-pod/1/";>
<metadata>
<status>online</status>
</metadata>
<item xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";><?xml version="1.0" 
encoding="utf-16"?>
<pod xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
Key="0385788e-70a7-4109-bbf9-7b5be6d7f690" xmlns="http://entities";>
  <authorizations>
    <Authorization>1000516</Authorization>
  </authorizations>
  <blobs/>
  <constraint>search</constraint>
  <metadata>
    <Id xmlns="http://podmetadata";>podmetadata</Id>
    <Title xmlns="http://podmetadata";>Search Box</Title>
    <Version xmlns="http://podmetadata";>1</Version>
    <Created xmlns="http://podmetadata";>2015-11-06T10:45:45.5223577Z</Created>
    <Updated xmlns="http://podmetadata";>2016-01-12T01:05:33.5575597Z</Updated>
    <Description xmlns="http://podmetadata";>description</Description>
     <UpdatedBy xmlns="http://podmetadata";>testuser</UpdatedBy>
    <CreatedBy xmlns="http://podmetadata";>testuser</CreatedBy>
    <MasterFeatures xmlns="http://podmetadata";>
      <MasterFeature>123576</MasterFeature>
    </MasterFeatures>
    <Status xmlns="http://podmetadata";>published</Status>
  </metadata>
</pod></item>
</pod_catalog_pod>



Thanks
Krishna
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to