Re: Simple type cannot be used in a derivation by RESTRICTION for a complexType.

Hi,

> Hi All,
>      I am recieving the above error message when I try to parse the
> following xml. Please let me know how to solve this problem. In XML-spy it
> works fine. xerces-J 1.4.2 fails.
> Thanks !!
>
> <xsd:complexType name="AddressLineType">
>      <xsd:simpleContent>
>          <xsd:restriction base="xsd:string">
>              <xsd:attribute name="index" type="xsd:string" use="optional"
> default="1"/>
>          </xsd:restriction>
>      </xsd:simpleContent>
> </xsd:complexType>

The problem is that when you're restricting a complexType in XML Schema the
base to must also be a complexType. What you want to do in the above example
is to extend the simpleType xs:string by adding an attribute. Since
simpleTypes can't carry attributes you have to use a complexType with simple
content but instead of restricting the simpleType xs:string you should extend
it. So, change xs:restriction to xs:extension and everything should work fine.

Cheers,
/Eddie

Received on Monday, 10 September 2001 19:50:24 UTC