簡體   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