XML Schema simpleType 元素
❮ 完整的 XML Schema 参考
定义和用法
simpleType 元素定义了一个简单类型,并指定了属性或纯文本元素的约束和信息。
元素信息
- 父元素: attribute, element, list, restriction, schema, union
语法
<simpleType
id=ID
name=NCName
任何属性
>
(annotation?,(restriction|list|union))
</simpleType>
(? 符号表示该元素在 simpleType 元素内出现零次或一次)
Attribute | 描述 |
---|---|
id | 可选。指定元素的唯一 ID |
name | 为元素指定名称。如果 simpleType 元素是 schema 元素的子元素,则此属性是必需的,否则不允许。 |
any attributes | 可选。指定任何其他非 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>
❮ 完整的 XML Schema 参考