in-mem-update won't update nodes from the DB. What I have done it create a new 
node in memory based on the one loaded from the DB. Maybe there's a better, I 
don't know.

Something like this:

let $uri := "/aa.xml"
let $article-in-db := fn:doc($uri)/pxml:article
let $article := element { fn:name($article-in-db) } { $article-in-db/@*, 
$article-in-db/*, $article-in-db/text() }
return mem:node-insert-child($article/pxml:front/pxml:history, <a/>) 

But then of course you'd have to save the changes back to the DB if you wanted 
to persist them.

From: [email protected]
Date: Thu, 28 Oct 2010 13:16:21 -0400
To: [email protected]
Subject: Re: [MarkLogic Dev General] Inserting node to xml before it is loaded  
in Marklogic



Hello there,

I'm interested in the memupdate from 
http://github.com/marklogic/commons/tree/master/memupdate/  and I tried it.  I 
found one thing that I don't understand:

If I manually get the article node data and assign it to $doc as static data, 
it will work, like   let $doc :=<article   xmlns="pxml">                        
<front>
                            <history/>
                        </front>
                   </article>
   return 
       mem:node-insert-child($doc/pxml:front/pxml:history, <a/>)   
the <a/> is inserted into history node.

But if the node is the node that I use fn:doc() to get from database, then it 
does not do the update in memory. for example:   let $uri := "/aa.xml"   
let $doc := fn:doc($uri)/pxml:article
   
return 
       
mem:node-insert-child($doc/pxml:front/pxml:history, <a/>)   
I expect that it will return me with article node that has the <a/> inserted 
into history node, but it didn't.

Is there anything that I missed?  I want to get a document from database, 
update some node, and then insert into another database with updated data.
Thanks, Helen



On Oct 26, 2010, at 1:10 PM, Micah Dubinko wrote:I believe this could help you:

http://github.com/marklogic/commons/tree/master/memupdate/

Thanks, -m

On Oct 26, 2010, at 2:57 AM, Geert Josten wrote:

Hi Pragya,

It sounds like you are looking for 'in-memory' updating of the XML. There was a 
small library module on XQzone that facilitated with this, but not sure where 
it went on github. It could also that the xqueryfunctions library 
(http://www.xqueryfunctions.com/) provides readily available functions that 
should help you with it. But it is quite trivial with your example:

let $x :=
<x>
                <a>..</a>
                <b>…</b>
                                <c>..</c>
                                <c>..</c>
</x>

return
    element { node-name($x) } {
       $x/@*,
        $x/*,
        <c>...</c>
   }

You can use typeswitch if you need to go through your content recursively..

Kind regards,
Geert



drs. G.P.H. (Geert) Josten
Consultant

Daidalos BV
Hoekeindsehof 1-4
2665 JZ Bleiswijk

T +31 (0)10 850 1200
F +31 (0)10 850 1199

[email protected]
www.daidalos.nl

KvK 27164984


De informatie - verzonden in of met dit e-mailbericht - is afkomstig van 
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit 
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit 
bericht kunnen geen rechten worden ontleend.
From: [email protected] 
[mailto:[email protected]] On Behalf Of Pragya Kapoor
Sent: dinsdag 26 oktober 2010 11:33
To: [email protected]
Subject: [MarkLogic Dev General] Inserting node to xml before it is loaded in 
Marklogic

Hi,

I need to insert and element node to  the following xml without inserting into 
ML:

<x>
                <a>..</a>
                <b>…</b>
                                <c>..</c>
                                <c>..</c>
</x>

I want to add another <c> element based on some condition to get the desired 
xml as:
                <x>
                <a>..</a>
                <b>…</b>
                                <c>..</c>
                                <c>..</c>
                                <c>..</c>
</x>

Please let me know how can I do this.

Thanks,
Pragya
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not 
to copy, disclose, or distribute this e-mail or its contents to any other 
person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken 
every reasonable precaution to minimize this risk, but is not liable for any 
damage 
you may sustain as a result of any virus in this e-mail. You should carry out 
your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this 
e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***


_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general


_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general                         
                  
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to