Incomplete FLWOR expression: expecting 'return'

天涯浪子 提交于 2019-12-10 22:16:02

问题


I am having some trouble with the if-then-else command of the XQuery.

Currently I am using BaseX to edit XQuery (if that matters!)

if ($item/pf3:Current/pf3:Name) then (
    let $Name := "None"
) else (
    let $Name := data($item/pf3:Current/pf3:Name)
)

This piece throws an error saying: [XPST0003] Incomplete FLWOR expression: expecting 'return'.


回答1:


There is a small problem with your xquery. Here is the corrected version -

let $Name :=
if ($item/pf3:Current/pf3:Name) 
then "None" 
else data($item/pf3:Current/pf3:Name)

If there are no return statements following the above assignment statement, you can append the following return statement after the above statements -

return $Name


来源:https://stackoverflow.com/questions/36562739/incomplete-flwor-expression-expecting-return

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!