[MarkLogic Dev General] Avoiding conflicting document-insert()

Keith Breinholt BreinholtKL at ldschurch.org
Thu Dec 13 10:47:26 PST 2007


I'm trying to do a number of updates in successive order and then write information to a history file.
 
My problem is that when I write the history I don't know if the history file has already been created.
 
Here is the code path:
 
  if(xdmp:estimate(fn:doc($history-uri))) then
      xdmp:node-insert-child(fn:doc($history-uri)/cms:events,$event)
  else
      xdmp:document-insert( $history-uri,
                                        <cms:events>{$event}</cms:events>,
                                        (xdmp:permission("cms","read"),xdmp:permission("cms","update")),
                                        "http://ldschurch.org/cms/history"
                                       )    

The problem is that I am getting conflicting document-inserts().  Apparently xdmp:estimate(fn:doc()) isn't absolute at determining if a document exists or not.
 
Is there an absolute way to know if a document exists so that I don't try to create it again?
 
Thanks,
 
Keith L. Breinholt
ICS - Platform Team
"Do what you can, with what you have, where you are." -Theodore Roosevelt

----------------------------------------------------------------------
NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20071213/addc5102/attachment.html


More information about the General mailing list