XML Schema 参考手册 完整 XML Schema 参考手册 The redefine element allows you to redefine simple and complex types, groups, and attribute groups obtained from external schema files in the current Schema. 父元素: Schema Attribute Description Id Optional. Specifies the unique ID of the element. SchemaLocation Necessary. A URI reference to the location of the schema document. Any attributes Optional. Specifies any other attributes with the non-schema namespace. The following example shows a schema,Myschama2.xsd in which there are elements specified by Myschama1.xsd. The pname type is redefined. According to this schema, elements constrained by pname must end with a “country” element:Definition and usage ¶
Element information ¶
Grammar ¶
<redefine
id=ID
schemaLocation=anyURI
*any attributes*
>
(annotation|(simpleType|complexType|group|attributeGroup))\*
</redefine>
Example 1 ¶
**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>