Microsoft KB Archive/316635

= PRB: MSXML 4.0: Error Message When You Load an XSD Schema in an XMLSchemaCache Object =

Article ID: 316635

Article Last Modified on 3/18/2002

-

APPLIES TO


 * Microsoft XML Core Services 4.0

-



This article was previously published under Q316635



SYMPTOMS
When you load an XML Schema definition language (XSD) schema into an MSXML 4.0 XMLSchemaCache object, you may receive the following error message:

is not the only particle in a or is being used as an extension.



CAUSE
This may occur if the schema contains a complex type that derives from another complex type whose content model is defined by using an  grouping particle, as follows:         

    <xsd:element name=&quot;state&quot; type=&quot;USState&quot;/> <xsd:element name=&quot;zipcode&quot; type=&quot;xsd:positiveInteger&quot;/> </xsd:all> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:schema>

<div class="resolution_section">

RESOLUTION
To work around this problem, use either of the following methods:
 * Use the   element rather than the   element to define the content model of the parent type.
 * Use the   element to define a new complex type instead of extending a type that uses the   element.

For example, you can use the following schema: <?xml version=&quot;1.0&quot;?> <xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;> <xsd:complexType name=&quot;address&quot;>  <xsd:element name=&quot;name&quot;  type=&quot;xsd:string&quot;/> <xsd:element name=&quot;street&quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot;city&quot;  type=&quot;xsd:string&quot;/> </xsd:all> </xsd:complexType>

<xsd:complexType name=&quot;USAddress&quot;>  <xsd:element name=&quot;name&quot;  type=&quot;xsd:string&quot;/> <xsd:element name=&quot;street&quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot;city&quot;  type=&quot;xsd:string&quot;/> <xsd:element name=&quot;state&quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot;zipcode&quot; type=&quot;xsd:positiveInteger&quot;/> </xsd:all> </xsd:complexType> </xsd:schema>

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
According to the World Wide Web Consortium (W3C) specifications,   model groups may appear only at the top level of a complexType or group element, and must be the only particle in the group.

When an extension type is built in XSD, it is regarded as a sequence that contains the base type and the extension. For example, the derived USAddress complexType element from the schema that is described in the &quot;Cause&quot; section resembles the following: <xsd:complexType name=&quot;USAddress&quot;> <xsd:sequence>  <xsd:element name=&quot;name&quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot;street&quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot;city&quot; type=&quot;xsd:string&quot;/> </xsd:all>  <xsd:element name=&quot;state&quot; type=&quot;USState&quot;/> <xsd:element name=&quot;zipcode&quot; type=&quot;xsd:positiveInteger&quot;/> </xsd:all> </xsd:sequence> </xsd:complexType> This violates the rule that   model groups must appear at the top level of a complexType or group element, and must be the only particle in the group.

Steps to Reproduce Behavior
Save the sample schema that is described in the &quot;Cause&quot; section in a file named Address-schema.xsd, and then add the schema to an MSXML 4.0 XMLSchemaCache object, as in the following Microsoft Visual Basic sample: Dim xmlschema As MSXML2.XMLSchemaCache40 Set xmlschema = New MSXML2.XMLSchemaCache40 xmlschema.Add &quot;&quot;, app.path & &quot;\address-schema.xsd&quot; When the Add method is called, the XSD is checked to ensure that it conforms to the W3C XSD specifications. Because this schema does not conform to the specifications, you receive an error message.

<div class="references_section">