Hello,

we noticed a really significant change in collection behavior between JIBX 
version 1.2.3 and JIBX version 1.2.2.

As documented in the collection element documentation 
(http://jibx.sourceforge.net/binding/collection-element.html) unmarshalling an 
optional collection behaves like this: "If an element name is used with an 
optional collection, and that name is missing from an input XML document, the 
collection property will be set to null."
Thus (we expect and noticed in the past) if no element name is used the 
collection property will not be set to null (but will be an empty collection).

With version 1.2.3 the collection property will be set to null, even if NO 
element name in the binding.xml is used on the optional collection.

To reproduce the changed behavior I provide a simple maven project using JIBX 
1.2.3 with the following schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
                xmlns:tns="http://foo.bar";
                elementFormDefault="qualified"
                targetNamespace="http://foo.bar";>

                <xs:element name="myCollection" type="tns:myCollection"/>

                <xs:complexType name="myCollection">
                               <xs:sequence>
                                               <xs:element type="xs:string" 
name="name" />
                                               <xs:element type="xs:boolean" 
name="active" />
                                               <xs:element type="xs:int" 
name="item" minOccurs="0" maxOccurs="unbounded" />
                               </xs:sequence>
                </xs:complexType>

</xs:schema>

The maven project will generate the XML mapping sources (MyCollection.java) and 
a binding.xml file. There is a simple test

bar.foo.JibxUnmarshallingTest.testUnmarshalXmlWithMissingListItems()

which will unmarshal an XML with no items for a list member and the result is 
that the object member list is null (test fails).

If you change the jibx version in the pom.xml to 1.2.2 (and do some minor code 
changes in the test classes because getter and setter method names of generated 
code also changed from 1.2.2 (getItems()) to 1.2.3 (getItemList()) the list 
member of the unmarshalled object will be an empty list (test success)?.

I am really worried about these changes (code generation / collection handling) 
on INCREMENTAL version changes. Are these changes bugs or wanted? Will they be 
fixed or remain in future version? I would really appreciate if someone can 
give a statement on these changes.

Thanks
Jürgen
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to