Switch Expression

The Switch Expression is a welcome addition to the XML Query Language. This example presents its potential.

xquery version "3.0"; let $animal := "Cat" return switch ($animal) case "Cow" case "Calf" return "Moo" case "Cat" return "Meow" case "Duck" return "Quack" default return "What's that odd noise?"

returns

Meow

Note the sequence of switch case clauses

case "Cow" case "Calf" return "Moo"
sharing the same return expression.

The expression is available starting eXist-db 1.5