changing restriction on simple type in extended complex type
Posted
by rotary_engine
on Stack Overflow
See other posts from Stack Overflow
or by rotary_engine
Published on 2010-05-02T07:36:20Z
Indexed on
2010/05/02
7:47 UTC
Read the original article
Hit count: 237
I am trying to create a schema that has 2 address types. The first AdressType
requires an element Line 1
to have a value at least 10 characters. The second type OtherAdressType
derives from this with the same elements, but does not require a value for Line 1
.
I've tried different ways but always get schema errors, this error is:
Invalid particle derivation by restriction - 'Derived element '{namespace}:Line1' is not a valid restriction of base element '{namespace}:Line1' according to Elt:Elt -- NameAndTypeOK.'.
If I add a type xs:string
to OtherAdressType:Line1
then I get other errors.
<xs:complexType name="AdressType">
<xs:sequence>
<xs:element name="Line1" minOccurs="1" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="10" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Line2" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="OtherAdressType">
<xs:complexContent>
<xs:restriction base="AdressType">
<xs:sequence>
<xs:element name="Line1" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Line2" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
© Stack Overflow or respective owner