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>
Activity
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | CVS [ 10580 ] | |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] | |
| Assignee | Dennis Sosnoski [ dsosnoski ] |
| Fix Version/s | CVS [ 10580 ] | |
| Fix Version/s | 1.0-RC0 [ 10878 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
| Affects Version/s | JiBX 1.1 [ 12217 ] | |
| Affects Version/s | xsd2jibx-beta0.2 [ 11090 ] |
| Component/s | CodeGen [ 13794 ] | |
| Component/s | xsd2jibx [ 10675 ] |
I'm able to use minOccurs="0" with maxOccurs="unbounded" in the current CVS code, now being released as 0.2 Beta.