XQuery 4.0 example in fiddle with syntax no longer allowed

Friday, 30 October 2026 · 2 messages
MH
Martin Honnen30 Oct 2026 16:58 #

The BaseX fiddle has an XQuery 4 example "error handling" having

declare function local:divide($a, $b) {
   if ($b = 0) {
     error(xs:QName('local:div-zero'), 'Division by zero', $a)
   } else {
     $a div $b
   }
};

that I also tried with Saxon 13.1 EE (where it doesn't work) and Michael Kay explained me that

if (condition) { then-expression } else { else-expression }

is not allowed, only

if (condition) { then-expression }

I guess you are aware of that and are going to correct the example once BaseX implements the current version of XQuery 4.0. Or are you keeping that

if (condition) { then-expression } else { else-expression }

in BaseX despite https://github.com/qt4cg/qtspecs/pull/1712?

CG
Christian Grün30 Oct 2026 18:24 #

Hi Martin,

Thanks, I’ve updated the examples. See [1] for more details on BaseX.

Best, Christian

[1] https://docs.basex.org/main/XQuery_Extensions

Quoted text · Martin Honnen · 26 lines
> The BaseX fiddle has an XQuery 4 example "error handling" having > > declare function local:divide($a, $b) { > if ($b = 0) { > error(xs:QName('local:div-zero'), 'Division by zero', $a) > } else { > $a div $b > } > }; > > that I also tried with Saxon 13.1 EE (where it doesn't work) and Michael > Kay explained me that > > if (condition) { then-expression } else { else-expression } > > is not allowed, only > > if (condition) { then-expression } > > > I guess you are aware of that and are going to correct the example once > BaseX implements the current version of XQuery 4.0. Or are you keeping that > > if (condition) { then-expression } else { else-expression } > > in BaseX despite https://github.com/qt4cg/qtspecs/pull/1712?

⚡Generated with XQuery