Skip to content

Commit

Permalink
1649-fix-result-of-function-annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Dec 19, 2024
1 parent 31452ec commit c2ce1cc
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20585,7 +20585,7 @@ return function-arity($initial)</eg></fos:expression>

<fos:function name="function-annotations" prefix="fn">
<fos:signatures>
<fos:proto name="function-annotations" return-type="record(key as xs:QName, value as xs:anyAtomicType*)*">
<fos:proto name="function-annotations" return-type="map(xs:QName, xs:anyAtomicType*)*">
<fos:arg name="function" type="fn(*)"/>
</fos:proto>
</fos:signatures>
Expand All @@ -20599,25 +20599,23 @@ return function-arity($initial)</eg></fos:expression>
</fos:summary>
<fos:rules>
<p>The <code>fn:function-annotations</code> function returns the annotations of
<code>$function</code> as a sequence of (key, value) pairs.
<code>$function</code> as a sequence of singleton maps, each associating
the name of a function annotation with the value of the annotation.
Note that several annotations on a function can share the same name. The order
of the annotations is retained.</p>
<p>The result is a sequence of maps, each being an instance of
<code>record(key as xs:QName, value as xs:anyAtomicType*)</code>.
<p>The result is a sequence of singleton maps, each being an instance of
<code>map(xs:QName, xs:anyAtomicType*)</code>.
If a function (for example, a built-in function) has no annotations,
the result of the function is an empty sequence.</p>
<p>For each annotation, a map is returned, with two entries. One
entry has the key <code>"key"</code> as an <code>xs:string</code>, with the associated
value being the name of the annotation as an <code>xs:QName</code>.
The other has the key <code>"value"</code> as an <code>xs:string</code>, with the
associated value being the value of the annotation as a sequence of atomic items.
<p>For each annotation, a map is returned, with a single entry. The
key of the map entry is the name of the annotation as an <code>xs:QName</code>.
The value of the entry is the the value of the annotation as a sequence of atomic items.
If the annotation has no values, the associated value is an empty sequence.</p>
</fos:rules>
<fos:notes>
<p>The type of the result is the same as the type of the first argument
to the <code>map:of-pairs</code> function. This means that in the common case where the annotation names are all unique,
the result of the function can readily be converted into a map by calling
<code>map:of-pairs</code>.</p>
<p>In the common case where the annotation names are all unique,
the result of the function can readily be converted into single map by applying the function
<code>map:merge</code>.</p>
</fos:notes>
<fos:examples>
<fos:example>
Expand All @@ -20631,9 +20629,7 @@ return function-arity($initial)</eg></fos:expression>
<fos:expression><eg>
declare %private function local:inc($c) { $c + 1 };
function-annotations(local:inc#1)</eg></fos:expression>
<fos:result><eg>{ "key": QName("http://www.w3.org/2012/xquery", "private"),
"value": ()
}</eg></fos:result>
<fos:result><eg>{ QName("http://www.w3.org/2012/xquery", "private"), () }</eg></fos:result>
</fos:test>
</fos:example>
<fos:example>
Expand Down

0 comments on commit c2ce1cc

Please sign in to comment.