Re: mixed attribute on complexType/complexContent

Hi,

Michael Kay wrote:
> In 3.4.2 teh mapping table for complex content shows:
> 
> {content type}	
> 1 [Definition:]  Let the effective mixed be the appropriate case among the
> following:
> 1.1 If the mixed [attribute] is present on <complexContent>, then its
> .actual value.;
> 1.2 If the mixed [attribute] is present on <complexType>, then its .actual
> value.;
> 1.3 otherwise false.
> 
> In 3.4.3, Constraints on XML Representations of Complex Type Definitions,
> there doesn't seem to be a rule prohibiting <complexType mixed="true"> with
> <complexType mixed="false">, or vice versa.

Hmm, it seems that the complexContent/simpleContent overrides the
complexType regarding the 'mixed' value. The reason might be that the
'mixed' on complexType was invented only to allow setting it if using
the shorthand form of complexContent, i.e. not specifying the
complexContent at all.

> Does this mean that if the mixed attribute is present on complexContent, the
> value of the mixed attribute on complexType is ignored, and no error occurs
> if they are inconsistent?

It's a 'no effect' attribute in this case, comparable to:

3.4.3 (2.2)
"... specifying <xs:complexType . . .mixed='true' when the
<simpleContent> alternative is chosen has no effect on the corresponding
component, and should be avoided. This may be ruled out in a subsequent 
version of this specification."

To it seems not clear - maby except for historical reasons - why 'mixed'
should not be hold by the complexType _only_.

I tried to test this against XSV and Xerces:

Schema:
------
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:element name="foo">
     <xsd:complexType mixed="true">
       <xsd:complexContent mixed="false">
         <xsd:restriction base="xsd:anyType">
           <xsd:sequence>
             <xsd:element name="bar"/>
           </xsd:sequence>
         </xsd:restriction>
       </xsd:complexContent>
     </xsd:complexType>
   </xsd:element>
</xsd:schema>

Instance:
---------
<foo>
   hi
   <bar/>
</foo>

XSV 2.7-1 and Xerces-J 2.6.2 both don't like the character content if
'mixed' was enabled on complexType and disabled on complexContent.
With...

  <xsd:complexType mixed="false">
       <xsd:complexContent mixed="true">

...both seem to be happy.

Regards,

Kasimier

Received on Monday, 13 December 2004 10:42:43 UTC