[MarkLogic Dev General] Inserting node to xml before it is loaded in Marklogic
helen chen
hchen at aip.org
Thu Oct 28 10:16:21 PDT 2010
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
>>
>> geert.josten at daidalos.nl
>> 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: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Pragya Kapoor
>> Sent: dinsdag 26 oktober 2010 11:33
>> To: general at developer.marklogic.com
>> 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
>> General at developer.marklogic.com
>> http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20101028/64318611/attachment-0001.html
More information about the General
mailing list