Lược đồ XML xác định lại phần tử
❮ Tham chiếu lược đồ XML hoàn chỉnh
Định nghĩa và Cách sử dụng
Phần tử xác định lại xác định lại các loại, nhóm và nhóm thuộc tính đơn giản và phức tạp từ một lược đồ bên ngoài.
Thông tin phần tử
- Phần tử chính: giản đồ
Cú pháp
<redefine
id=ID
schemaLocation=anyURI
any attributes
>
(annotation|(simpleType|complexType|group|attributeGroup))*
</redefine>
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
schemaLocation | Required. A URI to the location of a schema document |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ví dụ 1
Ví dụ sau đây cho thấy một lược đồ, Myschema2.xsd, với các phần tử được chỉ định bởi Myschema1.xsd. Loại pname được xác định lại. Theo lược đồ này, các phần tử bị ràng buộc bởi kiểu pname phải kết thúc bằng phần tử "country":
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>
❮ Tham chiếu lược đồ XML hoàn chỉnh