Thanks Werner for the reply.

Castor marshalling does not generate xml for primitive types if their
set method is not called even though they have default values.

Castor generates _has Boolean members for primitive types whose value is
set to true when set method is called on the primitive members. But the
same logic is not used for non primitive types. Probably it checks for
null when marshalling for objects and checks for _has member for
primitive types.

So, my requirement of not generating the xml for member objects who have
default values but not their set methods are not called can be met if
Castor follows the same logic of having _has members for these non
primitive members and checking _has during marshalling

Is there any way I can do this?

Thanks,
Sreedhar

-----Original Message-----
From: Werner Guttmann [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 20, 2007 8:42 AM
To: [email protected]
Subject: Re: [castor-user] marshalling specific fields in an object

To my knowledge, there's no way to avoid this. In theory, you could 
implement a custom FieldHandler, but I doubt you'd have enough 
information to distinguish between whether a real value has been set or
not.

Werner

Sreedhar Kamishetti wrote:
> Hello,
> 
> I have Java source code generated using Castor. 
> 
> My requirement is, I need to set some of the members of generated Java
> class dynamically and generate the xml for that object with only
members
> whose set methods have been called.
> 
> I have "default" in the xml schema for some of the elements. For
> example,
> 
> <xsd:element name="ipConfig" type="AddrAllocTypeEnum" default="DHCP"
> minOccurs="0"/>
> 
> Code gets generated for this ipConfig field with default of DHCP. So,
> when I marshall this object, I get xml for this default members also. 
> 
> How can I avoid this?
> 
> Thanks,
> Sreedhar
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to