<p>I have an external variable coming in as a string and I would like to do a switch/case on it. How do I do that in xquery?</p>

XQuery doesn't have a function for switching on anything other than elements.
The first thing you do is convert your string to an element.
```
```
let $str := "kitchen"
let $room := element {$str} {}
```
```
Then just use typeswitch to do a normal switch:
```
```
return typeswitch($room)
  case element(bathroom) return "loo"
  case element(kitchen) return "scullery"
  default return "just a room"
```
```
Please note, this may be a MarkLogic only solution.