Where to declare xquery functions?

Let's take the simplest function I can write to xquery:

declare function local:identityFunction($v as xs:integer) 
{
  return ($v)
}; 

      

Where do I announce this?

I'm trying to use exist-db and basex, but if I write it in the query processor window, they give me some errors (although normal xqueries queries work).

For example, basex complains about the following message: "Waiting for expression".

+3


source to share


1 answer


You can put them in front of the normal expression.

Your mistake is to use 'return', which is neither needed nor allowed there, since the xquery function always returns the last (and only) value.

And the semicolon must be followed by another expression.



So this will work:

declare function local:identityFunction($v as xs:integer) 
{
  $v
};     
local:identityFunction(17)

      

+4


source







All Articles