当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema redefine 元素
The redefine element redefines simple and complex types, groups, and attribute groups from an external schema.
redefine元素的作用是:重新定义来自于一个扩展schema中的简单类型、复合类型、组以及属性组。
<redefine id=ID schemaLocation=anyURI any attributes > (annotation|(simpleType|complexType|group|attributeGroup))* </redefine> |
属性 | 描述 |
---|---|
id | Optional. Specifies a unique ID for the element 可选参数。为元素指定一个独立的ID |
schemaLocation | Required. A URI to the location of a schema document 必要参数。指定一个schema文档的URI地址 |
any attributes | Optional. Specifies any other attributes with non-schema namespace 可选参数。指定其它的属性(这些属性无schema命名空间) |
The following example shows a schema, Myschama2.xsd, with elements specified by the Myschama1.xsd. The pname type is redefined. According to this schema, elements constrained by the pname type must end with a "country" element:
下面的案例中展示了一个名为“Myschema2.xsd“的schema文件,文件中包含了由“Myschama1.xsd”指定的元素。这里的pname类型被重定义了。根据这个schema文档,被pname类型限制的元素必须以一个“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> |