- From: Achille Fokoue <achille@us.ibm.com>
- Date: Wed, 8 Jan 2003 12:09:01 -0500
- To: www-xml-schema-comments@w3.org, xmlschema-dev@w3.org
- Cc: Paul.V.Biron@kp.org
It seems that there is no way to restrict a complex type whose content type is mixed and allows some elements into a new type which would simply allow text. Here is an example - taken from a SQC issue reported by Paul Biron - that illustrates the problem : <xs:schema> <xs:complexType name='base' mixed='true'> <xs:choice minOccurs='0' maxOccurs='unbounded'> <xs:element name='e1' type=xs:string'/> </xs:choice> <xs:attribute name='a1'/> </xs:complexType> <!-- the intend of this type is to simply remove all the children to leave a type which ony allows (untyped) text --> <xs:complexType name='restr' mixed='true'> <xs:complexContent> <xs:restriction base='base'> <xs:attribute name='a1'/> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:schema> According to the rule below defined in Part 1 section 3.4.2 and specifying how the content type of a complex type should be computed from its XML representation, the content type of restr is EMPTY, not mixed. "The appropriate case among the following: 1 If the <restriction> alternative is chosen, then the appropriate case among the following: 1.1 If one of the following is true 1.1.1 There is no <group>, <all>, <choice> or <sequence> among the [children]; 1.1.2 There is an <all> or <sequence> among the [children] with no [children] of its own excluding <annotation>; 1.1.3 There is a <choice> among the [children] with no [children] of its own excluding <annotation> whose minOccurs [attribute] has the ·actual value· 0; , then empty;" This rule simply ignores the value of mixed attribute, and produces a result that is counter intuitive. I thought that another way to remove all the children and allow only text would be to use <simpleContent>, but, in that case, the spec requires the base type to be either to a simple type or a complex type whose content type is a simple type. I don't see how to restrict the base type to allow only text. If the rule in section 3.4.2 could be modified to take into account the value of the mixed attribute, the problem I'm raising would be solved. Best regards, Achille Fokoue XML/XSL Transformational Systems IBM T.J. Watson Research Center
Received on Wednesday, 8 January 2003 12:27:05 UTC