XML Schema simpleType element

definition and usage

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

element information

occurrence unrestricted
parent element attribute, element, list, restriction (simpleType), schema, union
content annotation, list, restriction (simpleType), union

syntactic

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

(element declaration สามารถปรากฏขึ้นใน element simpleType ซึ่งไม่มีหรือมีหนึ่งครั้ง)

attributes description
id ตัวเลือก กำหนด ID ที่เป็นเดียวกันกับ element นี้
name

ชื่อของประเภท ชื่อนี้ต้องเป็น NCName ที่ถูกกำหนดใน XML namespace specification

ถ้ามีการกำหนด ชื่อนี้ต้องเป็นที่เด็ดขาดระหว่าง element simpleType และ complexType ทั้งหมด

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

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>