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 4467 - Context determined type for complex type with simple content
Summary: Context determined type for complex type with simple content
Status: CLOSED FIXED
Alias: None
Product: XML Schema
Classification: Unclassified
Component: Structures: XSD Part 1 (show other bugs)
Version: 1.1 only
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: C. M. Sperberg-McQueen
QA Contact: XML Schema comments list
URL: http://lists.w3.org/Archives/Member/w...
Whiteboard:
Keywords: resolved
Depends on:
Blocks:
 
Reported: 2007-04-13 15:16 UTC by Sandy Gao
Modified: 2009-04-21 19:21 UTC (History)
0 users

See Also:


Attachments

Description Sandy Gao 2007-04-13 15:16:07 UTC
<xs:complexType name="B" mixed="true">
  <xs:sequence>
    <xs:element name="e" type="xs:int" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="R">
  <xs:simpleContent>
    <xs:restriction base="B">
      <xs:simpleType>
        <xs:restriction base="xs:string"/>
      </xs:simpleType>
    </xs:restriction>
  </xs:simpleContent>
</xs:complexType>

The CDT for "e" in "B" is "xs:int". What's the CDT for "e" in "R". 
Currently it's "absent". Question: should it also be "xs:int" (i.e. 
inherit from "B")?

Some WG members, during the F2F, felt that it should inherit from "B". 
This can be "fixed" by removing "or CTD's {content type} has simple 
{variety}". This is where my Action item came from. We wanted to make sure 
such change wouldn't have any negative impact.

Because one can not derive from a complex type with simple content and add 
element children to it (i.e. go from simple content to complex content), 
whether simple content use absent or inherit doesn't make any difference 
in most cases. The only case it affects (that I can think of now) is the 
following. Consider the above complex types and the following instance:

<p xsi:type="R">
  <e>abc</e>
</p>

Obviously <p> is invalid, because "R" has simple content and doesn't allow 
<e>. But what happens to <e>?

If "R" uses "absent" as CDT for <e>, then as a consequence <e> doesn't 
have a governing type definition. It will be laxly assessed using 
xs:anyType.

But if "R" inherits CDT from "B", then <e> has xs:int as its CDT and 
governing type, and will be flagged invalid because its content "abc" is 
not a valid int.

Which is the right behavior? (I'm leaning a little toward inherit. i.e. 
make the change suggested by this action item.)

[1] 
http://www.w3.org/XML/Group/2004/06/xmlschema-1/structures.html#key-cdt
[2] http://www.w3.org/XML/Group/2007/01/xml-schema-ftf-minutes#fripm.vm3
Comment 1 Sandy Gao 2007-06-27 13:42:40 UTC
The WG discussed this issue at 2007-06-27 F2F meeting, and decided to remove "or CTD's {content type} has simple {variety}", which effectively says that context determined type is always inherited by derived types.
Comment 2 C. M. Sperberg-McQueen 2007-08-02 00:11:14 UTC
The repair agreed on in June has been included in the current status-quo
version of the spec at http://www.w3.org/XML/Group/2004/06/xmlschema-1/structures.html

So I'm changing this from 'decided' to 'resolved'.