hell_storm2004
hell_storm2004

Reputation: 1605

Name and number of arguments do not match any function signature in the static context - XQuery

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!

Upvotes: 1

Views: 958

Answers (1)

Ghislain Fourny
Ghislain Fourny

Reputation: 7279

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.

Upvotes: 1

Related Questions