W3C home > Mailing lists > Public > public-xsl-query@w3.org > October 2016

Re: Function annotations

From: Adam Retter <adam@exist-db.org>
Date: Wed, 12 Oct 2016 13:19:25 -0400
Message-ID: <CAJKLP9bJrP-B5OCZxMbGgfnVqenxiF4A_79OD=uVQjxgtAsaWw@mail.gmail.com>
To: Michael Kay <mike@saxonica.com>
Cc: Public Joint XSLT XQuery XPath <public-xsl-query@w3.org>
> 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!).

See: http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/inspection&location=java:org.exist.xquery.functions.inspect.InspectionModule#inspect-function.1

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:43:20 UTC