XML Schema องค์ประกอบ Redefine
ความหมายและการใช้งาน
redefine องค์ประกอบช่วยให้คุณสามารถที่จะกำหนดประเภทที่ง่ายและซับซ้อนกลุ่มและแอตทริบิวต์กลุ่มที่ได้รับจากไฟล์สคีภายนอกใน Schema ปัจจุบัน
องค์ประกอบข้อมูล
- องค์ประกอบหลัก: สคี
ไวยากรณ์
<redefine
id=ID
schemaLocation=anyURI
any attributes
>
(annotation|(simpleType|complexType|group|attributeGroup))*
</redefine>
id=ID
schemaLocation=anyURI
any attributes
>
(annotation|(simpleType|complexType|group|attributeGroup))*
</redefine>
属性 | 描述 |
---|---|
id | 可选。规定该元素的唯一的 ID。 |
schemaLocation | 必需。对 schema 文档位置的 URI 引用。 |
any attributes | 可选。规定带有 non-schema 命名空间的任何其他属性。 |
ตัวอย่างที่ 1
ตัวอย่างต่อไปนี้แสดงให้เห็นถึงคี Myschama2.xsd ประเด็นการปรากฏตัวขององค์ประกอบที่ระบุโดย Myschama1.xsd ประเภท pname เป็นนิยามใหม่ ตามแบบแผนนี้องค์ประกอบ จำกัด pname จะต้องเป็น "ประเทศ" องค์ประกอบปิดให้บริการ:
Myschema1.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="pname">
<xs:sequence>
<xs:element name="firstname"/>
<xs:element name="lastname"/>
</xs:sequence>
</xs:complexType>
<xs:element name="customer" type="pname"/>
</xs:schema>
Myschema2.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:redefine schemaLocation="Myschema1.xsd">
<xs:complexType name="pname">
<xs:complexContent>
<xs:extension base="pname">
<xs:sequence>
<xs:element name="country"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
<xs:element name="author" type="pname"/>
</xs:schema>
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="pname">
<xs:sequence>
<xs:element name="firstname"/>
<xs:element name="lastname"/>
</xs:sequence>
</xs:complexType>
<xs:element name="customer" type="pname"/>
</xs:schema>
Myschema2.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:redefine schemaLocation="Myschema1.xsd">
<xs:complexType name="pname">
<xs:complexContent>
<xs:extension base="pname">
<xs:sequence>
<xs:element name="country"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
<xs:element name="author" type="pname"/>
</xs:schema>
XML Schema สมบูรณ์อ้างอิง