users@jaxb.java.net

Re: Q: Does JAXB handle elements with minOccurs="0" correctly?

From: Jacob Lauemøller <jacob.lauemoeller_at_computer.org>
Date: Thu, 18 Nov 2004 21:17:09 +0100

On Thursday 18 November 2004 19:13, Kohsuke Kawaguchi wrote:
> Jacob Lauemøller wrote:
> > But it's unfortunate (IMHO) and somewhat clumsy that I either
> > have to add this annotation to every element that has a minOccurs="0"
> > constraint (and this will only work well, by the way, when I control the
> > schema file) or add it at the schema level (e.g in a JAXB binding file)
> > and live with the fact that I then end up with isSetXXX, unsetXXX methods
> > on properties that are always set and cannot be unset (because their
> > minOccurs constraint is 1 or greater).
>
> I agree. It's clumsy. The problem for me is that when something is a
> spec-specified behavior, the RI can't really change it on its own. Plus,
> we care for the compatibility, and changing the signature of the
> generated code will break existing clients.
>
> But I think this is a great input toward 2.0.

I see your point, but couldn't you make it a customization feature for now and
then maybe turn it into a 2.0 spec. feature? As I see it, it would just be a
variation on the generateIsSetMethod property?

Another great customization would be to have xjc generate constructors that
took all required values (in addition to the empty default ctor). In this way
it would be slightly easier to build JAXB stuctures programmatically. Right
now I have to instantiate the right *Impl class and then invoke setters as
needed. Perhaps emitting a seperate factory class instead of a ctor would be
a better idea?

Apart from this, JAXB works really well for us -- it's fast and much, much
easier to use than e.g. the Axis generated classes. Keep up the good work!

Kind regards,
Jacob


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net