Xml 如何将多个complexType添加到XSD中的同一元素类型中?
如何将多个compelxType添加到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"/> <
<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>
推荐阅读: