次の方法で共有


restriction (simpleType)

simpleType 定義の制約を定義します。

<restriction
  base = QName 
  id = ID 
  {any attributes with non-schema Namespace}...>
Content: (annotation?, (simpleType?, (minExclusive | minInclusive | 
maxExclusive | maxInclusive | totalDigits |fractionDigits | length | 
minLength | maxLength | enumeration | whiteSpace | pattern)*))
</restriction>

属性

  • base
    組み込みデータ型の名前か、またはスキーマ (または指定した名前空間によって示される他のスキーマ) に定義されている simpleType 要素の名前。restriction 要素を含んでいる要素は、base 値で指定した型から派生します。

    base 値は、限定名 (QName) であることが必要です。

    必ず指定します。

  • id
    この要素の ID。id の値は ID 型である必要があり、この要素を含んでいるドキュメント内で一意である必要があります。

    省略可能です。

要素情報

出現回数 1 回
親要素 simpleType
コンテンツ annotationfractionDigitsenumerationlengthmaxExclusivemaxInclusivemaxLengthminExclusiveminInclusiveminLengthpatternsimpleTypetotalDigitswhiteSpace

制限を使用する単純型の定義例を次に示します。単純型を nonNegativeInteger から派生させ、その maxInclusive 値を 100 に設定します。

<xs:simpleType name="freezeboilrangeInteger">
  <xs:restriction base="xs:nonNegativeInteger">
    <xs:maxInclusive value="100"/>
  </xs:restriction>
</xs:simpleType>

integer 組み込み型から派生し、integer のすべてのファセットを持つ (制限なし) 単純型の定義例を次に示します。

<xs:simpleType name="myInteger">
  <xs:restriction base="xs:integer"/>
</xs:simpleType>

string から派生し、列挙型である単純型の定義例を次に示します。値セットは指定した値に制限します。

<xs:simpleType name="mountainbikesize">
  <xs:restriction base="xs:string">
    <xs:enumeration value="small"/>
    <xs:enumeration value="medium"/>
    <xs:enumeration value="large"/>
  </xs:restriction>
</xs:simpleType>

参照

XML スキーマ リファレンス (XSD) | XML スキーマの要素

詳細については、http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#derivation-by-restriction で、W3C『XML Schema Part 2: Datatypes Recommendation』を参照してください。