RE: coerce mixed/element content to simple content via restriction ?

Priya,

This construct is not valid. 'Cos, it clearly violates rule 2 of Schema
Representation Constraint: Complex Type Definition Representation OK [1]

"If the <simpleContent> alternative is chosen, the type definition
·resolved· to by the ·actual value· of the base [attribute] must be either a
complex type definition whose {content type} is a simple type definition or,
only if the <extension> alternative is also chosen, a simple type
definition; "

[1]
http://www.w3.org/TR/xmlschema-1/#section-Constraints-on-XML-Representations
-of-Complex-Type-Definitions

Asir
-----Original Message-----
From: xmlschema-dev-request@w3.org
[mailto:xmlschema-dev-request@w3.org]On Behalf Of Priya Lakshminarayanan
Sent: Tuesday, June 11, 2002 3:29 PM
To: Tom Moog; xmlschema-dev@w3.org
Cc: xmlschema-dev@w3.org
Subject: RE: coerce mixed/element content to simple content via
restriction ?



I think you meant to show the derivedType as having simpleContent instead of
complexContent.

<xs:complexType name="BaseType" mixed="true">
   <xs:sequence minOccurs="0">
     <xs:element name="a" type="xs:string" />
  </xs:sequence>
</xs:complexType>

<xs:complexType name="DerivedType" mixed="true">
  <xs:simpleContent>
    <xs:restriction base="BaseType">
      <xs:simpleType>
        <xs:restriction base="xs:string" />
      </xs:simpleType>
    </xs:restriction>
  </xs:simpleContent>
</xs:complexType>

The above is valid since the baseType's particle is emptiable and its
mixed="true", as per clause 5.1.2 of Schema Component Constraint: Derivation
Valid (Restriction, Complex)in the XML Schema rec.
[http://www.w3.org/TR/xmlschema-1/#derivation-ok-restriction]

5 The appropriate case among the following must be true:
5.1 If the {content type} of the complex type definition is a simple type
definition, then one of the following must be true:
5.1.1 The {content type} of the {base type definition} must be a simple type
definition of which the {content type} is a ·valid restriction· as defined
in Derivation Valid (Restriction, Simple) (§3.14.6).
5.1.2 The {base type definition} must be mixed and have a particle which is
·emptiable· as defined in Particle Emptiable (§3.9.6).

Thanks,
Priya

-----Original Message-----
From: Tom Moog [mailto:tmoog@sarvega.com]
Sent: Tuesday, June 11, 2002 12:09 PM
To: xmlschema-dev@w3.org
Cc: xmlschema-dev@w3.org
Subject: coerce mixed/element content to simple content via restriction ?



In a recent book on xml schema there is an example that shows a complex
type with complex content being coerced to simple content because of
an empty restriction plus mixed content.  This looks really odd and seems
to violate the idea that simple content and element content can't appear
in the same derivation hierarchy.

Is this valid ?

The author appears to know that this is unusual because she adds, "This is

the only case where a restriction element may have both a base attribute
and a simpleType child".

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >

<xs:complexType name="BaseType" mixed="true">
   <xs:sequence minOccurs="0">
     <xs:element name="a" type="xs:string" />
  </xs:sequence>
</xs:complexType>

<xs:complexType name="DerivedType" mixed="true">
  <xs:complexContent>
    <xs:restriction base="BaseType">
      <xs:simpleType>
        <xs:restriction base="xs:string" />
      </xs:simpleType>
    </xs:restriction>
  </xs:complexContent>
</xs:complexType>

</xs:schema>

Received on Tuesday, 11 June 2002 16:12:01 UTC