Hi Keith, Many thanks for the suggestion. Indeed it seems to me that such property/attribute that prevents default value to be written to the XML is missing. The reason I need this odd behavior is that I must have an XML with maximum specified length and I am very close to that limit (where more data is added constantly).
I'll sure try the field handler if they do not impose too much delay in the project. Regards, Avi Avi Wiesenfeld, CISSP IDm Business unit, bmcsoftware Phone: +972-3-6451-295 Mobile: +972-52-428-6295 E-mail: [EMAIL PROTECTED] -----Original Message----- From: Keith Visco [mailto:[EMAIL PROTECTED] Sent: Thursday, February 23, 2006 3:31 AM To: [email protected] Subject: Re: [castor-user] Removing boolean=false lines from resultant XML file upon marshalling Avi, It might not be the ideal solution, but you could implement a custom FieldHandler that simply returns null from the FieldHandler#getValue() method if the boolean value is false. It would be nice if Castor had a simple property that can be set to indicate that default values should be filtered out during marshalling, unfortunately we don't have such a feature at this time. Please see here for more information on handlers: http://castor.codehaus.org/xml-fieldhandlers.html --Keith Wiesenfeld, Avi wrote: > > Avi Wiesenfeld, CISSP > IDm Business unit, bmcsoftware > Phone: +972-3-6451-295 > Mobile: +972-52-428-6295 > E-mail: [EMAIL PROTECTED] > > Hi ALL, > > When I unmarshall an XML file, where the castor map file contains the > following description: > > <field name="MyBool" type="boolean" required="false"> > <bind-xml name="MyBool" node="element"/> > </field> > > The target class boolean "MyBool" will contain the value "false" if the > original XML file did not contain the element "MyBool" (line > "<MyBool>false</MyBool>" did not appear in the XML file). > > Now I want exactly the opposite to happen when I marshall a class with > boolean field "MyBool" with false value to an XML file - I would like > the > File NOT to include the line "<MyBool>false</MyBool>". It is somewhat > hard to do that as one must have a true or false value in boolean > variable (unlike String that can have the value null). > > Is there a way to do that? > > Regards, > > Avi Wiesenfeld > BMC Software > > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- > > ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] ------------------------------------------------- ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] -------------------------------------------------

