XML Schema รวมถึง Element
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์
ความหมายและการใช้งาน
องค์ประกอบรวมใช้เพื่อเพิ่มสคีมาหลายรายการที่มีเนมสเปซเป้าหมายเดียวกันในเอกสาร
ข้อมูลองค์ประกอบ
- องค์ประกอบหลัก:สคีมา
ไวยากรณ์
<include
id=ID
schemaLocation=anyURI
any attributes
>
(annotation?)
</include>
(เครื่องหมาย ? ประกาศว่าองค์ประกอบสามารถเกิดขึ้นได้เป็นศูนย์หรือครั้งเดียวภายในองค์ประกอบรวม)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
schemaLocation | Required. Specifies the URI to the schema to include in the target namespace of the containing schema |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ตัวอย่าง 1
ด้วยสคีมาที่รวมไว้ ไฟล์ที่รวมทั้งหมดต้องอ้างอิงเนมสเปซเป้าหมายเดียวกัน หากเนมสเปซเป้าหมายสคีมาไม่ตรงกัน การรวมจะไม่ทำงาน:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.w3schools.com/schema">
<xs:include schemaLocation="https://www.w3schools.com/xml/customer.xsd"/>
<xs:include schemaLocation="https://www.w3schools.com/xml/company.xsd"/>
..
..
..
</xs:schema>
❮ การอ้างอิงสคีมา XML ที่สมบูรณ์