This section describes a tutorial example of incorrect usages of 'redefine' components on changing existing datatypes.
One common error on using "redefine" components is that the redefined datatype uses a name different than the base datatype.
Here is a sample schema document, address_redefine_error.xsd, that has this type of errors:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:annotation>
<xsd:documentation>address_redefine_error.xsd
Copyright (c) 2007 by Dr. Herong Yang. All rights reserved.
</xsd:documentation>
</xsd:annotation>
<xsd:redefine schemaLocation="address_us.xsd">
<xsd:annotation>
<xsd:documentation>
Modifying the "addressUsType" definition
</xsd:documentation>
</xsd:annotation>
<xsd:complexType name="addressOverseaType">
<xsd:complexContent>
<xsd:extension base="addressUsType">
<xsd:sequence>
<xsd:element name="country" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:redefine>
<xsd:element name="addressOversea" type="addressOverseaType"/>
</xsd:schema>
Here is the error message reported by the schema checker program, XsdSchemaChecker.java:
>java XsdSchemaChecker address_redefine_error.xsd
Error:
Line number: 18
Column number: 41
Message: src-redefine.5.b.d: 'extension' does not have a 'base'
attribute that refers to the redefined element,
',addressOverseaType'. <complexType> children of <redefine>
elements must have <extension> or <restriction> descendants,
with 'base' attributes that refer to themselves.
Failed with 1 errors.