XQueryHacker

Applying a function in the context of a different database - MarkLogic 7 update 01 May 2014

A couple of years ago I wrote about how useful it would be to apply a function in the contect of a different database. At that time there were two choices - eval a string or invoke a main module. But things have changed since then, in MarkLogic 7 there are a couple of new functions:

xdmp:invoke-function(
   function() { xdmp:document-insert("doc", $content), xdmp:commit() },
   <options xmlns="xdmp:eval"><database>{xdmp:database("another-db")}</options>
)
xdmp:spawn-function(
   $fn,
   <options xmlns="xdmp:eval"><database>{xdmp:database("another-db")}</options>
)

The documentation explains the details better than I could: xdmp:invoke-function, xdmp:spawn-function. And check out taskbot for a great example of these new functions in action.

Previous Posts

  1. MarkLogic and XQuery learning resources 25 Aug 2013

  2. New blog setup using GitHub and Jekyll 17 Nov 2012

  3. api.xqueryhacker.com updated 16 Nov 2012

  4. Applying a function in the context of a different database 17 Mar 2012

  5. Computed indexes in MarkLogic 03 Mar 2012

  6. xray - an XQuery test framework 04 Jan 2012

  7. MarkLogic XQuery performance tuning - computing facets concurrently 03 Jan 2012

  8. DQ update 15 Mar 2011

  9. API interface updated for MarkLogic 4.2 16 Oct 2010

  10. Search interface to MarkLogic API now on SourceForge 24 Mar 2010

  11. Searching the MarkLogic API function reference with MarkLogic 09 Mar 2010

  12. Early version of DQ - an alternative interface for MarkLogic's CQ XQuery editor 13 Jan 2010

  13. Error restoring a MarkLogic forest 04 Dec 2009

  14. SyntaxHighlighter XQuery brush 18 Nov 2009

  15. MarkLogic to add XSLT 2.0 support 17 Nov 2009

  16. MarkLogic: Move documents to new forests 02 Nov 2009

  17. Installing MarkLogic on Ubuntu 9.04 25 Oct 2009

  18. Excel Function library in XQuery 02 Oct 2009

  19. XQuery coalesce 23 Sep 2009

  20. XQDT - XQuery support in Eclipse 10 Sep 2009

  21. Format number in XQuery 03 Sep 2009

  22. XQuery support in Notepad++ XQuery 1.0 and MarkLogic 4.1 update 02 Sep 2009

  23. XDMP-LISTCACHEFULL error 14 Aug 2009

  24. MarkLogic 4.1 Released 20 Jul 2009

  25. MarkLogic improvements 25 Jun 2009

  26. MarkLogic searches - stemmed vs unstemmed 02 Apr 2009

  27. xdmp:strftime() requires year >= 1900 11 Mar 2009

  28. AuthorMapper.com 07 Feb 2009

  29. More on MarkLogic 4 28 Oct 2008

  30. MarkLogic 4 - Initial thoughts 18 Oct 2008

  31. XQuery support in Notepad++ 27 Sep 2008

  32. Welcome! 11 Sep 2008