Hi Sudheshna, How about an XQuery 3.0 switch (http://www.w3.org/TR/xquery-30/#id-switch)? Like so: switch(data($code)) case "ONE" return <tns:ONE/> case "TWO" return <tns:TWO/> default return () I hope this helps? Kind regards, Ghislain