You just don't set any value (or set it explicetely to 'null'). Castor's Marshaller will figure that the element is 'nillable', and emit the correct code.
Regards Werner Elango wrote: > Werner, > > The XML element structure, which I am working on now, is like the one given > below: > > <xs:complexType name="Request"> > <xs:complexContent> > <xs:sequence> > <xs:element name="Field1"/> > <xs:element name="Field2" nillable="true" minOccurs="0"/> > </xs:sequence> > </xs:complexContent> > </xs:complexType> > > I don't know what value to set for Field2 to make Castor generate <Field2 > xsi:nil="true"> as output during marshalling. I want to set xsi:nil=true for > the element <Field2>. For <Field1>, I just call setField1(Object) to set a > value. But for <Field2>, what value to set while calling setField2() to make > Castor Marshaller generate xsi:nil = "true" attribute? > > It will be very helpful for me, if you give me the steps to follow to > acheive the output <Field2 xsi:nil="true"> > NOTE: I am new to Castor. So, please bear with me. Thanks. > > > I checked the generated Descriptor class corresonding to this Request > element. There setNillable(true) is called for the Field2. But I don't know > how to use this RequestDecriptor class to achieve the xsi:nil="true". I > don't see any documentation regarding this either. > > - Elango > > > Werner Guttmann-5 wrote: >> Hi, >> >> Why don't you use the nillable attribute on the element/attribute >> definition in question ? That should give you what you are looking for. >> >> Werner >> >>> -----Original Message----- >>> From: Elango [mailto:[EMAIL PROTECTED] >>> Sent: Dienstag, 16. Jänner 2007 13:34 >>> To: [email protected] >>> Subject: [castor-user] How to enable xsi:nil attribute using castor? >>> >>> >>> Hi All, >>> >>> How to enable xsi:nil attribute of an XML element during >>> marshalling using Castor? I don't see any documentation that >>> explains how to set xsi:nil attribute of an XML element to "true". >>> >>> Steps that I follow to generate XML using Castor: >>> >>> 1. Create object from Castor generated class. >>> 2. Set the values for the elements. >>> 3. Call Marshaller.marshall(). >>> >>> Please help me. >>> >>> Regards, >>> Elango >>> -- >>> View this message in context: >>> http://www.nabble.com/How-to-enable-xsi%3Anil-attribute-using- >>> castor--tf3020679.html#a8389374 >>> Sent from the Castor - User mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> 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

