我遇到以下問題,並且語法明智我不知道爲什麼我得到我得到的結果。XQuery!=運算符與序列
我有以下FLOWR表達:
(: example 1 :)
for $attr in $node/@*
where $attr/fn:local-name != ("src", "type", "id")
return $attr
這個英文版本在我心目中是:Get me all the attributes that are not src, type, or id
。
但是,當我運行這個,每個屬性被返回,包括src, type, and id
。當我將where
聲明更改爲只包含一個元素where $attr/fn:local-name != ("src")
時,則按預期工作 - 將返回除src
之外的所有屬性。奇怪的是,它與一個元素比較起作用,但不是三個。
如果我扭轉我的邏輯,並作出這樣的聲明:
(: example 2 :)
for $attr in $node/@*
where $attr/fn:local-name = ("src", "type", "id")
return $attr
(: difference is = instead of != :)
然後我也,我得到的結果我想到,這僅僅是3個屬性"src", "type", and "id"
,而不是其他。
所以,回到我原來的情況下,爲了得到它的工作,我期待的樣子,我必須使用以下的語句:
(: example 3 :)
for $attr in $node/@*
where fn:not($attr/fn:local-name = ("src", "type", "id"))
return $attr
這將返回除了src, type, and id
所有屬性。
這是怎麼發生的呢?在我看來,示例1和示例3應該做同樣的事情。但是,我無法獲得示例1以我期待的方式工作。
的XPATH相當於我的問題類似如下:
$node/@*[fn:not(./fn:local-name(.) = ("src", "type", "id"))]
任何人都可以解釋在我的想法是錯誤的?我正在使用xquery version "1.0-ml"
。