你如何在XQuery中打开一个字符串?

Six*_*Bit 12 xml xquery case switch-statement

我有一个外部变量作为字符串,我想在它上面做一个开关/案例.我如何在xquery中做到这一点?

小智 23

从XQuery 1.1开始,使用switch:

http://www.w3.org/TR/xquery-11/#id-switch

switch ($animal) 
   case "Cow" return "Moo"
   case "Cat" return "Meow"
   case "Duck" return "Quack"
   default return "What's that odd noise?" 
Run Code Online (Sandbox Code Playgroud)