XML Schema simpleType要素
定義と使用方法
simpleType要素は単純なタイプを定義し、テキスト内容を持つ要素や属性の値に関する情報およびそれらの制約を規定します。
要素情報
出現回数 | 制限なし |
親要素 | attribute、element、list、restriction(simpleType)、schema、union |
内容 | annotation、list、restriction(simpleType)、union |
文法
<simpleType id=ID name=NCName any attributes > (annotation?,(restriction|list|union)) </simpleType>
(? 符号宣言要素はsimpleType要素内で0回または1回出現できます。)
属性 | 説明 |
---|---|
id | 任意。その要素のユニークなIDを指定します。 |
name |
タイプ名。その名前はXML命名空間規範で定義された無冒号名(NCName)でなければなりません。 指定された場合、その名前はすべてのsimpleTypeおよびcomplexType要素間で一意でなければなりません。 もしsimpleType要素がschema要素の子要素である場合、必須であり、他の状況では許可されていません。 |
any attributes | オプションです。non-schema名前空間を含む他の属性を指定します。 |
例
例 1
この例では、"age"要素が制約付きのシンプルタイプであることを宣言しています。ageの値は0以下または100以上ではありません:
<xs:element name="age"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> </xs:restriction> </xs:simpleType> </xs:element>