2

I am reading the W3C Recommendation for XQuery 3.0. Here is what I tried to do:

try {
   3 div 0
} catch err:XPTY0004{
   'typing error'
} catch * {
   $err:code || '
' ||
   $err:description || '
' ||
   $err:value || '
' ||
   $err:module || '
' ||
   $err:line-number || '
' ||
   $err:additional
}

When trying to save the file, Altova XMLSpy gave me an error: Undefined namespace prefix 'err'.

How should I go about defining err first to make it work?

Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100

1 Answers1

8

By default, the err prefix is not bound to any namespace, so you need to explicitly declare it in the query dialog:

declare namespace err = "http://www.w3.org/2005/xqt-errors";
try { 3 div 0 } catch err:FOAR0001 { 'gotcha' }

In some query processors, this prefix is predeclared.

Christian Grün
  • 6,012
  • 18
  • 34