Xsd-restriction
XSD-制限
制限要素は、XML要素が受け入れることができる許容値を定義するために使用されます。
構文
<xs:restriction base = "element-type"> restrictions </xs:restriction>
base |
Type of the Element on which restriction is to be applied. For example,
この制限がint型の要素に固有であることを指定します。 |
restriction |
restriction is normally a range of conditions to be applied on the element’s value. In this example, we’ve set a restriction on marks that marks should be in range of 0 to 100 with both values are included.
|
例
値の制限。
条件-マークの範囲は0〜100でなければなりません。
<xs:element name = "marks">
<xs:simpleType>
<xs:restriction base = "xs:integer">
<xs:minInclusive value = "0"/>
<xs:maxInclusive value = "100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
値のセットの制限。
条件-グレードはA、B、またはCのみにしてください。
<xs:element name = "grades">
<xs:simpleType>
<xs:restriction base = "xs:string">
<xs:enumeration value = "A"/>
<xs:enumeration value = "B"/>
<xs:enumeration value = "C"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
通常のパターンを使用した制限。
条件-名はアルファベットのみにする必要があります。
<xs:element name = "firstname">
<xs:simpleType>
<xs:restriction base = "xs:string">
<xs:pattern value = "[a-z]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
制限の種類
S.No. | Restriction & Description |
---|---|
1 |
enumeration 許容可能な値のリストを定義します。 |
2 |
fractionDigits 許容される小数点以下の最大桁数を定義します(ゼロ以上)。 |
3 |
length リスト内の文字列またはアイテムの文字の長さを定義します(ゼロ以上)。 |
4 |
maxExclusive この数値を除く数値の上限を定義します。 |
5 |
maxInclusive この数値を含む数値の上限を定義します。 |
6 |
maxLength リスト内の文字列またはアイテムの文字数で最大長を定義します(ゼロ以上)。 |
7 |
minExclusive この数値を除く数値の下限を定義します。 |
8 |
minInclusive この数値を含む数値の下限を定義します。 |
9 |
minLength リスト内の文字列またはアイテムの文字数で最小長を定義します(ゼロ以上)。 |
10 |
pattern 許容されるパターンによって識別される文字の正確なシーケンスを定義します |
11 |
totalDigits 数値で許可される正確な桁数を定義します(常にゼロより大きい) |
12 |
whiteSpace 空白文字(ラインフィード、タブ、スペース、およびキャリッジリターン)の処理方法を定義します |