users@jaxb.java.net

Re: Model Group Binding for mixed content

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Mon, 15 Aug 2005 10:59:14 +0200

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();
}

Bye.
/lexi