complexContent 定義の制約を定義します。
<restriction
base = QName
id = ID
{any attributes with non-schema Namespace}...>
Content: (annotation?, (group | all | choice | sequence)?, ((attribute |
attributeGroup)*, anyAttribute?))
</restriction>
属性
base
このスキーマ (または指定した名前空間で示される他のスキーマ) で定義されている complexType 要素の名前。restriction 要素を含んでいる要素は、base 値で指定した型から派生します。base 値は、限定名 (QName) であることが必要です。
必ず指定します。
id
この要素の ID。id の値は ID 型である必要があり、この要素を含んでいるドキュメント内で一意である必要があります。省略可能です。
要素情報
出現回数 | 1 回 |
親要素 | complexContent |
コンテンツ | group、all、choice、sequence、attribute、attributeGroup、anyAttribute |
例
restriction を使用して複合型を定義する例を次に示します。複合型 USAddress
を通常のアドレス複合型から派生させ、その country 要素を US
に固定します。
<xs:complexType name="address">
<xs:sequence>
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
<xs:element name="zipcode" type="xs:integer" />
<xs:element name="country" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="USAddress">
<xs:complexContent>
<xs:restriction base="address">
<xs:sequence>
<xs:element name="street" type="xs:string" />
<xs:element name="city" type="xs:string" />
<xs:element name="zipcode" type="xs:integer" />
<xs:element name="country" type="xs:string" fixed="US" />
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
参照
XML スキーマ リファレンス (XSD) | XML スキーマの要素
詳細については、http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#derivation-by-restriction で、W3C『XML Schema Part 2: Datatypes Recommendation』を参照してください。