In the documentation for xdmp:invoke
, it's possible to pass parameters as the second argument.
For xdmp:invoke-function
this option is not available. Is there any workaround to achieve this?
Mapping a list to a function is easy. What I am trying to achieve is a kind of aspect oriented function which checks for what succeeded and failed and standard log messages for any functions that are called this way. Something like:
declare function my-mapper ($array, $fn) {
(: standard logging and checks :)
for $a in $array
return try {
(: now call the function with parameter :)
xdmp:invoke-function($fn($a),<options>...</options>)
} catch ($e) {
(: standard housekeeping if something goes wrong :)
...
}
})
my-mapper($array, function ($item) {
(: do stuff with item :)
})
Is there any way to achieve this in XQuery using MarkLogic?