Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何将多个complexType添加到XSD中的同一元素类型中?_Xml_Xsd - Fatal编程技术网

Xml 如何将多个complexType添加到XSD中的同一元素类型中?

Xml 如何将多个complexType添加到XSD中的同一元素类型中?,xml,xsd,Xml,Xsd,如何将多个compelxType添加到XSD文件中的同一元素类型中?如下例所示: <xs:element name="InboundFlight" type="eInboundFlight" <xs:complexType name="Flight"> <xs:sequence> <xs:element name="aircraftIdentification" type="xs:int"/> <

如何将多个compelxType添加到XSD文件中的同一元素类型中?如下例所示:

<xs:element name="InboundFlight" type="eInboundFlight"
<xs:complexType name="Flight">
    <xs:sequence>
        <xs:element  name="aircraftIdentification" type="xs:int"/>      
        <xs:element  name="iataFlightDesignator" type="xs:string"/>
    </xs:sequence>     
</xs:complexType>

<xs:complexType name="Aircraft">     
    <xs:sequence>
        <xs:element  name="aircraftRegistration" type="xs:int"/>      
        <xs:element  name="iataAircraftType" type="xs:string"/>
        <xs:element  name="icaoAircraftType" type="xs:string"/>      
    </xs:sequence>     
</xs:complexType> />


代码正确吗?或者应该为每个complexType添加单个elementType?

您不能在XML中任何元素的开始标记内添加元素,包括XSD中的
xs:element

要为由单独的航班和飞机信息组成的
InboundFlight
构建内容模型,对这两部分使用单独的元素,而不仅仅是单独的类型:

<?xml version="1.0" encoding="utf-8"  ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="InboundFlight" type="eInboundFlight"/>
  <xs:complexType name="eInboundFlight">
    <xs:sequence>
      <xs:element name="Flight">
        <xs:complexType>
          <xs:sequence>
            <xs:element  name="aircraftIdentification" type="xs:int"/>      
            <xs:element  name="iataFlightDesignator" type="xs:string"/>
          </xs:sequence>     
        </xs:complexType>
      </xs:element>
      <xs:element  name="Aircraft">
        <xs:complexType>     
          <xs:sequence>
            <xs:element  name="aircraftRegistration" type="xs:int"/>    
            <xs:element  name="iataAircraftType" type="xs:string"/>
            <xs:element  name="icaoAircraftType" type="xs:string"/>
          </xs:sequence>     
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

推荐阅读: