定义对 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 元素的元素是从基值所指定的类型派生的。基值必须是限定名 (QName)。
必选项。
id
该元素的 ID。 id 值必须属于类型 ID 并且在包含该元素的文档中是唯一的。可选项。
元素信息
出现次数 |
一次 |
父元素 |
|
内容 |
annotation、fractionDigits、enumeration、length、maxExclusive、maxInclusive、maxLength、minExclusive、minInclusive、minLength、pattern、simpleType、totalDigits、whiteSpace |
示例
以下示例说明使用限制的简单类型定义。 (简单类型是从 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>