XQuery 是否有 FLWOR 表达式的退出语句
我想知道 xquery FLWOR 表达式是否有像 continue 和 break 这样的退出语句?
例如,我想在达到特定条件时退出 for 循环。
I would like to know if xquery FLWOR expression has an exit statement like continue and break?
For example I want to exit the for loop when a particular condition is reach.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
XQuery 是一种函数语言,这意味着不存在严格的执行顺序概念。因此,当某些事情发生时,任何尝试做特定事情的尝试都是没有意义的。
正确的方法是在满足特定条件的情况下执行某些操作。
除了使用 < 之外,无法退出 FLWOR 表达式code>error() 函数,但这会终止处理。
人们不应该太担心优化——许多处理器都有很好的优化器。
因此,许多处理器将延迟求值,并在第一次产生满足
special-condition()
的结果时停止对下面的 FLOWR 表达式的求值:XQuery is a functional language, which among many other things means that there is no strict concept of order of execution. Therefore any attempts to do something specific when something happens, are not meaningful.
The correct approach is to do something if a specific condition is satisfied.
There is no way to exit a FLWOR expression, other than using the
error()
function, but this terminates processing.One shouldn't worry too much about optimization -- many processors have good optimizers.
Thus many processors will evaluate lazily and will stop the evaluation of the FLOWR expression below, the first time it produces result that satisfies the
specific-condition()
:XQuery Scripting 有一个退出语句:
或者
您可以在 http://www.zorba-xquery.com/html/demo#JvSLsVh3ZjhvTHecVd9jyE1vEBc=
XQuery Scripting has an exit statement:
Or
You can try this example live at http://www.zorba-xquery.com/html/demo#JvSLsVh3ZjhvTHecVd9jyE1vEBc=
虽然这个问题很老了,但我回答它是因为一些新人可能会遇到这种情况并会得到更好的解决方案。
该解决方案可以在 BaseX 7.6 上轻松运行,
输出将为 - 3
或这将生成输出 - 3,
Though the question is quite old, I am answering it as some new people might face such situation and would get a better solution.
This solution would run easily on BaseX 7.6
Output will be - 3
OR this will generate the output - 3,