[MarkLogic Dev General] Reg: Issue with xdmp:node-insert-child()

Danny Sokolsky Danny.Sokolsky at marklogic.com
Fri Aug 10 15:17:38 PDT 2012


Hi Siriam,

Since you did not give the whole code or tell us the error you are seeing, it is hard to say.  For example, in the code you have, there is no $parent-id variable bound.  The basic idea you have works, as this code inserts a child node after the root node:

xdmp:document-insert("/testdevlist.xml", <version-info xmlns="http://namespace">
                <id>ABCD13255DEFG</id>
                <additions/>
                <updates/>
                <deletes/>
  </version-info>
);

declare namespace pce="http://namespace";
let $version-info := fn:doc("/testdevlist.xml")/pce:version-info
return xdmp:node-insert-child($version-info, <foo/>);

doc("/testdevlist.xml")
=>
<?xml version="1.0" encoding="UTF-8"?>
<version-info xmlns="http://namespace">
  <id>ABCD13255DEFG</id>
  <additions/>
  <updates/>
  <deletes/>
  <foo xmlns=""/>
</version-info>

So I maybe if you simplify your query and then post some code along with results and/or error messages, we can help figure it out.

-Danny

From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Gampa, Sriram
Sent: Friday, August 10, 2012 2:22 PM
To: general at developer.marklogic.com
Subject: [MarkLogic Dev General] Reg: Issue with xdmp:node-insert-child()

Hi All,

I'm having an issue while inserting an element into a node using xdmp:node-insert-child().

My xml structure is as below

<version-info xmlns="http://namespace">
                <id>ABCD13255DEFG</id>
                <additions/>
                <updates/>
                <deletes/>
  </version-info>

I'm trying to insert <parent-id> 13242682898790</parent-id> into the <version-info> as child using the xdmp:node-insert-child() as part of my code but the node is not getting inserted into the version-info xml. But when I tried to the same through CQ its working fine.


let $version-info-uri := "/content/documents/sd/62211250/ ABCD13255DEFG-version-info-7.xml"
let $log1 := xdmp:log(fn:concat("Update Note: Version Info URI", $version-info-uri))
let $version-info := fn:doc($version-info-uri)/pce:version-info
...
...
xdmp:log(fn:concat("version-info before", $version-info)),
xdmp:node-insert-child($version-info,<nmsp:parent-id>{$parent-id}</nmsp:parent-id>),
xdmp:log(fn:concat("version-info after", $version-info)),
xdmp:log(fn:concat("parent-standard-id::",$parent-id)),

Could please let me know what is the issue with the above code.

Thanks,
Sriram Gampa
Off: 407-345-2386 |Cell: 612-867-3232|email: Sriram.Gampa at hmhpub.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20120810/bd6f3c11/attachment.html 


More information about the General mailing list