XML Schema anyAttribute Element
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์
ความหมายและการใช้งาน
องค์ประกอบ anyAttribute ช่วยให้ผู้เขียนขยายเอกสาร XML ด้วยแอตทริบิวต์ที่ไม่ได้ระบุโดยสคีมา
ข้อมูลองค์ประกอบ
- องค์ประกอบหลัก: complexType, ข้อจำกัด (ทั้ง simpleContent และ complexContent), ส่วนขยาย (ทั้ง simpleContent และ complexContent), attributeGroup
ไวยากรณ์
<anyAttribute
id=ID
namespace=namespace
processContents=lax|skip|strict
any attributes
>
(annotation?)
</anyAttribute>
(เครื่องหมาย ? ประกาศว่าองค์ประกอบสามารถเกิดขึ้นได้เป็นศูนย์หรือครั้งเดียวภายในองค์ประกอบ anyAttribute)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
namespace | Optional. Specifies the namespaces containing the
attributes
that can be used. Can be set to one of the following:
|
processContents | Optional. Specifies how the XML processor should handle
validation against the elements specified by this any element. Can be set to
one of the following:
|
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ตัวอย่าง 1
ตัวอย่างต่อไปนี้แสดงการประกาศองค์ประกอบที่เรียกว่า "บุคคล" โดยใช้องค์ประกอบ <anyAttribute> ผู้เขียนสามารถเพิ่มแอตทริบิวต์จำนวนเท่าใดก็ได้ให้กับองค์ประกอบ "บุคคล":
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
<xs:anyAttribute/>
</xs:complexType>
</xs:element>
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์