I have a schema element declared as below

    <xs:element name="LOC_DATA">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="NAME"/>
                <xs:element ref="TYPE" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="NAME" type="locnameType"/>
    <xs:element name="TYPE" type="locType"/>
    <xs:simpleType name="locnameType">
            <xs:restriction base="xs:string">
                    <xs:minLength value="1"/>
                    <xs:maxLength value="12"/>
            </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="locType">
          <xs:restriction base="xs:string">
            <xs:enumeration value="N"/>
            <xs:enumeration value="A"/>
            <xs:enumeration value=""/>
          </xs:restriction>
    </xs:simpleType>

The xml doc that I am trying to unmarshall is

     <LOC_DATA>
       <NAME>CHICAGO</NAME>
       <TYPE></TYPE>
     <LOC_DATA>

Using the default marshalling code (ie. without using any custom mapping
file) I get an exception

ValidationException: The field '_TYPE' (whose xml name is 'TYPE') is a
required field.;

I can explain this, since there is no minOccurs/maxOccurs attr specified in
the schema, so it defaults it to " minOccurs=1 maxOccurs=1"
 which implies in the schema   <xs:element ref="TYPE" />  == <xs:element
ref="TYPE" minOccurs="1" maxOccurs="1" />

Ok,now my question is, since blank ("") is a valid enumertion for locType,
which one should take precedence ? Castor seems to think that since the
minOccurs is not specified, it should be present and seems to ignore the "
<xs:enumeration value=""/>" schema specification.

I tried to validate the same xml document using XMLSpy and it validates it.
So which is the correct interpretation in such cases ?

thanks
Sire



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to