I think Xquery has not the "AND" operator and i cant do this:
if开发者_StackOverflow社区 node1 = xxx and node2 = yyy and node3 = zzz then replace node3 with www
XQuery has And Operator which is "and". it has OR operator also "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()
http://x-query.com/pipermail/talk/2004-November/000358.html
<<
There's no such operator as "&="
in XQuery. I think you need the
contains() function instead, although you might want matches().
So I think your query should look like:
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 (
...
)
精彩评论