- From: Eddie Robertsson <erobertsson@allette.com.au>
- Date: Mon, 26 Aug 2002 17:37:22 +1000
- To: Masayasu Ishikawa <mimasa@w3.org>
- CC: xmlschema-dev@w3.org
Hi, >Suppose that I have a schema like this: > ><xs:schema version="1.0" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://example.com/test" > xmlns:test="http://example.com/test"> > > <xs:attributeGroup name="attrs"> > <xs:attribute name="id" type="xs:ID"/> > <xs:attribute name="class" type="xs:NMTOKENS"/> > </xs:attributeGroup> > > <xs:complexType name="mixed" mixed="true"> > <xs:choice minOccurs="0" maxOccurs="unbounded"> > <xs:element ref="test:a"/> > <xs:element ref="test:b"/> > </xs:choice> > </xs:complexType> > > <xs:element name="root"> > <xs:complexType> > <xs:complexContent> > <xs:extension base="test:mixed"> > <xs:attribute name="id" type="xs:ID"/> > </xs:extension> > </xs:complexContent> > </xs:complexType> > </xs:element> > > <xs:element name="a"> > <xs:complexType> > <xs:complexContent> > <xs:extension base="test:mixed"> > <xs:attributeGroup ref="test:attrs"/> > </xs:extension> > </xs:complexContent> > </xs:complexType> > </xs:element> > > <xs:element name="b"> > <xs:complexType> > <xs:complexContent> > <xs:extension base="test:mixed"> > <xs:attributeGroup ref="test:attrs"/> > </xs:extension> > </xs:complexContent> > </xs:complexType> > </xs:element> > ></xs:schema> > >And an instance would be something like this: > ><root xmlns="http://example.com/test"> > ccc<a>aaa<b>bbb</b>aaa</a>ccc<b>bbb<a>aaa</a>bbb</b>ccc ></root> > >MSV (20020414), Xerces-J 2.0.2 and XML Spy 4.4 reported no problem, >but XSV (online version, 1.203.2.47.2.4.2.11/1.106.2.25.2.3) complained >like this: > > Invalid per cvc-complex-type.1.2.3: text not allowed: | ccc| > I tested this with MSXML SP1 as well and it also reports this as an error. However I believe that this is a correct schema and instance and XSV and MSXML4 are wrong here. Section 3.2.1 [1] reads (Complex Type Definition with complex content* Schema Component*): {content type} 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; 1.2 otherwise a pair consisting of 1.2.1 the appropriate case among the following: 1.2.1.1 If the mixed [attribute] is present on <complexContent>, then mixed if its ·actual value· is true, otherwise elementOnly; 1.2.1.2 If the mixed [attribute] is present on <complexType> and its ·actual value· is true, then mixed; 1.2.1.3 otherwise elementOnly. 1.2.2 The particle corresponding to the <all>, <choice>, <group> or <sequence> among the [children]. 2 If the <extension> alternative is chosen, then [Definition:] let the explicit content be empty if any of the sub-clauses of clause 1.1 above applies, otherwise the particle corresponding to the <all>, <choice>, <group> or <sequence> among the [children], and then take the appropriate case among the following: 2.1 If the ·explicit content· is empty, then the {content type} of the type definition ·resolved· to by the ·actual value· of the base [attribute] ... In the example we have the following extension: <xs:element name="root"> <xs:complexType> <xs:complexContent> <xs:extension base="test:mixed"> <xs:attribute name="id" type="xs:ID"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> Since this is an extension this will match clause 2 in the above section of the spec. This clause says that the explicit content of the derived type is empty if any of the sub-clauses of clause 1.1 applies. Looking at 1.1.1 above we see that this is a match because we don't have <group>, <all>, <choice> or <sequence> among the [children] of the extension element. Since the explicit content is empty we have a match in 2.1 which specifies the content type of the derived type to be the content type of the base type. Since the content type of the base type is mixed the content type of the derived type should be mixed as well. >If I change each element declaration like the following, XSV doesn't >complain anymore. > > <xs:element name="root"> > <xs:complexType mixed="true"> > <xs:complexContent> > <xs:extension base="test:mixed"> > <xs:attribute name="id" type="xs:ID"/> > </xs:extension> > </xs:complexContent> > </xs:complexType> > </xs:element> > >What's/who's wrong? > This shouldn't be necessary. XSV and MSXML are wrong. Cheers, /Eddie
Received on Monday, 26 August 2002 03:37:43 UTC