Re: Function annotations

> My first thought is that it's easy enough to meet this requirement with an extension function, and the obvious one would be something like
> function-annotations($f as function()) as map{xs:QName, item()*}
> But the same user points out that Saxon isn't allowing several annotations on a function with the same name, although the spec appears to permit this. If the data model allows several annotations with the same name then this complicates the API.

For reference:

In eXist we have a reflection module, this is something that could
most likely be abstracted into a better module in the EXPath project
context if desirable. The function we use in eXist looks like:

inspect:inspect-function($function as function() as item()*) as node()

So for example:

function local:some-function($x as xs:string, $y as xs:int+) as element() {


results in:

<function name="local:some-function"
    <argument type="xs:string" cardinality="exactly one" var="x"/>
    <argument type="xs:int" cardinality="one or more" var="y"/>
    <returns type="element()" cardinality="exactly one"/>
    <annotation name="private"
    <annotation name="local:adam"

Personally I don't like how we express the cardinality and the
name/namespace stuff (but hey, I didn't implement this one!).


Perhaps the W3C XQuery WG feels however that they could complement say
fn:function-name($function) with a fn:function-annotations($function)
or similar, you might also want something to find the annotations on a
variable, however I am not sure how that would work as there is no
such thing as a reference to a variable.

...Any way just some thoughts that might help inform direction

Adam Retter

eXist Developer
{ United Kingdom }

Received on Wednesday, 12 October 2016 17:19:58 UTC