commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Erdely" <mjerd...@gmail.com>
Subject Re: [betwixt] How do I control the mapping of a member class, Jav a --> XML?
Date Mon, 21 Aug 2006 22:29:32 GMT
Thank you but I am still getting the same behavior.

Doesn't having the outer element name of "Address" in Address.bewtixt
imply that all child elements are contained within the "Address"
element parent?

I have tried other Address.betwixt outer element name combinations
with no luck as well.


On 8/21/06, Sweetland, Jesse <JSweetland@talk.com> wrote:
> I've had a great deal of luck by providing separate bean info documents for
> each class.  Something like this might work better for you:
>
> Customer.betwixt:
>
> <?xml version="1.0"?>
> <info>
>         <element name="Customer"
> uri="'http://www.example.com/customer/2006-06-01/">
>                 <attribute name="name" property="name"/>
>                 <element name="ShippingAddress" property="shippingAddress"
> uri="'http://www.example.com/customer/2006-06-01/"/>
>                 <!-- ... -->
>         </element>
> </info>
>
>
>
> Address.betwixt:
>
> <?xml version="1.0"?>
> <info>
>         <element name="Address"
> uri="'http://www.example.com/customer/2006-06-01/">
>                 <element name="addressLine1" property="addressLine1"
> uri="'http://www.example.com/customer/2006-06-01/"/>
>                 <element name="addressLine2" property="addressLine1"
> uri="'http://www.example.com/customer/2006-06-01/"/>
>                 <!-- ... -->
>         </element>
> </info>
>
>
>
> -----Original Message-----
> From: Michael Erdely [mailto:mjerdely@gmail.com]
> Sent: Monday, August 21, 2006 5:04 PM
> To: commons-user@jakarta.apache.org
> Subject: [betwixt] How do I control the mapping of a member class, Java -->
> XML?
>
> My JavaBean has shippingAddress (of type Address) as a member of
> Customer along with a few primitives.
>
> My configuration file properly renames the shippingAddress element
> with the proper namespace. However, for the Address object primitives,
> my the configuration file gets ignored so the elements have the wrong
> names and no namespace.
>
> Any ideas? I am hoping I am just missing something simple.
>
> I am using Betwixt 0.7.
>
> -Michael
>
>
> Snippet of XML
> ________________________________________________________________________
> <bt1:Customer name="Mr Smith"
> xmlns:bt1="http://www.example.com/customer/2006-06-01/">
>     <bt1:ShippingAddress>
>       <addressLine1>123 Main St</addressLine1>
>       <city>Anytown</city>
>
>
> Customer.betwixt snippet
> ________________________________________________________________________
> <?xml version='1.0' encoding='UTF-8' ?>
> <info>
>         <element name='Customer'
> uri='http://www.example.com/customer/2006-06-01/'>
>                 <attribute name='name' property='name'/>
>                 <element name='ShippingAddress' property='shippingAddress'
> uri='http://www.example.com/customer/2006-06-01/'>
>                         <element name='AddressLine1' property='addressLine1'
> uri='http://www.example.com/customer/2006-06-01/'/>
>                         <element name='City' property='city'
> uri='http://www.example.com/customer/2006-06-01/'/>
>
>
> Java Code
> ________________________________________________________________________
> Customer customer = new Customer ();
> customer.setName("Mr Smith");
>
> Address address = new Address ();
> address.setAddressLine1("123 Main St");
> address.setCity("Anytown");
>
> customer.setShippingAddress(address);
>
> StringWriter outputWriter = new StringWriter();
> BeanWriter beanWriter = new BeanWriter(outputWriter);
>
> beanWriter.getXMLIntrospector().getConfiguration().setAttributesForPrimitive
> s(false);
> beanWriter.getBindingConfiguration().setMapIDs(false);
> beanWriter.setWriteEmptyElements(false);
> beanWriter.enablePrettyPrint();
>
> beanWriter.write(customer);
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message