views:

52

answers:

1

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>
+1  A: 

I don't have a complete answer for you, I'm afraid, because I don't have time to look into this in detail, but, your derived type does not seem to be a valid restriction: a string with a minLength of 0 is not a restriction of a string with a minLength of 10: there are more strings with a minLength of 0 than there are with 10.

xcut