element simpleType ของ XML Schema

การกำหนดและการใช้งาน

element ของ simpleType กำหนดชนิดที่เดี่ยว กำหนดข้อมูลที่เกี่ยวข้องกับค่าของ element หรือ attribute ที่มีเนื้อหาข้อความ และข้อจำกัดเกี่ยวกับมัน

ข้อมูล element

การปรากฏของ element ไม่มีจำกัด
parent element attribute、element、list、restriction (simpleType)、schema、union
เนื้อหา annotation、list、restriction (simpleType)、union

การใช้งาน

<simpleType
id=ID
name=NCName
any attributes
>
(annotation?,(restriction|list|union))
</simpleType>

(? องค์ประกอบของสัญญาณสามารถปรากฏขึ้น 0 หรือ 1 ครั้งใน element ของ simpleType)

คุณสมบัติ คำอธิบาย
id ให้เลือก กำหนด ID ที่เดี่ยวโดยเฉพาะขององค์ประกอบนี้
name

ชื่อชนิด ชื่อนี้ต้องเป็นชื่อที่เดี่ยวที่กำหนดโดยนิยามใน XML Namespace (NCName)

ถ้ากำหนด ชื่อนี้ต้องเป็นชื่อที่เดี่ยวซึ่งไม่มีขีดแบ่ง (NCName) ที่กำหนดโดยนิยามใน XML Namespace ในทุก simpleType และ complexType

ถ้า element ของ simpleType เป็น child element ของ schema ในบางครั้งนั้นเป็นความจำเป็น ในทางตรงกันข้ามนั้นไม่อนุญาต

any attributes ให้เลือก กำหนดคุณสมบัติอื่นที่มีชื่อสามัญ

ตัวอย่าง

ตัวอย่าง 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>