In C, if you find yourself writing large switch statements (or rafts of if statements), you should consider using pointers to functions instead. In C++, if you find yourself writing large switch statements (or rafts of if statements), you should consider using objects and polymorphism instead. In XQuery, If you find yourself writing large typeswitch…