Reputation: 1109
Let's take the most simple function I can think of written in xquery:
declare function local:identityFunction($v as xs:integer)
{
return ($v)
};
Where do I declare it?
I am trying both exist-db and basex, but if I write it in the query processor window, they give me some errors (though normal xqueries work).
For example basex complains with the following message: "Expecting expression".
Upvotes: 4
Views: 2958
Reputation: 16917
You can insert them before the normal expression.
Your mistake is to use 'return', which is neither needed nor allowed there, since a xquery function always returns the last (and only) value.
And the semicolon should be followed with another expression.
Therefore this will work:
declare function local:identityFunction($v as xs:integer)
{
$v
};
local:identityFunction(17)
Upvotes: 5