I have couple of documents on which xdmp:node-replace() over certain elements doesnot work. There are some other set of documents which are almost similar to th
xdmp:node-replace()
If your working with in memory elements import the following module
in memory elements
import module namespace mem = "http://xqdev.com/in-mem-update" at "/MarkLogic/appservices/utils/in-mem-update.xqy";
Instead of using xdmp:node-replace you can use mem:node-replace(, )
xdmp:node-replace
mem:node-replace(, )