commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carter Bradford" <car...@bradfordconsulting.com>
Subject [Betwixt] How to flatten the object structure when serializing to XML
Date Thu, 29 May 2008 22:38:24 GMT
Hi,

I have the following simple problem:

I have an object structure as follows:

public class Person {
  private String name;
  private int age;
  private Address addr;

  <...Standard Getters and Setters..>
}

public class Address {
  private String addrLine1;
  private String city;
  private String state;

<...Standard Getters and Setters...>

}

I want to map this into a a flat XML structure as follow:

<Person>
  <Name></Name>
  <Age></Age>
  <AddrLine1></AddrLine1>
  <City></City>
  <State></State>
</Person>

In other words, I don't want the Address wrapped in its own element.  I have
a mapping file as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<betwixt-config>
    <class name="Person">
        <element name="Person">
            <element name="Name" property="name"/>
            <element name="Age" property="age"/>
            <element name="Address" property="address"/>
        </element>
    </class>
     <class name="com.lmam.gw.plugins.policy.Address">
        <element name="Address">
            <element name="AddrLine1" property="addrLine1"/>
            <element name="City" property="city"/>
            <element name="State" property="state"/>
        </element>
    </class>
</betwixt-config>

I want to suppress the surrounding "Address" element.  This should be easy,
but it's not obvious to me.  Any help would be much appreciated.

Regards,

Carter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message