[MarkLogic Dev General] question about getting document from another database

Wayne Feick wayne.feick at marklogic.com
Thu Aug 19 10:53:03 PDT 2010

  Hi Helen,

Take a look at the docs for xdmp:eval() and xdmp:invoke(), specifically 
the database option. Here's a quick example.

       'xquery version "1.0-ml";
        declare variable $URI as xs:string external;
       ', (xs:QName("URI"), "/foo.xml"),
       <options xmlns="xdmp:eval">

Note that a cross database eval/invoke will always run as a separate 
transaction (either a second update, or at a different commit timestamp 
if it's a query).

I've found the xdmp:function capability very useful in this context to 
call a function in the context of a different database.

    declare function local:foo($arg1, $arg2) { ... };

       'declare variable $FN as xdmp:function external;
        declare variable $ARG1 external;
        declare variable $ARG2 external;
       ', (xs:QName("FN"), xdmp:function("local:foo"),
           xs:QName("ARG1"), $x,
           xs:QName("ARG2"), $y),
       <options xmlns="xdmp:eval">

Both of those code snippets are from memory, so they may not be quite right.


On 08/19/2010 10:41 AM, helen chen wrote:
> I'm inside marklogic and in database A, if I want to get some document from another database B and do something,  like if I want to get the list of document with uri  pattern "/a/b/*xml" from database B,   how can I do it?
> Thanks, Helen
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general

Wayne Feick
Lead Engineer
MarkLogic Corporation
Phone +1 650 655 2378
Cell +1 408 981 4576

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20100819/a35fe69c/attachment.html 

More information about the General mailing list