
xdmp.apply( function as function, [params-1-to-N as Sequence] ) as Sequence
Applies an xdmp:function with the given parameters.
var f = xdmp.function(xs.QName("fn:empty"));
xdmp.apply(f, []);
=> true
var f = xdmp.function(xs.QName("fn:concat"));
xdmp.apply(f, "hello", " world");
=> hello world
Given square.sjs in the modules database as the following:
module.exports = function(width) {
return {
area: function() {
return width * width;
},
set: function(_width) {
width = _width;
}
};
}
var mySquare = fn.head(xdmp.apply(xdmp.function(null,"square.sjs"),4));
xdmp.apply(mySquare.set, 3);
xdmp.apply(mySquare.area)
=> 9
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.