XML Schema complexType要素
完全なXML Schemaリファレンス
定義と使い方
complexType 要素は複合型を定義します。複合型の要素は、他の要素や属性を含むXML要素です。
要素情報
- 親要素: element, redefine, schema
構文
<complexType
id=ID
name=NCName
abstract=true|false
mixed=true|false
block=(#all|list of (extension|restriction))
final=(#all|list of (extension|restriction))
any attributes
>
(annotation?,(simpleContent|complexContent|((group|all|
choice|sequence)?,((attribute|attributeGroup)*,anyAttribute?))))
</complexType>
id=ID
name=NCName
abstract=true|false
mixed=true|false
block=(#all|list of (extension|restriction))
final=(#all|list of (extension|restriction))
any attributes
>
(annotation?,(simpleContent|complexContent|((group|all|
choice|sequence)?,((attribute|attributeGroup)*,anyAttribute?))))
</complexType>
(? 記号は、complexType 要素内で要素が0回または1回出現できることを宣言し、* 記号は要素が0回以上出現できることを宣言します。)
| 属性 | 説明 |
|---|---|
| id | 任意。この要素の一意のIDを指定します。 |
| name | 任意。要素の名前を指定します。 |
| abstract | 任意。インスタンス文書で複合型を使用できるかどうかを指定します。この値が true の場合、要素はその複合型を直接使用できず、その複合型から派生した複合型を使用する必要があります。既定値は false です。 |
| mixed | 任意。この複合型の子要素間に文字データを許可するかどうかを指定します。既定値は false です。
|
| block | 任意。指定された派生型を持つ複合型がこの複合型の代わりに使用されるのを防ぎます。この値には #all または、extension や restriction のサブセットであるリストを含めることができます:
|
| final | 任意。この complexType 要素から指定された型が派生するのを防ぎます。この値には #all または、extension や restriction のサブセットであるリストを含めることができます。
|
| any attributes | 任意。non-schema 名前空間を持つ任意のその他の属性を指定します。 |
例 1
次の例には、"note" という名前の複合型要素があります:
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
例 2
次の例には、別の複合型 "personinfo" から派生した複合型 "fullpersoninfo" があります。これは、3つの追加要素(address、city、country)を使用して継承された型を拡張しています:
<xs:element name="employee" type="fullpersoninfo"/>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
上記の例では、上記の "employee" 要素は次の要素を順番に含める必要があります:"firstname"、"lastname"、"address"、"city"、"country"。
完全なXML Schemaリファレンス その他の拡張