4

xsdの要素宣言で一意のタグを直接使用する方法の例を見てきましたが、複合型である要素宣言に入れる方法を理解できません。以下のコードを参照してください。

<xs:complexType name="flighttype">
<xs:sequence>
    <xs:element name="departure" type="departuretype"/>
    <xs:element name="arrival" type="arrivaltype"/>
    <xs:element name="altitude" type="xs:string"/>
    <xs:element name="speed" type="xs:string"/>
    <xs:element name="distance" type="xs:string"/>
    <xs:element name="entertainment" type="entertainmenttype"/>
    <xs:element name="safetymessage" type="xs:string"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
<xs:attribute name="airline" type="xs:string"/>
<xs:attribute name="flightno" type="xs:string"/>
<xs:attribute name="model" type="xs:string"/>
<xs:attribute name="passengers" type="xs:integer"/>
<xs:attribute name="status" type="xs:string"/>
</xs:complexType>

IDを一意のIDにしたいので、次の例を機能させることができますが、要素宣言内で直接使用されます。

ありがとうございました!

4

1 に答える 1

6

XSDでは、ID制約はタイプではなく要素に関連付けられます。flighttypeしたがって、それ自体ではなく、タイプを持つものとして定義されたスキーマ内の要素にID制約を定義しますflighttype

于 2013-02-05T16:57:59.160 に答える