Hi Werner, Can you reproduce the problem according to JIRA using the attachment files?
On 1/15/07, Xinjun Chen <[EMAIL PROTECTED]> wrote:
HI Werner, I provided some false information in the JIRA. The JDK version in my test code is 1.5.0 instead of 1.4.2. Regards, Xinjun On 1/15/07, Xinjun Chen <[EMAIL PROTECTED] > wrote: > > Hi Werner, > > The created JIRA is at the following URL: > http://jira.codehaus.org/browse/CASTOR-1838 > > The attached zip file contains the main code (CISClient3.java), domain > entity (HearingDetailsVO.java), mapping file (HearingDetailsVO.xml), and > JUnit test script (CISClient3Test.java). > > Regards, > Xinjun > > > On 1/12/07, Werner Guttmann <[EMAIL PROTECTED] > wrote: > > > > Xinjun, > > > > I cannot reproduce things locally. Can I please ask you to create a > > new issue at http://jira.codehaus.org/browse/CASTOR, and attach all > > relevant files (domain entities, mapping file, JUnit test case, ...). > > > > Thanks in advance > > Werner > > > > ------------------------------ > > *From:* Xinjun Chen [mailto:[EMAIL PROTECTED] > > *Sent: *Freitag, 12. Jänner 2007 11:08 > > *To:* [email protected] > > *Subject:* Re: [castor-user] Castor mapping file to specify optional > > elements > > > > > > Hi Sandeep and Werner, > > > > Thank you for your responsive reply. > > > > I have looked through the link quite a few times. I understand > > "required" attribute may be the only place I can set in the mapping. But the > > default value for "required" is already "false". Should I still specify this > > for those fields which may contains null value? > > > > I have the following mapping for field caseNo and designation in the > > HearingDetailsVO.java. > > > > <field name="caseNo" type="java.lang.String"> > > <bind-xml name="caseNo" node="element"/> > > </field> > > <field name="designation" type=" java.lang.String"> > > <bind-xml name="designation" node="element"/> > > </field> > > > > In fact I didn't set value for caseNo and designation when creating > > the object. When I marshal the object, I get some null elements like > > <caseNo/><designation/> inside the DOM Node. > > > > I also tried to change the mapping to > > <field name="caseNo" type="java.lang.String" required="false"> > > <bind-xml name="caseNo" node="element"/> > > </field> > > <field name="designation" type=" java.lang.String" required="false"> > > <bind-xml name="designation" node="element"/> > > </field> > > But this does not solve the problem. > > > > I was also wondering whether I should use required="optional". Again, > > that did not solve the problem. > > Did I miss some other configuration or this is a bug in Castor? > > I am using Castor-1.0.5-xml.jar. Java 1.4.2 > > > > Regards, > > Xinjun > > > > > > On 1/12/07, Werner Guttmann <[EMAIL PROTECTED] > wrote: > > > > > > Xinjun, > > > > > > have a llok at > > > > > > http://castor.org/xml-mapping.html#3.4-The-%3Cfield%3E-element > > > > > > which explains that on a field mapping you can specify whether a > > > field is required (or not) by setting the 'required' attribute according to > > > your needs. > > > > > > Re: the null elements, can you please give me an example where this > > > happens, and where in your view should not happen ? > > > > > > Regards > > > Werner > > > > > > ------------------------------ > > > *From:* Xinjun Chen [mailto:[EMAIL PROTECTED] > > > *Sent:* Freitag, 12. Jänner 2007 07:36 > > > *To:* [email protected] > > > *Subject:* [castor-user] Castor mapping file to specify optional > > > elements > > > > > > > > > Hi, > > > > > > I am new to Castor. Could anyone tell me if there is any way to > > > specify certain xml elements as optional? And in turn stop Castor > > > marshalling framework from generating null elements. > > > > > > > > > Regards, > > > Xinjun > > > > > > > > >

