What is wrong with extending an XML Schema type using xs:all?

xsd

Solution

The problem is you can't have all if you're extending another type. As far as XML knows the parent type might have a sequence model and since XML forbids putting an all group inside of a sequence group (since that would destroy the sequence group's ordering) then XML also forbids putting an all group in an extension of a complex type. You could use sequence instead of all for both though and you'd be fine.

Problem

``` <?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 An 'all' model group is neither allowed in complex type definition 'mstns:ServiceType' nor in its extension '{anonymous}'. Clicking Details gives a link to a paragraph in XML Schema specification which I do not understand. Added: Ah, yes, forgot to mention - the line of error is this one: ``` <xs:element name="TemplateCode" type="xs:string"/> ```

Original source