This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27175 - subtype-itemtype
Summary: subtype-itemtype
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.1 (show other bugs)
Version: Working drafts
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-26 13:11 UTC by Benito van der Zander
Modified: 2015-07-06 09:07 UTC (History)
3 users (show)

See Also:


Attachments

Description Benito van der Zander 2014-10-26 13:11:26 UTC
>2.5.6.2 The judgement subtype-itemtype(Ai, Bi) 
>Point 14: Bi is either element(Bn) or element(Bn, xs:anyType?), the expanded QName of An equals the expanded QName of Bn, and Ai is either element(An), or element(An, T?) for any type T.

That does not mention the case element(An, T) like some other points (e.g. 16), so element(An, T) would not be a subtype of element(An).

But it seems, it should
Comment 1 Jonathan Robie 2014-10-28 18:49:40 UTC
I suspect you are right, but we want to look at this carefully. 

You claim this: 

element(An, T) would not be a subtype of element(An)

That would be a bug. This is equivalent to saying that the following judgement returns false in http://www.w3.org/TR/2014/WD-xquery-31-20140424/#id-itemtype-subtype:

subtype-itemtype( element(An,T), element(An))

Ai = element(An,T)
Bi = element(An)

Rule 14 is the only one that can match this case:

<quote>
14. Bi is either element(Bn) or element(Bn, xs:anyType?), the expanded QName of An equals the expanded QName of Bn, and Ai is either element(An), or element(An, T?) for any type T.
</quote>

Let's review the meaning of the syntax for the two element tests according to http://www.w3.org/TR/2014/WD-xquery-31-20140424/#id-element-test :

<quote>
3. element( ElementName , TypeName ) matches an element node whose name is ElementName if derives-from( AT, TypeName ) is true, where AT is the type annotation of the element node, and the nilled property of the node is false.

Example: element(person, surgeon) matches a non-nilled element node whose name is person and whose type annotation is surgeon (or is derived from surgeon).

4.  element( ElementName, TypeName ?) matches an element node whose name is ElementName if derives-from( AT, TypeName ) is true, where AT is the type annotation of the element node. The nilled property of the node may be either true or false.

Example: element(person, surgeon?) matches a nilled or non-nilled element node whose name is person and whose type annotation is surgeon (or is derived from surgeon).
</quote>
Comment 2 John Snelson 2014-11-18 17:30:55 UTC
Having looked over the spec, I think this bug makes a valid point and this needs fixing.
Comment 3 Michael Kay 2014-11-20 11:51:05 UTC
I think Benito is correct in the sense that rule 14 is incomplete. However, I think the missing case is covered by rule 16:

16. Bi is element(Bn, Bt?), the expanded QName of An equals the expanded QName of Bn, Ai is either element(An, At) or element(An, At?), and derives-from(At, Bt) returns true.

If we set Bt = xs:anyType, then for any type T we know that derives-from(At, Bt) is true, so rule 16 becomes

16a. Bi is element(Bn, xs:anyType?), the expanded QName of An equals the expanded QName of Bn, Ai is either element(An, T) or element(An, T?) for any type T

which is identical to the amended rule 14 proposed by Benito. Except that rule 14 also covers the case where there is no type name.

I think therefore that rule 14 could be replaced with the rule

14. Bi is element(N), and Ai is either element(N) or element (N, T) or element(N, T?), where N is any QName and T is any schema type.

leaving rule 16 to take care of the case element(Bn, xs:anyType?).

Note, I've simplifed the rule by assuming that we can take it as read that the QName N can be written in different ways and still be the same QName - but perhaps we shouldn't do that here unless we do it throughout all the rules.
Comment 4 Michael Kay 2014-11-20 14:41:50 UTC
I got that wrong. 

The reason rule 14 covers the element(B, xs:anyType?) case is that we want to make element(N) a subtype of element(N, xs:anyType?), which would not be the case under rule 16 alone.

So I think the lowest-risk fix, as suggested, is to change rule 14 as suggested to say:

14. Bi is either element(Bn) or element(Bn, xs:anyType?), the expanded QName of An equals the expanded QName of Bn, and Ai is either element(An) or element(An, T) or element(An, T?) for any type T.
Comment 5 Andrew Coleman 2014-11-28 14:06:05 UTC
The working group decided on the following resolution at the 2014-11-25 teleconference:

RESOLVED: to address bug 27175 by making the change proposed in
comment 4.
Comment 6 Michael Kay 2015-07-06 09:07:16 UTC
Confirmed that the proposed change has been applied in the current draft.