Ok, this is what I did and it seems to give me what I need. I use it like 
xdmp:apply, eg aint:apply($function, $params)

Any peer reviews appreciated. Two files, the first is called, which then uses 
the invoker to xdmp:invoke back on itself in a new update transaction:


apply-in-new-transaction.xqy:
-----------------------------------
module namespace aint = "apply-in-new-transaction";

declare option xdmp:mapping "false";

declare function apply($function) {
    apply($function, ())
};

declare function apply($function, $params) {
    xdmp:invoke("apply-in-new-transaction-invoker.xqy", 
            ((xs:QName("aint:function"), $function), (xs:QName("aint:params"), 
$params)),
            <options xmlns="xdmp:eval">
              <isolation>different-transaction</isolation>
             </options>)
};



apply-in-new-transaction-invoker.xqy:
---------------------------------------------
declare namespace aint = "apply-in-new-transaction";
declare option xdmp:update "true";

declare variable $aint:function as xdmp:function external;
declare variable $aint:params as item()* external;

xdmp:apply($aint:function, $aint:params)






> From: colleen.whit...@marklogic.com
> To: general@developer.marklogic.com
> Date: Fri, 29 Jul 2011 14:27:21 -0700
> Subject: Re: [MarkLogic Dev General] Cannot apply an update function from a 
> query
> 
> Yes.
> 
> If you want to force update mode, you can use this option in the prolog of 
> your calling module:
> 
> declare option xdmp:update "true";
> 
> But that doesn't help you if you want to run in query mode when updates are 
> not involved.
> 
> --Colleen
> 
> Colleen Whitney
> MarkLogic Corporation
> 
> Phone +1 650 655 2366
> email  colleen.whit...@marklogic.com
> web    www.marklogic.com
> 
> This e-mail and any accompanying attachments are confidential. The 
> information is intended solely for the use of the individual to whom it is 
> addressed. Any review, disclosure, copying, distribution, or use of this 
> e-mail communication by others is strictly prohibited. If you are not the 
> intended recipient, please notify us immediately by returning this message to 
> the sender and delete all copies. Thank you for your cooperation.
> 
> ________________________________________
> From: general-boun...@developer.marklogic.com 
> [general-boun...@developer.marklogic.com] On Behalf Of seme...@hotmail.com 
> [seme...@hotmail.com]
> Sent: Friday, July 29, 2011 2:27 PM
> To: general@developer.marklogic.com
> Subject: Re: [MarkLogic Dev General] Cannot apply an update function from a 
> query
> 
> Ok. So did static analysis not detect that the code should run as an update 
> query because the xdmp:document-insert call was on the other side of the 
> xdmp:apply call? I'm thinking this is a new thing I've got to be on the 
> lookout for.
> 
> ________________________________
> From: jhun...@marklogic.com
> Date: Fri, 29 Jul 2011 14:19:32 -0700
> To: general@developer.marklogic.com
> Subject: Re: [MarkLogic Dev General] Cannot apply an update function from a 
> query
> 
> On Jul 29, 2011, at 2:08 PM, seme...@hotmail.com<mailto:seme...@hotmail.com> 
> wrote:
> 
> Am I going to have to xdmp:eval or xdmp:invoke the function and declare it to 
> be in a separate transaction?
> 
> Yes.  You can eval or invoke the function or the apply of the function.
> 
> -jh-
> 
> 
> _______________________________________________ General mailing list 
> General@developer.marklogic.com 
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
                                          
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to