我不知道如何在 RestXQ 中返回 JSONP。添加
let $x := util:declare-option("exist:serialize", fn:concat("method=json jsonp=",request:get-parameter("callback", "callback")))
到函数后,我收到错误消息:
err:XPTY0004:如果在静态分析阶段发现表达式具有不适合表达式出现的上下文的静态类型,或者在动态求值阶段发现表达式的动态类型不合适,则属于类型错误值与 2.5.4 序列类型匹配中的匹配规则指定的所需类型不匹配。
GET 函数的开头是:
declare
%rest:GET
%rest:path("/demo/contacts/submit")
%rest:query-param("email", "{$email}", '')
%rest:query-param("nomail", "{$nomail}", 0)
%rest:produces("application/javascript")
%output:media-type("application/javascript")
%output:method("json")
function contacts:submit($email as xs:string*, $nomail as xs:integer*)
{
try
{
let $x := util:declare-option("exist:serialize", fn:concat("method=json jsonp=",request:get-parameter("callback", "callback")))