What is wrong with XML schema type extension using xs: all?

<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns="http://tempuri.org/ServiceDescription.xsd" xmlns:mstns="http://tempuri.org/ServiceDescription.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://tempuri.org/ServiceDescription.xsd" elementFormDefault="qualified" id="ServiceDescription"> <xs:element name="Template"> <xs:complexType> <xs:complexContent> <xs:extension base="ServiceType"> <xs:all> <xs:element name="TemplateCode" type="xs:string"/> </xs:all> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> <xs:complexType name="ServiceType"> <xs:all> <xs:element name="ServiceCode" type="xs:string"/> </xs:all> </xs:complexType> </xs:schema> 

When I try to save this in XMLSpy, it tells me

The "all" model group is not allowed in the definition of the complex type "mstns: ServiceType" and in its extension "{anonymous]".

When you click the Details button, a link to a paragraph in the specification of an XML schema that I don’t understand.

Added: Ah, yes, I forgot to mention - the error line is this:

 <xs:element name="TemplateCode" type="xs:string"/> 
+4
source share
1 answer

The problem is that you may not have all if you extend another type. Because XML knows that the parent type can have a sequence model, and since XML prevents the entire group from being placed inside a sequence group (since this would destroy the ordering of sequence groups), XML also prevents the entire group from being placed in an extension of the complex type. You could use a sequence, not everything for both, and everything would be fine.

+4
source

All Articles