XML Schema group要素
完全な XML Schema リファレンスマニュアル
定義と使用法
group 要素は、複合型定義で使用される要素グループを定義するために使用されます。
要素情報
- 親要素: schema, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
構文
<group
id=ID
name=NCName
ref=QName
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(all|choice|sequence)?)
</group>
id=ID
name=NCName
ref=QName
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(all|choice|sequence)?)
</group>
(? 記号は group 要素内で宣言されており、この要素は0回または1回出現できます。)
| 属性 | 説明 |
|---|---|
| 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です。 |
| any attributes | 任意。non-schema 名前空間を持つその他の属性を指定します。 |
例 1
次の例では、4つの要素を含むシーケンスのグループを定義し、その group 要素を複合型定義で使用しています:
<?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>
<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>
完全な XML Schema リファレンスマニュアル その他の拡張