Ok, this is probably a very idiot question, but I can't really find a way to fix it: I have this query with parameters A, B and C. All of them are optional. The behavior I'm looking for us: if client submits parameter A, then do the search based in A. If client submits parameter B, then do the search based in B, and so forth. If client submits more then one parameter, then the precedence order is A > B > C. And if client submits no parameter, return nothing at all. This would be simply accomplished with some conditional logic but I have no idea how to implement it in xquery. Any help is appreciated.