枚举属性 XML 架构

Enumerating attributes XML Schema

正在尝试完成一个 XML 架构,其中包含汽车的父元素以及制造商、型号等子元素。附件元素需要只有 yes 或 no 值的属性。我已经在这方面工作了一段时间,已经到了下面,但它没有提供错误,只是第 22 行的红色 x(扩展名="cxml:YesNo")。在 XML 中,我在第 15 行收到以下错误 Multiple annotations found at this line:

    - cvc-complex-type.4: Attribute 'Radio' must appear on element 'cxml:Accessories'.
    - cvc-complex-type.4: Attribute 'Air_Conditioning' must appear on element 
     'cxml:Accessories'.
    - cvc-complex-type.4: Attribute 'Power_Steering' must appear on element 
     'cxml:Accessories'.
    - cvc-complex-type.4: Attribute 'Power_Brakes' must appear on element 
     'cxml:Accessories'.
    - cvc-complex-type.4: Attribute 'Power_Windows' must appear on element 
     'cxml:Accessories'. I am using eclipse.

我知道配件是导致问题的原因,但我似乎找不到解决方法。任何帮助将不胜感激。

XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://xxxxxxxxxx.com/CarsXML" 
xmlns:cxml="http://xxxxxxxxxxxx.com/CarsXML" elementFormDefault="qualified" > 



<xs:element name= "Car">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="Make" type="xs:string" />
            <xs:element name="Model" type="xs:string" />
            <xs:element name="Year" type="xs:gYear" />
            <xs:element name="Color" type="xs:string" />
            <xs:element name="Engine" type="cxml:EngineInfo" />
            <xs:element name="Number_of_Doors" type="xs:positiveInteger" />
            <xs:element name="Transmission_Type" type="cxml:TransInfo" />
            <xs:element name="Accessories" >
                <xs:complexType>
                <xs:simpleContent>
                    <extension base="cxml:YesNo">
                    <xs:attribute name="Radio"  type="cxml:YesNo" use="required" />
                    <xs:attribute name="Air_Conditioning" type="cxml:YesNo" use="required"/>
                    <xs:attribute name="Power_Windows" type="cxml:YesNo" use="required"/>
                    <xs:attribute name="Power_Steering" type="cxml:YesNo" use="required"/>
                    <xs:attribute name="Power_Brakes" type="cxml:YesNo" use="required"/>
                    </extension>
                </xs:simpleContent>
                </xs:complexType>
            </xs:element>   
        </xs:sequence>
    </xs:complexType>
</xs:element>

    <xs:complexType name="EngineInfo">
        <xs:sequence>
            <xs:element name="Number_Of_Cylinders" type="xs:positiveInteger"></xs:element>
            <xs:element name="Fuel_System">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                    <xs:enumeration value="Carbureted"/>
                    <xs:enumeration value="Fuel_Injected"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

     <xs:complexType name="TransInfo">
        <xs:sequence>
            <xs:element name="Transmission_Type">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                    <xs:enumeration value="Automatic"/>
                    <xs:enumeration value="Manual"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="YesNo">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Yes" />
      <xs:enumeration value="No" />
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

XML:

<?xml version="1.0" encoding="UTF-8"?>
<cxml:Car xmlns:cxml="http://cis337-0217.cisdprogram.com/CarsXML" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:xxxxxxxx.com/CarsXML 
Cars.xsd ">
  <cxml:Make>cxml:Make</cxml:Make>
  <cxml:Model>cxml:Model</cxml:Model>
  <cxml:Year>2001</cxml:Year>
  <cxml:Color>cxml:Color</cxml:Color>
  <cxml:Engine>
    <cxml:Number_Of_Cylinders>1</cxml:Number_Of_Cylinders>
    <cxml:Fuel_System>Carbureted</cxml:Fuel_System>
  </cxml:Engine>
  <cxml:Number_of_Doors>1</cxml:Number_of_Doors>
  <cxml:Transmission_Type>
    <cxml:Transmission_Type>Automatic</cxml:Transmission_Type>
  </cxml:Transmission_Type>
  <cxml:Accessories>cxml:Accessories</cxml:Accessories>
</cxml:Car>

使用 <xs:extension> 而不是 <extension>