我认为Xquery没有“AND”运算符,我不能这样做:
如果 node1 = xxx 且 node2 = yyy 且 node3 = zzz 则将node3替换为www
答案 0 :(得分:6)
XQuery和And运算符是“和”。它还有OR运算符“或”。
let $d := <Employee>
<Name>Test</Name>
<ID>1909239</ID>
<Address>test Add </Address>
<Email>test@test.net</Email>
<Department>Dept 1</Department>
<Department>Dept 2</Department>
<Department>Dept 3</Department>
<Department>Dept 4</Department>
<Department>Dept 5</Department>
return if( ($d//*:Department[1]/text() = 'Dept 1') and ($d//*:Department[1]/text() = 'Dept 2') ) then fn:true() else fn:false()
答案 1 :(得分:0)
http://x-query.com/pipermail/talk/2004-November/000358.html
&LT;&LT;
XQuery中没有"&="
这样的运算符。我想你需要的
而不是contains()函数,尽管你可能想要匹配()。
所以我认为你的查询应该是这样的:
let $query :=
if ($ttl != "") then (
for $entries in collection($collctn)//TEI.2
[contains(., $kwds) and
descendant::head[contains(., $ttl)]
return (
if ($entries/@id = "ppp.00271") then (
...
)
else if ($entries/@id = "ppp.00237") then (
...
)
else if ($entries/@id = "ppp.00473") then (
...
)
else (
...
)
)
else if (...) then (
...
)
else (
...
)