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 參考