Hi Abhishek,
Ah, my bad. You could either follow in the line of the approach suggested by
Sunny, and reconstruct the entire doc, though I would try to avoid fn:name()
comparison and use self:: axis instead in that case. But you could still use
xdmp:node-replace if you like. MarkLogic Server allows multiple
xdmp:node-replace calls on the same document within a single transaction,
provided they don't conflict.
Also, I somehow have the impression that it may be unpredictable which element
needs to be preserved. That is manageable too, though requires using fn:name():
let $org := doc('sample.xml')/sample
let $new := <sample>
<sample1>A</sample1>
<sample2>A</sample2>
<sample3>A</sample3>
<sample5>A</sample5>
<sample6>A</sample6>
</sample>
for $o in $org/*
let $replacement := $new/*[fn:name(.) eq fn:name($o)]
return
xdmp:node-replace($o, $replacement)
Kind regards,
Geert
Van: [email protected]
[mailto:[email protected]] Namens Abhishek53 S
Verzonden: woensdag 15 juni 2011 16:20
Aan: General MarkLogic Developer Discussion
Onderwerp: Re: [MarkLogic Dev General] Node Replace
Geert Thanks for the reply ! But it is not simply node-replace. I need to
replace the entire content XML except one elements. For example I have one
test.xml already there into ML as
<sample>
<sample1>A</sample1>
<sample2>B</sample2>
<sample3>C</sample3>
<sample4>D</sample4>
<sample5>E</sample5>
<sample6>F</sample6>
</sample>
Next time I am going to ingest the following file with the same uri. I need to
get the value of <sample4> from the older (already present into ML) text.xml ,
add this to the new one coming and the insert to ML with same URI within single
transaction.
<sample>
<sample1>A</sample1>
<sample2>A</sample2>
<sample3>A</sample3>
<sample5>A</sample5>
<sample6>A</sample6>
</sample>
I guess I am clear with the example
Thanks & Regards
Abhishek Srivastav
Systems Engineer
Tata Consultancy Services
Cell:- +91-9883389968
Mailto: [email protected]<mailto:[email protected]>
Website: http://www.tcs.com<http://www.tcs.com/>
____________________________________________
Experience certainty. IT Services
Business Solutions
Outsourcing
____________________________________________
From:
Geert Josten <[email protected]>
To:
General MarkLogic Developer Discussion <[email protected]>
Date:
06/15/2011 03:47 PM
Subject:
Re: [MarkLogic Dev General] Node Replace
Sent by:
[email protected]
________________________________
Hi Abhishek,
I think you are looking for xdmp:node-replace:
http://developer.marklogic.com/pubs/4.2/apidocs/UpdateBuiltins.html#xdmp:node-replace
You can find functions to do inserts of new elements and things like that on
that page as well..
Kind regards,
Geert
Van:
[email protected]<mailto:[email protected]>
[mailto:[email protected]] Namens Abhishek53 S
Verzonden: woensdag 15 juni 2011 11:06
Aan: General MarkLogic Developer Discussion
Onderwerp: [MarkLogic Dev General] Node Replace
Hi All
I have my content XML as follows
<sample>
<sample1>A</sample1>
<sample2>B</sample2>
<sample3>C</sample3>
<sample4>D</sample4>
<sample5>E</sample5>
<sample6>F</sample6>
</sample>
with all the possible hierarchies. The document is already present in marklogic
repository. If the same document is going to be updated I need to replace the
entire old content XML with the new one except the element <sample5>. What is
best possible way to achieve this in a single transaction.
It is like getting the <sample5> element value from the older one setting to
the new coming content XML and the ingesting to marklogic but the problem is
there for on the fly XML modification.
Abhishek Srivastav
Systems Engineer
Tata Consultancy Services
Cell:- +91-9883389968
Mailto: [email protected]<mailto:[email protected]>
Website: http://www.tcs.com<http://www.tcs.com/>
____________________________________________
Experience certainty. IT Services
Business Solutions
Outsourcing
____________________________________________
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general