xquery if then语句问题

xquery if then statement issue

我在 MarkLogic 控制台上尝试此代码并收到此错误

Unexpected token syntax error, unexpected If_

这是代码

let $name1 := "Bob"
let $name2 := "John"

if(fn:contains($name1, "Bo")) then
 return "Bob is good"
else 
 return "John is good"

你的语法有误。试试这个-

let $name1 := "Bob"
let $name2 := "John"

return 
  if (fn:contains($name1, "Bo")) then
    "Bob is good"
  else 
    "John is good"