Title: Unmarshalling XML data with empty tags, adds default values.

Hi All,

I've encountered some odd behaviour with Castor which is causing a lot of problems for me.  It turns out that when I try to unmarshall data that is a primitive type and the tags are empty, Castor is defaulting the data to 0 for numeric types and FALSE for boolean.

This doesn't seem right.  For example, consider a XML schema:

<xsd:simpleType name="includecustomerinfo">
        <xsd:restriction base="xsd:boolean">
                <xsd:pattern value="true|false" />
        </xsd:restriction>
</xsd:simpleType>

Now, if I try to unmarshall some XML with a fragment like:

<INCLUDECUSTOMERINFO></INCLUDECUSTOMERINFO>

I would expect a ValidationException since the emtpy tag violates the reg-ex pattern in the schema.  Castor however, is defaulting this empty tag to 'false' and as such validation succeeds!

This seems to be caused by the toPrimitiveObject() method in the UnmarshalHandler which is defaulting data  for primitve types when the tags are empty.

Is there an easy way to work around this, or fix it?

Thanks,

Brett

Reply via email to