users@jaxb.java.net

Re: Model Group Binding for mixed content

From: Joe Fialli <Joseph.Fialli_at_Sun.COM>
Date: Mon, 15 Aug 2005 12:12:00 -0400

Aleksei Valikov wrote:

> Hi.
>
> >> Model group binding style is very helpful to homogenize JAXB
> >> collections and properties. Could it be somehow applied to the
> >> mixed-content types? That is, a property like
> >>
> >> /**
> >> * Objects of the following type(s) are allowed in the list
> >> * {_at_link org.jvnet.hyperjaxb2.test.one.MixedType.Name}
> >> * {_at_link java.lang.String}
> >> * {_at_link org.jvnet.hyperjaxb2.test.one.MixedType.Shipdate}
> >> * {_at_link org.jvnet.hyperjaxb2.test.one.MixedType.Orderid}
> >> *
> >> */
> >> java.util.List getContent();
> >>
> >> could contain instances of NameOrShipdateOrOrderidOrValue.
>
>> I'm not exactly sure what you are proposing, Lexi.
>
>
> With model group binding style, schema fragment
>
> <xs:sequence maxOccurs="unbounded">
> <xs:element name="se" type="xs:string"/>
> <xs:element name="sf" type="sequenceType"/>
> </xs:sequence>
>
> Is mapped onto:
>
> /**
> * Objects of the following type(s) are allowed in the list
> * {_at_link org.jvnet.hyperjaxb2.test.one.HeteroSequenceType.SeAndSf}
> */
> java.util.List getSeAndSf();
>
> public interface SeAndSf {
> org.jvnet.hyperjaxb2.test.one.SequenceType getSf();
> void setSf(org.jvnet.hyperjaxb2.test.one.SequenceType value);
> java.lang.String getSe();
> void setSe(java.lang.String value);
> }
>
> I'd like mixed type like this:
>
> <xs:complexType name="mixedType" mixed="true">
> <xs:sequence>
> <xs:element name="name" type="xs:string"/>
> <xs:element name="orderid" type="xs:positiveInteger"/>
> <xs:element name="shipdate" type="xs:date"/>
> </xs:sequence>
> </xs:complexType>
>
> to be have similar mapping. Not simply
>
> public interface MixedType {
>
> /**
> * Objects of the following type(s) are allowed in the list
> * {_at_link org.jvnet.hyperjaxb2.test.one.MixedType.Name}
> * {_at_link java.lang.String}
> * {_at_link org.jvnet.hyperjaxb2.test.one.MixedType.Shipdate}
> * {_at_link org.jvnet.hyperjaxb2.test.one.MixedType.Orderid}
> *
> */
> java.util.List getContent();
> }
>
> But
>
> public interface MixedType {
>
> /**
> * Objects of the following type(s) are allowed in the list
> * {_at_link
> org.jvnet.hyperjaxb2.test.one.MixedType.NameOrShipdateOrOrderid}
> */
> java.util.List getContent();
> }
>
> public interface NameOrshipdateOrOrderid {
> Name getName();
> Shipdate getShipdate();
> Orderid getOrderid();
> String getValue();
> }

This style of binding becomes problematic for the binding of a named
model group definition.
There exist a chance that a complex type definition with mixed content
references
a named model group definition and also a complex type definition
without mixed
content acceses the same model group definition. Text information is a
property
of the type definition while the model group definition only allows
element content.
This is why they were kept separate in JAXB 1.0 binding.

-Joe





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