Changes

Jump to navigation Jump to search
529 bytes added ,  15:01, 12 January 2011
no edit summary
The [http://www.w3.org/TR/xquery-30/#id-try-catch try/catch] construct can be used to handle errors at runtime:
'''Example:'''
<pre class="brush:xquery"> try {
concat('Error [', $code, ']: ', $desc)
}</pre>
'''Result:''' <code>Error [XPTY0004]: '+' operator: number expected, string found.</code>
 
==Switch==
 
The [http://www.w3.org/TR/xquery-30/#id-switch switch] statement is available in many other programming languages. It chooses one of several expressions to evaluate based on its input value.
 
'''Example:'''
<pre class="brush:xquery">
for $fruit in ("Apple", "Pear", "Peach")
return switch ($fruit)
case "Apple" return "Red"
case "Pear" return "Green"
case "Peach" return "Pink"
default return "Unknown"
</pre>
'''Result:''' <code>Error [XPTY0004]: '+' operator: number expected, string found.</code>
[[Category:XQuery]]
[[Category:Finish]]
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu