小编jon*_*ong的帖子

XQuery计数器里面的for

假设我有以下XQuery代码:

   for $y in doc("file.xml")/A/B

        for $x in $y/C where $x/constraint1 != "-" and $x/constraint2 > 2.00
            do stuff 
Run Code Online (Sandbox Code Playgroud)

我可以使用计数器来计算我的代码在第二个for循环中输入的数量吗?我试过这个:

   for $y in doc("file.xml")/A/B
       let $i := 0
        for $x in $y/C where $x/constraint1 != "-" and $x/constraint2 > 2.00
            $i := $i + 1
Run Code Online (Sandbox Code Playgroud)

但是我遇到了编译错误.我还需要总结一些这样的约束:

   for $y in doc("file.xml")/A/B
       let $i := 0
       let $sum := 0
        for $x in $y/C where $x/constraint1 != "-" and $x/constraint2 > 2.13
            $i := $i + 1
            $sum := $sum + $x/constraint2 …
Run Code Online (Sandbox Code Playgroud)

xml counter xquery

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

counter ×1

xml ×1

xquery ×1