schema validation errors + xs:restriction
Posted: Fri Apr 29, 2005 11:18 am
hi all,
I have the error (E derivation-ok-restriction.5.4.2: Error for type 'MyErpAddress'. The particle of the type is not a valid restriction of the particle of the base) when trying to validate the info.xsd
Could someone please tell me what I did wrong? Must the restricted have the same namespace as the base?
-------------------------------------------------------------------------------
components.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="components" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:compt="components" targetNamespace="components" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="ErpAddress" >
<xs:sequence>
<xs:element name="streetNumber" type="xs:string" minOccurs="0"/>
<xs:element name="streetName" type="xs:string" minOccurs="0"/>
<xs:element name="streetSuffix" type="xs:string" minOccurs="0"/>
<xs:element name="streetPrefix" type="xs:string" minOccurs="0"/>
<xs:element name="streetType" type="xs:string" minOccurs="0"/>
<xs:element name="suiteNumber" type="xs:string" minOccurs="0"/>
<xs:element name="city" type="xs:string" minOccurs="0"/>
<xs:element name="country" type="xs:string" minOccurs="0"/>
<xs:element name="postalCode" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
------------------------------------------------------------------------------
info.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="info" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:compt="components" targetNamespace="info" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="components" schemaLocation="components.xsd"/>
<xs:complexType name="MyErpAddress">
<xs:complexContent>
<xs:restriction base="compt:ErpAddress">
<xs:sequence>
<xs:element name="streetNumber" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="streetName" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="postalCode" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
I have the error (E derivation-ok-restriction.5.4.2: Error for type 'MyErpAddress'. The particle of the type is not a valid restriction of the particle of the base) when trying to validate the info.xsd
Could someone please tell me what I did wrong? Must the restricted have the same namespace as the base?
-------------------------------------------------------------------------------
components.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="components" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:compt="components" targetNamespace="components" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="ErpAddress" >
<xs:sequence>
<xs:element name="streetNumber" type="xs:string" minOccurs="0"/>
<xs:element name="streetName" type="xs:string" minOccurs="0"/>
<xs:element name="streetSuffix" type="xs:string" minOccurs="0"/>
<xs:element name="streetPrefix" type="xs:string" minOccurs="0"/>
<xs:element name="streetType" type="xs:string" minOccurs="0"/>
<xs:element name="suiteNumber" type="xs:string" minOccurs="0"/>
<xs:element name="city" type="xs:string" minOccurs="0"/>
<xs:element name="country" type="xs:string" minOccurs="0"/>
<xs:element name="postalCode" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
------------------------------------------------------------------------------
info.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="info" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:compt="components" targetNamespace="info" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="components" schemaLocation="components.xsd"/>
<xs:complexType name="MyErpAddress">
<xs:complexContent>
<xs:restriction base="compt:ErpAddress">
<xs:sequence>
<xs:element name="streetNumber" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="streetName" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="postalCode" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>