generalize the boolean expression wml handler code

WIP