dev@jaxb.java.net

FW: Issue with Nillable Elements....

From: Sakala, Adinarayana <ASAKALA_at_iona.com>
Date: Thu, 26 Jan 2006 14:42:38 -0500

> -----Original Message-----
> From: Sakala, Adinarayana
> Sent: Wednesday, January 25, 2006 5:59 PM
> To: 'users_at_jaxb.dev.java.net'
> Subject: Issue with Nillable Elements....
>
>
> Hi,
>
> I am using JAXB implementation that ships with JAX-WS2.0 EA3.
> Here is the schema that i am working with,
>
> <complexType name="OccuringStruct1">
> <sequence minOccurs="0" maxOccurs="unbounded">
> <element name="varFloat" type="xsd:float" nillable="true"/>
> <element name="varInt" type="xsd:int" minOccurs="1"
> maxOccurs="10"/>
> <element name="varString" type="xsd:string"/>
> </sequence>
> </complexType>
>
> The JAXB generated code is attached (OccuringStruct1.java).
>
> Client code:
> public void testOccuringStruct1() throws Exception {
> OccuringStruct1 x = new OccuringStruct1();
> List<Serializable> theList =
> x.getVarFloatAndVarIntAndVarString();
> theList.add(2);
> theList.add("x1");
>
> OccuringStruct1 yOriginal = new OccuringStruct1();
> theList = yOriginal.getVarFloatAndVarIntAndVarString();
> theList.add(22);
> theList.add("y");
>
> Holder<OccuringStruct1> y = new
> Holder<OccuringStruct1>(yOriginal);
> Holder<OccuringStruct1> z = new Holder<OccuringStruct1>();
>
> OccuringStruct1 ret = docClient.testOccuringStruct1(x, y, z);
>
> System.out.println(++i + "/" + test_count +
> ":testOccuringStruct1 complete");
> }
>
> The generated XML Message by JAXB Runtime is,
> <ns4:testOccuringStruct1 xmlns:ns4=http://objectweb.org/type_test/doc
> xmlns:ns5="http://objectweb.org/type_test/types">
> <ns4:x>
> <ns5:varInt>2</ns5:varInt>
> <ns5:varString>x1</ns5:varString>
> </ns4:x>
> <ns4:y>
> <ns5:varInt>22</ns5:varInt>
> <ns5:varString>y</ns5:varString>
> </ns4:y>
> </ns4:testOccuringStruct1>
>
> The above message looks wrong to me because the nillable
> element varFloat was ignored in the serialization of XML.
> I would have expected the xml message to look like,
> <ns4:testOccuringStruct1 xmlns:ns4=http://objectweb.org/type_test/doc
> xmlns:ns5="http://objectweb.org/type_test/types"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <ns4:x>
> <ns5:varFloat xsi:nil="true"/>
> <ns5:varInt>2</ns5:varInt>
> <ns5:varString>x1</ns5:varString>
> </ns4:x>
> <ns4:y>
> <ns5:varFloat xsi:nil="true"/>
> <ns5:varInt>22</ns5:varInt>
> <ns5:varString>y</ns5:varString>
> </ns4:y>
> </ns4:testOccuringStruct1>
>
> Is this a known issue with JAXB2.0 EA3 or am i doing something wrong?
>
> Any help is really appreciated.
>
> thanks,
> Adi Sakala
>