Question on nesting

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question on nesting

Abhiram Panyam
I have the following classes

public class AddressVO {

        private String street;
        private String city;
        private String state;
        private String postalCode;
        private GeographicCoordinates geoCoordinates;
       
        //constructor, getters and setters
}

and

public class GeographicCoordinates {
       
        private Double latitude;
        private Double longitude;
        //constructor, getters and setters
}

I was able to get the following XML using aliases and attributes

<address street="7501 Philips Hwy" city="JACKSONVILLE" state="FL"
postalCode="32256">
        <geoCoordinates>
          <latitude>30.236246</latitude>
          <longitude>-81.594224</longitude>
        </geoCoordinates>
</address>

What I need is the latitude and longitude to be attributes of the address
element...like,

<address street="7501 Philips Hwy" city="JACKSONVILLE" state="FL"
postalCode="32256" latitude="30.236246" longitude="-81.594224" />

I would like to know if this is possible with XStream, and if it is, how.

Thanks,
abhi


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Question on nesting

Jörg Schaible-2
Hi Abhi,

Abhiram Panyam wrote:

> I have the following classes
>
> public class AddressVO {
>
> private String street;
> private String city;
> private String state;
> private String postalCode;
> private GeographicCoordinates geoCoordinates;
>
> //constructor, getters and setters
> }
>
> and
>
> public class GeographicCoordinates {
>
> private Double latitude;
> private Double longitude;
>         //constructor, getters and setters
> }
>
> I was able to get the following XML using aliases and attributes
>
> <address street="7501 Philips Hwy" city="JACKSONVILLE" state="FL"
> postalCode="32256">
>         <geoCoordinates>
>           <latitude>30.236246</latitude>
>           <longitude>-81.594224</longitude>
>         </geoCoordinates>
> </address>
>
> What I need is the latitude and longitude to be attributes of the address
> element...like,
>
> <address street="7501 Philips Hwy" city="JACKSONVILLE" state="FL"
> postalCode="32256" latitude="30.236246" longitude="-81.594224" />
>
> I would like to know if this is possible with XStream, and if it is, how.

This is only possible with your own custom converter for AddressVO. See the
converter tutorial, how to write something like that.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Question on nesting

Abhiram Panyam
Thanks, Jorg!




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email