XML Schema simpleType 元素

定义和用法

simpleType 元素定义一个简单类型,规定与具有纯文本内容的元素或属性的值有关的信息以及对它们的约束。

元素信息

出现次数 无限制
父元素 attribute、element、list、restriction (simpleType)、schema、union
内容 annotation、list、restriction (simpleType)、union

语法

ບໍ່ມີປະສົມປະກອບ
>
(annotation?,(restriction|list|union))

(? 符号声明元素可在 simpleType 元素中出现零次或一次。)

ປະສົມປະກອບ ອະທິບາຍ
id ອະນຸຍາດ. ປະກອບກົດລະບຽບຄວາມທີ່ພຽງພໍລະຫວ່າງຫົວຂໍ້ຂອງຫນັງ.
name

ຊື່ປະເພດ. ຊື່ນັ້ນຕ້ອງເປັນຊື່ພຽງພໍລະຫວ່າງບໍ່ມີຄຳເວົ້າຊັບ (NCName) ທີ່ຖືກກໍານົດໃນ XML Namespace.

ຖ້າມີການກໍານົດຄວາມຊື່ຄວາມຊື່ນັ້ນຈະຕ້ອງເປັນຊື່ຄວາມຊື່ພຽງພໍລະຫວ່າງ simpleType ແລະ complexType ທັງໝົດ.

ຖ້າ simpleType ເປັນຫົວຂໍ້ຂອງ schema ເປັນລູກຄົນແລ້ວຈະເປັນການເວົ້າຫນັງຄົນແລ້ວຈະບໍ່ອະນຸຍາດ.

ບໍ່ມີປະສົມປະກອບ Optional. Specify any other attributes with non-schema namespace.

Instance

Example 1

This example declares that the "age" element is a simple type with constraints. The value of age cannot be less than 0 or greater than 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>