An interesting variation on the common theme of "I want to construct an XPath expression as a string at run-time". You can do that with extensions such as saxon:evaluate(), but not with standard XSLT.
However, since there are only two variations here, you could do
Code:
test="($op='and' and @keyword=$field1 and @keyword=$field2) or
($op='or' and (@keyword=$field1 or @keyword=$field2))"