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 13760 - Handling of open contents in complex type extension
Summary: Handling of open contents in complex type extension
Status: CLOSED FIXED
Alias: None
Product: XML Schema Test Suite
Classification: Unclassified
Component: Saxon tests (show other bugs)
Version: 2006-11-06
Hardware: PC Windows XP
: P2 normal
Target Milestone: XSD 1.1 PR
Assignee: C. M. Sperberg-McQueen
QA Contact: XML Schema Test Suite mailing list
URL:
Whiteboard:
Keywords: needsAgreement
Depends on:
Blocks:
 
Reported: 2011-08-11 16:00 UTC by Sandy Gao
Modified: 2011-10-21 16:38 UTC (History)
2 users (show)

See Also:


Attachments

Description Sandy Gao 2011-08-11 16:00:54 UTC
Schema "saxonData/Open/open031.xsd" in test "open031" (expected to be valid) has:

  <xs:defaultOpenContent mode="suffix" appliesToEmpty="false">
    <xs:annotation/>
    <xs:any namespace="http://nonempty.com/" processContents="lax"/>
  </xs:defaultOpenContent>

  <xs:complexType name="B">
    <xs:openContent mode="interleave">
       <xs:any namespace="http://open.com/" processContents="lax"/>
    </xs:openContent>
    <xs:sequence>
      <xs:element name="a" maxOccurs="unbounded"/>
      <xs:element name="b" minOccurs="0"/>
      <xs:element name="c" minOccurs="0"/>
      <xs:element name="d" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="R">
    <xs:complexContent>
      <xs:extension base="B">
        <xs:sequence/>
      </xs:extension>
    </xs:complexContent>  
  </xs:complexType>  

Note that type "R" gets both the default open content and the inherited open content from the base type. The 2 open contents are merged where "mode" comes from the default open content "suffix". Now "R" has "suffix" open content but "B" has "interleave", causing the schema to be invalid.

Either changing "suffix" to "interleave" on the default open content, or adding an explicit "mode=none" open content to "R", will make the schema valid, and will work with the accompanying instance tests.

It may be useful to add a negative test using the current form of this schema.
Comment 1 Sandy Gao 2011-08-11 17:34:36 UTC
A similar test is "open032" with schema "saxonData/Open/open032.bad.xsd". This is expected to be invalid, and contains:

<!-- invalid complex type extension: base type allows open content, extended type does not -->

  <xs:complexType name="B">
    <xs:openContent mode="interleave">
       <xs:any namespace="http://open.com/" processContents="lax"/>
    </xs:openContent>
    <xs:sequence>
      <xs:element name="a" maxOccurs="unbounded"/>
      <xs:element name="b" minOccurs="0"/>
      <xs:element name="c" minOccurs="0"/>
      <xs:element name="d" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="R">
    <xs:complexContent>
      <xs:extension base="B">
        <xs:openContent mode="none"/>
        <xs:sequence/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

Because "R" has a "none" open content, it inherits from "B", and the comment "base type allows open content, extended type does not" is not true.
Comment 2 David Ezell 2011-10-07 16:07:28 UTC
Discussed on telcon 2011-10-07
Comment 3 Michael Kay 2011-10-10 15:09:17 UTC
The former test open031 has been renamed open046 and is now expected to be invalid.

Test open031 has been made valid by adding an explicit "mode=none" open content to "R"

(the intention of the test was related to the use of appliesToEmpty="false", but this is actually irrelevant since R is only locally empty.)

open032 has been modified to test the intended condition in a different way.
Comment 4 Sandy Gao 2011-10-10 19:18:21 UTC
> open032 has been modified to test the intended condition in a different way.

Trying to understand what constraint is violated by open032. It now has

        <xs:openContent mode="interleave">
          <xs:any notNamespace="http://open.com/"/>
        </xs:openContent>  

which will be merged with the base open content

    <xs:openContent mode="interleave">
       <xs:any namespace="http://open.com/" processContents="lax"/>
    </xs:openContent>

to form an "interleave" open content that allows all namespaces. This satisfies the relevant bullets in

http://www.w3.org/TR/xmlschema11-1/#cos-ct-extends

1.4.3.2.2.3 One or more of the following is true:
1.4.3.2.2.3.1 B.{content type}.{open content} (call it BOT) is 
Comment 5 Michael Kay 2011-10-17 17:17:25 UTC
Saxon is getting this wrong. It reports:

Error in open032.bad.xsd:
  Invalid extension. The open content wildcard of the base type of type R is not a subset of
  the open content wildcard of the extended type.

This is a reference to derivation valid (extension) clause 1.4.3.2.2.4.

Saxon is incorrectly testing that the wildcard specified for B is a subset of the wildcard specified for R, whereas it should be testing that the wildcard specified for B is a subset of the computed wildcard for R, which is the union of the wildcards specified for R and B. In fact, it appears that the rule in 1.4.3.2.2.4 is never violated for components constructed from schema documents.

I have removed test open032 from the test set.

I have added a new test open047 based on this schema, with examples of valid and invalid instances.