On Thu March 5 2009 8:42:50 pm Benson Margulies wrote: > Isn't this for what minOccurs='0' was invented? In JAXB, I think > that's required=false, nillable=true or some such.
Right. It's actually required=false, nillable=false. With nillable true, if it's null, you get the element with xsi:nil="true" set. Dan > > On Thu, Mar 5, 2009 at 6:00 PM, David Castro <[email protected]> wrote: > > Hrmm, how about dynamically? Really what I am going for is something > > like: > > > > http://myapiserver.com/api/contacts?fields=id > > > > So this: > > > > <contact> > > <id>0</id> > > <firstName>A</firstName> > > <lastName>B</lastName> > > </contact> > > > > turns into this: > > > > <contact> > > <id>0</id> > > </contact> > > > > Although, in my particular case, I wouldn't just mind stripping out all > > XML elements with empty content. I've already got a filter/interceptor > > to empty fields I want to remove from the result XML...but those tags > > still get included, which I want to avoid. Want to compress the XML to > > only fields that have data. > > > > Would still be great if there were simply a way of telling CXF on the fly > > that only certain fields should make their way into the XML. If you are > > aware of a better way...I'm all ears =) > > > > Thanks, > > David > > > > On Thu, Mar 5, 2009 at 2:50 PM, Ian Roberts <[email protected]>wrote: > >> David Castro wrote: > >> > Is anyone is aware of how I can dynamically tell CXF (and thus JAXB) > >> > that there are some fields I want excluded from the resultant XML > >> > being > >> > >> returned? > >> > >> > I don't want to reinvent the wheel if I don't have to, but I can't > >> > find information on how to do what I want using the CXF framework > >> > rather than having to parse the XML outbound and remove what needs > >> > removing. Ideas? > >> > >> @XmlTransient tells JAXB to exclude particular fields. You might need > >> to annotate either the field directly or its get/set methods, depending > >> on the @XmlAccessorType of the containing class. > >> > >> Ian > >> > >> -- > >> Ian Roberts | Department of Computer Science > >> [email protected] | University of Sheffield, UK -- Daniel Kulp [email protected] http://www.dankulp.com/blog
