XML Schema sequence 要素
定義と使用法
sequence 要素は、グループ内の要素が指定された順序で含む要素に現れることを要求します。各サブ要素は0回から任意回現れることができます。
要素情報
出現回数 | グループ内で一度のみ;それ以外は無制限。 |
親要素 | group、choice、sequence、complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent) |
内容 | annotation、any、choice、element、group、sequence |
構文
<sequence id=ID maxOccurs=nonNegativeInteger|unbounded minOccurs=nonNegativeInteger 任意の属性 > (annotation?,(element|group|choice|sequence|any)*) </sequence>
(? 則sequence要素の中でこの要素は0回または1回出現します。)
属性 | 説明 |
---|---|
id | オプション。この要素のユニークなIDを指定します。 |
maxOccurs | オプション。任意要素が親要素の中で最大何回出現するかを指定します。この値は0以上の整数で、最大回数に制限を設定しない場合は文字列"unbounded"を使用します。デフォルト値は1です。 |
minOccurs | オプション。任意要素が親要素の中で最小何回出現するかを指定します。この値は0以上の整数で、任意のグループはオプションと指定する場合は0に設定します。デフォルト値は1です。 |
任意の属性 | オプション。non-schema命名空間を持つ属性を指定します。 |
例
例1
この例では、"personinfo"要素に対する宣言が含まれており、この要素は以下の5つの要素("firstname", "lastname", "address", "city",および"country")を順序で含む必要があります:
<xs:element name="personinfo"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
例2
この例では、"pets"要素に対する宣言が含まれており、0個以上のdogおよびcat要素を含むことができます:
<xs:element name="pets"> <xs:complexType> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:element name="dog" type="xs:string"/> <xs:element name="cat" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>