qt4cg / qtspecs

QT4 specifications
https://qt4cg.org/
Other
28 stars 15 forks source link

Annotations: duplicate names #1391

Closed michaelhkay closed 1 day ago

michaelhkay commented 3 weeks ago

The function fn:function-annotations returns a map from QNames to values, which rather assumes that a function cannot have two annotations with the same name. But there is nothing in either the data model or the XQuery language spec that imposes this restriction.

michaelhkay commented 3 weeks ago

I propose that (a) in the data model, two annotations cannot have the same name, but (b) writing %a(v1) %a(v2) is allowed and is deemed equivalent to writing %a(v1, v2) - that is, it creates a single annotation.

Further observation: XQuery says "If the namespace URI of an annotation is not recognized by the implementation, then the annotation is ignored." I propose changing this so that the annotation has no effect other than to retain the value and make it visible via the fn:function-annotations function.

ChristianGruen commented 3 weeks ago

I’m ashamed to have overlooked that: It’s indeed fairly common for annotations to have the same name, and it’s important to not throw the values together. The most prominent example may be RESTXQ with its query and form parameters:

https://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-specification.html#example-query-parameter-annotation-with-a-default-value

I think we’ll need to change the function definition and return the annotation values as array(s).