小编use*_*530的帖子

使用"every"子句时,Let和For之间的xquery结果不同

我有以下Xquery:

let $x := <a>
           <i>false</i>
          </a>
return
    if (every $t in $x/a satisfies $t/i eq "true")
    then $x
    else <nothing/>
Run Code Online (Sandbox Code Playgroud)

我如何理解这一点,$x如果所有人<a>都有一个<i>单词"true" ,则返回.但是,这总是回归$x.

相反,如果我有以下XML文档:

<root>
  <a><i>false</i></a>
</root>
Run Code Online (Sandbox Code Playgroud)

以及以下查询:

for $x in /root
return
    if (every $t in $x/a satisfies $t/i eq "true" )
    then $x
    else <nothing/>
Run Code Online (Sandbox Code Playgroud)

它将<nothing/><i>包含false时返回$x,<i>并在"true" 时返回

我的问题是:

  1. 为什么带"let"的查询的行为方式如此?
  2. 为什么"for"的查询行为不同?

xml xquery

3
推荐指数
1
解决办法
199
查看次数

标签 统计

xml ×1

xquery ×1