Hi Markus,
I became curious if this development situation will be improved further.
Who would you expect to improve that? Are you thinking of the developers of the official W3 recommendations or the developers of BaseX?
The other XQuery rule that applies to your examples is that: if there is only one expression in main or a function body then the keyword "return" is omitted
Which specification from the standard does support this implementation detail?
Please note that, for the sake of simplicity, you can regard the term "specification" as synonym for "standard" (or "recommendation", as the W3 calls its documents).
The "return" keyword is part of the so-called FLWOR expression [1,2]. As Andy stated, "return" won’t be accepted if you have a single expression. The following expressions are both valid XQuery expressions:
(: FLWOR expression :) let $a := 'abcde' return $a
(: Simple expression :) 'abcde'
The following expression …
"return 'abcde'
… is illegal, as the grammar of the XQuery language does not accept this construct. The same applies to semicolons: They are not defined in XQuery.
Should the shown annotation be replaced by a standard keyword for the function declaration? https://www.w3.org/TR/2011/REC-xquery-update-10-20110317/#id-function-declar...
Both "updating" and "%updating" can be used. The annotation was introduced with XQuery Update 3.0 [3], but BaseX still supports the "updating" keyword as legacy feature.
Is this a tool-specific setting? https://docs.basex.org/wiki/XQuery_Update#User-Defined_Functions
The support for the invocation of dynamic functions is another feature that is only supported since version 3 of the specification. To be strict, the finalized version of the spec woud require the "updating" keyword to be prepended by an additional "invoke" keyword [4]. We should add that in BaseX as well. I believe, though, that there is actually no implementation out there yet that can handle the "invoke" keyword, and that provides the full range of the latest version.
Function items are a rather advanced feature of XQuery. If you are still a beginner, it’s advisable to stick with conventional functions and function declarations (the ones you used in your first example), as they are easier to use and understand.
Best, Christian
[1] https://www.w3.org/TR/xquery-31/#id-flwor-expressions [2] https://docs.basex.org/wiki/XQuery_3.0#Enhanced_FLWOR_Expressions [3] https://www.w3.org/TR/xquery-update-30/ [4] https://www.w3.org/TR/xquery-update-30/#id-dynamic-updating-function-invocat...