Prashant wrote:
> Hello:
>
> I want to generate a "homogenous" lists of my xs:choice elements.
>
> But, I am a little bit confused by JAXB 1.0.X's treatment of unnamed
> xs:choice groups.
>
> Consider following example which is a modified version of
> "bind-choice" sample shipped with JAXB.
>
> Custom binding:
> <jxb:globalBindings bindingStyle="modelGroupBinding"/>
>
> Schema :
> <xs:element name="FooBar">
> <xs:complexType>
> <xs:sequence>
> <xs:choice>
> * <xs:element name="phoneNumber" type="xs:string"
> minOccures="0" maxOcuurs="unbounded"/>
> <xs:element name="speedDial" type="xs:int" minOccures="0"
> maxOcuurs="unbounded"/>
> * </xs:choice>
> </xs:complexType>
> </xs:element>
>
> Generated FooBar Bean contains
>
> public List getPhoneNumberOrSpeedDial() - elements of list are of type
> PhoneNumberOrSpeedDial
>
> PhoneNumberOrSpeedDial{
>
> getPhoneNumber();
> isSetPhoneNumber();
> isSetSeedDial();
> getSpeedDial();
>
> }
>
> Instead is't it simpler for FooBar to contain methods
>
> List getPhoneNumbers();
> List getSpeedDials();
Don't use the <jxb:globalBindings bindingStyle="modelGroupBinding"/>. This
binds a model group to a content interface.
>
>
> The lists would be empty when phone numbers/speeddials donot occur in
> a XML instance.
>
> What was the rational behind current behavior. Am i missing something
> here ?
See section 5.9.8, "Model Group Binding Style" of JAXB 1.0 spec for the
rationale for this binding.
modelGroupBinding style is not supported in JAXB 2.0. It requires state
driven
unmarshalling which runs counter to support for binding to invalid XML
content
and support for schema evolution, one of the goals for JAXB 2.0.
>
>
> Is the treatment better in JAX 2.0 ?
In JAXB 2.0 this will bind to (assuming binding to classes):
public class FooBar {
...
public List<String> getPhoneNumber() { .. }
public List<Integer> getSpeedDial() { ..}
}
Sekhar
>
>
> -Prashant
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>