Hi Keith,

It seems like the basic code path you have there should work.  You say you are 
doing a number of successive updates--maybe the conflicting update is coming 
from elsewhere in your XQuery statement?

For example, this works both when the document exists and when it does not:

let $uri := "/hello.xml"
let $new := <bar>new node</bar>
return
if ( xdmp:estimate(fn:doc($uri)) eq 0 )
then ( xdmp:document-insert($uri, <foo>{$new}</foo>), "inserted new document" )
else ( xdmp:node-insert-child(fn:doc($uri)/foo, $new), "added new child node" ) 
 

What is the exact exception you are getting?  Also, what is the entire query?

-Danny

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Keith Breinholt
Sent: Thursday, December 13, 2007 10:47 AM
To: [email protected]
Subject: [MarkLogic Dev General] Avoiding conflicting document-insert()

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.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to