users@jaxb.java.net

Re: Wrapper object for collections issue with JAXB 2.1

From: Malachi de Ælfweald <malachid_at_gmail.com>
Date: Wed, 8 Oct 2008 12:27:11 -0700

I would add this in on the element:
            <xsd:annotation>
                <xsd:appinfo>
                    <jaxb:property name="Addresses" />
                </xsd:appinfo>
            </xsd:annotation>

So that the Java API is nice :)

On Wed, Oct 8, 2008 at 11:46 AM, Ted Poovey <tpoovey_at_uscentral.org> wrote:

> Might try:
>
> <xs:element name="Person">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="Address" type="AddressType"
> minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> Thank you
>
> Ted Poovey
> Software Engineer III
> I.T. Application Management
> U.S. Central
> 9701 Renner Blvd
> Lenexa, KS 66219
> (ph) 913-227-6106
> (fax) 913-227-6254
>
>
> -----Original Message-----
> From: sr_ren [mailto:srini_rengasamy_at_hotmail.com]
> Sent: Wednesday, October 08, 2008 1:31 PM
> To: users_at_jaxb.dev.java.net
> Subject: Wrapper object for collections issue with JAXB 2.1
>
>
> Hi,
>
> I have a collection of addresses and I want the XML should look like
> this
> <PhysicalAddresses>
> <PhysicalAddress> ... </PhysicalAddress>
> <PhysicalAddress> ... </PhysicalAddress>
> <PhysicalAddress> ... </PhysicalAddress>
> </PhysicalAddresses>
> To achieve this the XSD is defined as follows
> <xs:complexType name="Person">
> <xs:sequence>
> <xs:element name="Addresses" type="Addresses" />
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="Addresses">
> <xs:sequence>
> <xs:element name="Address" type="AddressType"
> minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="AddressType">
> <xs:sequence>
> ....
> </xs:sequence>
> </xs:complexType>
>
> The JAXB is generating classes like this
> public class Person{
> Addresses addresses;
> public Addresses getAddresses();
> public Addresses setAddresses(Addresses);
> }
> public class Addresses{
> List<Address> address;
> public List<Address> getAddress();
> }
> public class Address{
> }
> This is OK, but I want to avoid the extra "Addresses" class and
> directly
> represent them as follows
> public class Person{
> List<Address> address;
> public List<Address> getAddress();
> }
> Is it possible through some annotation, binding file directive etc?
>
> Thanks!
> --
> View this message in context:
> http://www.nabble.com/Wrapper-object-for-collections-issue-with-JAXB-2
> .1-tp19884674p19884674.html<http://www.nabble.com/Wrapper-object-for-collections-issue-with-JAXB-2.1-tp19884674p19884674.html>
> Sent from the java.net - jaxb users mailing list archive at
> Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>