tags:

views:

33

answers:

2

I think Xquery has not the "AND" operator and i cant do this:

if node1 = xxx and node2 = yyy and node3 = zzz then replace node3 with www

A: 

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 ( ... )

Pak Choi
+1  A: 

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>[email protected]</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()
kadalamittai
This coded tested against MarkLogic Server. but XQuery is set to W3C standards.
kadalamittai