不完整的FLWOR表达式:期望“返回" [英] Incomplete FLWOR expression: expecting 'return'

查看:113
本文介绍了不完整的FLWOR表达式:期望“返回"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用XQuery的if-then-else命令时遇到麻烦.

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

当前,我正在使用BaseX来编辑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)
)

这件作品引发了一个错误,说: [XPST0003] FLWOR表达式不完整:期待返回".

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

推荐答案

您的xquery有一个小问题.这是更正的版本-

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

这篇关于不完整的FLWOR表达式:期望“返回"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆