saxon:function-annotations

Returns the XQuery function annotations defined on a function item.

function-annotations($fn as function(*)) ➔ map(*)*

Arguments

 

$fn

function(*)

The function item in question

Result

map(*)*

Namespace

http://saxon.sf.net/

Saxon availability

Requires Saxon-PE or Saxon-EE. Implemented since Saxon 9.8.

Notes on the Saxon implementation

Available since Saxon 9.8.

Details

This function returns the function annotations present on an XQuery function declaration. If the function has no annotations, it returns an empty sequence.

The result sequence contains one item for each function annotation present on the supplied function. This information is provided in the form of a map, with two entries. The entry with key "name" holds the name of the annotation, as an xs:QName value. The entry with key "params" holds the values of the parameters of the annotation, as a sequence of atomic values.

For example, if the function is declared as:

declare namespace a="http://a.com/"; declare %a:colour("blue", 3) function local:f() as xs:integer {3};

then the function call saxon:function-annotations(local:f#0) returns a sequence containing a single map of the form:

map{"name": QName("http://a.com/", "colour"), "params": ("blue", 3)}

Function annotations are retained (as required by the W3C specification) when a function is coerced as a result of type-checking. Annotations are also retained when functions are partially applied.