Author: Reece H. Dunn. 67 Bricks.
This proposal adds annotation signatures to the XQuery type system.
It is not currently possible to access annotation information for a function in XQuery. Adding support for that to the XQuery Functions and Operators would need a way of specifying the annotations in return and parameter types, and thus be describable in the type system.
The new annotation types may also be used when specifying the type of the proposed annotation declarations.
The annotation type is modelled on the FunctionTest syntax. Annotation types cannot have a return type. For example:
annotation(*)%compatibility-annotation annotation()annotation(xs:string)annotation(variadic array(xs:string))-- using the syntax from the variadic function parameter proposal.
The type matching rules should follow the same logic as matching functions, excluding the return type.
The type of an Annotation will be as follows:
- The number of parameter types will match the number of arguments the annotation is called with.
- If a parameter is a
StringLiteral, it will have the typexs:string. - If a parameter is a
DoubleLiteral, it will have the typexs:double. - If a parameter is a
DecimalLiteral, it will have the typexs:decimal. - If a parameter is a
IntegerLiteral, it will have the typexs:integer.
The type of an annotation declaration will match the type signature for that declaration.
The type of a named annotation reference will be the type signature of the matching annotation declaration.
If a named annotation reference refers to a variadic function parameter (if that proposal is accepted), the reference will refer to the expanded non-variadic signature, and the parameters after the last non-variadic parameter will have the type specified in the ArrayTest or item() if a type is not specified.
Provide access to annotations in the XQuery code.
Make the XQuery type system more complete by making annotations part of the data model.
let $post as annotation()? := annotation-for-function($f, %rest:POST#1)
return exists($post)
TBD.