繁体   English   中英

XQuery使用谓词:return和for之间的区别

[英]XQuery using predicates: difference between return and for

我认为这两个xquery表达式是等效的:

for $x
  in doc("hamlet.xml")//LINE[../SPEAKER = "HAMLET"]
  return $x[../preceding-sibling::SPEECH[1]/SPEAKER = "MARCELLUS"]

for $x
  in doc("hamlet.xml")//LINE[../SPEAKER = "HAMLET"][../preceding-sibling::SPEECH[1]/SPEAKER = "MARCELLUS"]
  return $x

区别在于谓词首先在返回中使用,然后在for中使用。 为什么输出不一样?

https://www.ibiblio.org/xml/examples/shakespeare/hamlet.xml

编辑::我使用BASEX 9.0.1。

他们对我来说看起来一样。

对于第一个查询,撒克逊人给出

<LINE>I am very glad to see you. Good even, sir.</LINE>
<LINE>But what, in faith, make you from Wittenberg?</LINE>
<LINE>Did you not speak to it?</LINE>
<LINE>Arm'd, say you?</LINE>
<LINE>From top to toe?</LINE>
<LINE>Then saw you not his face?</LINE>
<LINE>Hold off your hands.</LINE>
<LINE>How say you, then; would heart of man once think it?</LINE>
<LINE>But you'll be secret?</LINE>
<LINE>There's ne'er a villain dwelling in all Denmark</LINE>
<LINE>But he's an arrant knave.</LINE>
<LINE>Nay, but swear't.</LINE>
<LINE>Upon my sword.</LINE>
<LINE>Indeed, upon my sword, indeed.</LINE>

对于第二个查询,撒克逊人给出:

<LINE>I am very glad to see you. Good even, sir.</LINE>
<LINE>But what, in faith, make you from Wittenberg?</LINE>
<LINE>Did you not speak to it?</LINE>
<LINE>Arm'd, say you?</LINE>
<LINE>From top to toe?</LINE>
<LINE>Then saw you not his face?</LINE>
<LINE>Hold off your hands.</LINE>
<LINE>How say you, then; would heart of man once think it?</LINE>
<LINE>But you'll be secret?</LINE>
<LINE>There's ne'er a villain dwelling in all Denmark</LINE>
<LINE>But he's an arrant knave.</LINE>
<LINE>Nay, but swear't.</LINE>
<LINE>Upon my sword.</LINE>
<LINE>Indeed, upon my sword, indeed.</LINE>

您看到什么区别,并且正在使用什么XQuery实现?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM