XML Schema redefine element
Definition and Usage
redefine element allows you to redefine simple and complex types, groups and attribute groups obtained from external schema files in the current Schema.
Element Information
- Parent element: schema
grammar
<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 命名空间的任何其他属性。 |
Example 1
The following example shows a schema, Myschama2.xsd, wherein the presence of the elements specified by the Myschama1.xsd. pname type is redefined. According to this schema, elements constrained pname must be "country" element ends:
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>
Complete XML Schema Reference