Details
Description
If I define unbounded element sequences with minOccurs=0 in a schema and then xsd2jibx process the schema, the generated code throws a NullPointerException on calling the size...() method. Example:
In the XSD below, I have to set minOccurs to 1 (element workbenchList) in order for the generated code to not throw a NullPointerException when calling the generated sizeWorkbenchList() method.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://workbenchlist.jibx.v1.swidARD.ubs.com"
xmlns="http://workbenchlist.jibx.v1.swidARD.ubs.com"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="url" type="xsd:string"/>
<xsd:element name="workbench">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="1" ref="url"/>
</xsd:sequence>
<xsd:attribute name="description" type="xsd:string" use="optional"/>
<xsd:attribute name="swid" type="xsd:string" use="optional"/>
<xsd:attribute name="version" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="workbenchList">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="1" ref="workbench"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>