XML Schema simpleType Element
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์
ความหมายและการใช้งาน
องค์ประกอบ simpleType กำหนดประเภทอย่างง่าย และระบุข้อจำกัดและข้อมูลเกี่ยวกับค่าของแอตทริบิวต์หรือองค์ประกอบแบบข้อความเท่านั้น
ข้อมูลองค์ประกอบ
- องค์ประกอบหลัก:แอตทริบิวต์, องค์ประกอบ, รายการ, ข้อจำกัด, สคีมา, ยูเนี่ยน
ไวยากรณ์
<simpleType
id=ID
name=NCName
any attributes
>
(annotation?,(restriction|list|union))
</simpleType>
(เครื่องหมาย ? ประกาศว่าองค์ประกอบสามารถเกิดขึ้นได้เป็นศูนย์หรือครั้งเดียวภายในองค์ประกอบ simpleType)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
name | Specifies a name for the element. This attribute is required if the simpleType element is a child of the schema element, otherwise it is not allowed |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ตัวอย่าง 1
ตัวอย่างนี้กำหนดองค์ประกอบที่เรียกว่า "อายุ" ซึ่งเป็นประเภทธรรมดาที่มีข้อจำกัด ค่าของอายุต้องไม่ต่ำกว่า 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 ที่สมบูรณ์