XML Schema group 要素
定義と使用法
group 要素は、複雑なタイプ定義で使用される要素グループを定義するために使用されます。
要素情報
出現回数 | 無制限 |
親要素 | schema、choice、sequence、complexType、restriction (complexContent)、extension (complexContent) |
内容 | annotation、all、choice、sequence |
文法
<group id=ID name=NCName ref=QName maxOccurs=nonNegativeInteger|unbounded minOccurs=nonNegativeInteger 任意の属性 > annotation?,(all|choice|sequence)?) </group>
(group 要素内に宣言された ? 符号は、group 要素が零回または一回だけ現れることを示します。)
属性
id
任意。この要素のユニークな ID を指定します。
name
任意。グループの名前を指定します。この名前は XML ナミング空間規范で定義されたコロンを含まない名前 (NCName) でなければなりません。
schema 要素が group 要素の親要素である場合にのみ使用します。この場合、group は complexType、choice、sequence 要素によって使用されるモデルグループです。
name 属性と ref 属性は同時に使用できません。
ref
任意。他のグループの名前を参照します。ref 値は QName でなければなりません。ref には命名空間接頭辞を含むことができます。
name 属性と ref 属性は同時に使用できません。
maxOccurs
任意。group 要素が親要素に現れる最大回数を指定します。この値は0以上の整数でなければなりません。最大回数に制限を設けたくない場合は、文字列 "unbounded" を使用します。デフォルト値は1です。
minOccurs
任意。group 要素が親要素に現れる最小回数を指定します。この値は0以上の整数でなければなりません。デフォルト値は1です。
任意の属性
任意。non-schema ナミング空間を持つ他の属性を指定します。
例
例 1
以下の例では、4つの要素を含むシーケンスのグループを定義し、そのグループを複雑なタイプの定義で使用しています:
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:group name="custGroup"> <xs:sequence> <xs:element name="customer" type="xs:string"/> <xs:element name="orderdetails" type="xs:string"/> <xs:element name="billto" type="xs:string"/> <xs:element name="shipto" type="xs:string"/> </xs:sequence> </xs:group> <xs:element name="order" type="ordertype"/> <xs:complexType name="ordertype"> <xs:group ref="custGroup"/> <xs:attribute name="status" type="xs:string"/> </xs:complexType> </xs:schema>