Hi,
Can someone please give me some pointers on how my understanding og xsd:all element. I was under the impression that this allowed element to exist in any order or if minOccurs="0" is stipulated, allow elements to be optional or in any order. However I cant get the following XML to verify against the schema.
THE SCHEMA
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"
targetNamespace="http://www.ziese.com/" xmlns="http://www.ziese.com/">
<xs:element name="Car"> <!-- global element. Not wrapped by type -->
<xs:complexType> <!-- embedded type -->
<xs:sequence>
<xs:element name="engineType" type="engineType"/>
<xs:element name="partsValues" type="partsValue"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="Engine">
<xs:sequence>
<xs:element name="EngineType" type="engineType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="engineType">
<xs:restriction base="xs:string">
<xs:enumeration value="14Valve"/>
<xs:enumeration value="8Valve"/>
<xs:enumeration value="16Valve"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="partsValue">
<xs:all minOccurs="0"> <!-- child elements can exist in any order -->
<xs:element name="engine" type="xs:integer"/> <!-- and can optionally exist -->
<xs:element name="exhaust" type="xs:integer"/>
<xs:element name="wheels" type="xs:integer"/>
</xs:all>
</xs:complexType>
</xs:schema>
THE XML
<?xml version="1.0" encoding="UTF-8"?>
<Car xmlns="http://www.ziese.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ziese.com/
D:\CurrentProjects\WebServicesCertification\Documents\CHAPTE~1\carSchema.xsd">
<engineType>14Valve</engineType>
<partsValues>
<engine>122</engine>
<wheels>33</wheels>
</partsValues>
</Car>
Its complaining as I havent included exhaust. If I remove the minOccurs it complains as the order isnt correct. Im using XML Spy for validation.
Any help would be greatly appreciated.
Thanks
Steve