I am trying to return a string, but somehow this function just wouldn't compile. I am a bit lost!
declare function local:findValue($vrf as xs:string?, $namefirst as element()*, $schoolfirst as element()*, $namesecond as element()*, $schoolsecond as element()*) as xs:string? {
return (
if (not(fn:empty($namefirst) or fn:empty($schoolfirst))) then (
if ($vrf) then (
"SCHOOL"
) else (
"HIGHSCHOOL"
)
) else if (not(fn:empty($namesecond) or fn:empty($schoolsecond))) then (
if ($vrf) then (
"SCHOOL"
) else (
"HIGSCHOOL"
)
) else ()
)
};
The compile just wouldn't go through. It throws the exception mentioned in the title, any quick help would be great!
There is no return clause in XQuery functions, as you simply declare the result to be returned inside the curly braces. The return clause is only in FLWOR and other expressions.
The code is hence parsed as a call to a function called return with arity 1. Removing the wrapping
return ( ... )
should fix the error.