Hi All,

I seem to have a problem with reading xml with an xsd element that has
a default value.
For example given the xsd:

<?xml version='1.0' encoding='UTF-8'?>
<xs:schema targetNamespace="http://foo.org/foo";
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:foo="http://foo.org/foo";
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
   <xs:element name="FooElement" id="foo">
       <xs:complexType>
           <xs:sequence>
               <xs:element name="FooSub" default="bar">
                   <xs:simpleType>
                       <xs:restriction base="xs:string">
                           <xs:enumeration value="foo" />
                           <xs:enumeration value="bar" />
                       </xs:restriction>
                   </xs:simpleType>
               </xs:element>
           </xs:sequence>
       </xs:complexType>
   </xs:element>
</xs:schema>

and the xml:
<FooElement><FooSub/></FooElement>

Checking this with xml-spy and jdom (which I beleive uses xerces for
xsd validation) gives me that the above xml is valid.

However when I run this through castor (I have tested this with the
castor -cvs version of april 1st), it fails with "The field '_fooSub'
(whose xml name is 'FooSub') is a required field of class
'foo.FooElement{file: [not available]; line: 1; column: 35}"

Now, it can be fairly easy to patch the castor code to change the
setFooSub(FooSub fs)  method to fall back the the default whenever
null is passed, but I wonder if that is the correct behaviour for
this.

Did anyone else experience this problem?

I have a test example here, if anyone is interested I can mail it, so
you can test this for yourself.

If my patch is the appropriate behaviour (falling back to default when
null is passed), than I can mail that patch too, of course.

Thanks for your comments/time on this.

-Roy van der Kuil



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

Reply via email to