Hi Jerome, correct me if I am wrong, but I think there is a problem with the static type inference rules in Section 8.2.3.1.1 (Name Tests). Consider the expression $v/self::foo and $v has the static type `element *' (we know it's exactly one element, but we don't know its name). The Formal Semantics essentially depends on two judgments to derive the result type of this expression: axis self:: of element * : element * (Sect. 8.2.2.1.2) then test foo with element of element * : element foo . The latter is a rule in Section 8.2.3.1.1 where we perform a (non-wildcard) name test on an element type with a wildcard name: -------------------------------------------------------------------------------- test QName2 with element of element * OptTypeSpec : element QName2 OptTypeSpec I think a `?' occurrence indicator is missing here. If $v in the above example is a `foo' element, the result type is indeed `element foo'. But if $v carries a different name (say, `bar') the path step will return the empty sequence (which would not be permitted by the above static typing rule). The same problem arises also in some of the remaining judgments in Section 8.2.3.1.1.
The fix for this bug does not appear in the Recommendation of 23 January 2007. It will be considered for a future publication (either an Errata document or some possible future version of the specification).
I agree with the original comment. Specifically, we need to append a '?' to the conclusion of rules 2, 5, 7, 10, 13, and 15 (i.e., the rules with "element * OptTypeSpecifier" or "attribute * OptTypeReference"). (You might think that rules 3 and 11 would also be affected, but they'll be deleted pursuant to Bug 3269.)
The working groups have approved the solution given in Comment #2. Consequently, I am marking this bug FIXED. Please indicate your acceptance of this resolution by marking the bug CLOSED.
The solution looks fine to me. Thanks!
*** Bug 4581 has been marked as a duplicate of this bug. ***
This issue has been incorporated into FS erratum E018, whose fix has been committed to the source files for the next edition of the FS document.