Hi Roy,
I'll take a look at this if you can mail me your test example please.
Thanks.
-----Original Message-----
From: Roy van der Kuil [mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 12:04
To: [email protected]
Subject: [castor-user] XML: xsd default values
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
The information in this message is confidential and may be legally privileged.
It may not be disclosed to, or used by, anyone other than the addressee. If you
receive this message in error, please advise us immediately. Internet emails
are not necessarily secure. CODA does not accept responsibility for changes to
any email which occur after the email has been sent. Attachments to this email
may contain software viruses, which could damage your systems. CODA has checked
the attachments for viruses before sending, but you should virus-check them
before opening.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user