[MarkLogic Dev General] question about discrete transactions

Jakob Fix jakob.fix at gmail.com
Fri Aug 13 09:46:15 PDT 2010


Hi,

I've created an xquery module called by a document-creation trigger
that does the following:

1) copy the original document to another directory
2) remove the original document
3) add a property to the new document

In order for this to work, I created a function for each task, and
inside each function I did an xdmp:eval()  to make sure that these
actions are considered independent transactions. Can someone confirm
that this is the right approach? Judging from the documentation and
the fact that it works this seems ok, but I'm kind of hesitant to use
eval() all over the place.

Thanks,
Jakob.

Here's an example for the xdmp:document-insert wrapper function:

declare function local:insert-document( $new-filename as xs:string,
$doc as document-node() ) as item()*
{
    xdmp:eval("
      xquery version '1.0-ml';
      declare variable $new-filename as xs:string external;
      declare variable $doc as document-node() external;
      xdmp:document-insert( $new-filename, $doc )
    ",
      (
        xs:QName("new-filename"), $new-filename,
        xs:QName("doc"), $doc
      )
    )
};


More information about the General mailing list