Hi,
I am facing a problem while unmarshalling into a
Java bean from an xml. I am using Castor unmarshaller to populate the xml values into a Java bean. The problem is as follows:
In an xsd I have a simple type defined as follows:
<xs:simpleType name="ListTest">
<xs:list itemType="xs:string"/>
</xs:simpleType>
In the same xsd I have specified an element List as follows:
<xs:element name="List " type="ListTest" minOccurs="0" maxOccurs="1" nillable="true"> </xs:element>.
I use this xsd to validate my sample xml which has a field by name List
<List>abc def ghi</List>.
When I am unmarshalling the xml I am able to populate these values into a
string array successfully.
But when the same element doesn't have any element, ie <List></List>, while unmarshalling I get a Null Pointer Exception. My inference is that in case of elements which are of type list, Castor expects elements to be present so that it can assign them into a string array object. In some cases there will be a valid scenario where elements will not be present. Could anyone help me out with this problem. Is there any other declaration I need to make in my xsd, so that while unmarshalling, an empty array object is obtained?
Regards,
Kaushik