Re: Function annotations

The eXist variant is inspect:inspect-function():

```
xquery version "3.1";

declare %private %rest:query-param("client", "{$client}", "unknown")
function local:f() { 'well hidden' };

inspect:inspect-function(local:f#0)
```

returns:

<function name="local:f" module="http://www.w3.org/2005/xquery-local-functions">
    <returns type="item()" cardinality="zero or more"/>
    <annotation name="private"
namespace="http://www.w3.org/2005/xpath-functions"/>
    <annotation name="rest:query-param"
namespace="http://exquery.org/ns/restxq">
        <value>client</value>
        <value>{$client}</value>
        <value>unknown</value>
    </annotation>
</function>

The full function documentation for this module is at:

  http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/inspection

On Wed, Oct 12, 2016 at 8:32 AM, Christian Grün
<christian.gruen@gmail.com> wrote:
>> > I don't think it relies on the annotations being ordered.
>>
>> Exactly, the order is arbitrary.
>>
>> This is the function provided by BaseX:
>>
>> http://docs.basex.org/wiki/Inspection_Module#inspect:function-annotations
>>
>>
>>
>> > Michael Kay
>> > Saxonica
>> >
>> >
>> > > On 12 Oct 2016, at 11:08, Michael Kay <mike@saxonica.com> wrote:
>> > >
>> > > Note that in XSLT, the nearest equivalent to XQuery's function
>> > > annotations would be user-defined attributes on an xsl:function element. In
>> > > this case it would definitely be the case that the annotations have distinct
>> > > names and are unordered.
>> > >
>> > > We need to maintain the principle that the data model is common
>> > > between XSLT and XQuery.
>> > >
>> > > Michael Kay
>> > > Saxonica
>> > >
>> > >
>> > >> On 12 Oct 2016, at 11:00, Michael Kay <mike@saxonica.com> wrote:
>> > >>
>> > >> I've had input from a user who wants to get information about the
>> > >> annotations on a function.
>> > >>
>> > >> Annotations don't seem to be part of the data model for function and
>> > >> we don't have any accessor functions that reveal the values of 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.
>> > >>
>> > >> So, a question: is it by design or by accident that we don't have any
>> > >> rule prohibiting multiple annotations on a function with the same name?
>> > >>
>> > >> If we do allow it, is the order significant? Would you expect the
>> > >> order in which annotations appear to be retained in such an API?
>> > >>
>> > >> Michael Kay
>> > >> Saxonica
>> > >>
>> > >
>> > >
>> > >
>> >
>> >
>> >

Received on Tuesday, 25 October 2016 18:51:32 UTC