- From: Adam Retter <adam@exist-db.org>
- Date: Wed, 12 Oct 2016 13:19:25 -0400
- 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: declare %private %local:adam function local:some-function($x as xs:string, $y as xs:int+) as element() { <something/> }; inspect:inspect-function(local:some-function#2) results in: <function name="local:some-function" module="http://www.w3.org/2005/xquery-local-functions"> <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" namespace="http://www.w3.org/2005/xpath-functions"/> <annotation name="local:adam" namespace="http://www.w3.org/2005/xquery-local-functions"/> </function> 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 } adam@exist-db.org irc://irc.freenode.net/existdb
Received on Wednesday, 12 October 2016 17:19:58 UTC