<mapping name="Person" value-style="attribute" class="yourpackagename.Person">
<value name="name" field="_name"/>
<structure name="Address" field="_address"> <!-- wrap values from _address object in "address" element -->
<value name="city" field="_city"/>
<structure field="_state"> <!-- include values from _state object directly in current "address" element -->
<value name="state" field="_code"/>
</structure>
</structure>
</mapping>
The difference is that in the mapping Eitan gave you'd have a separate "state" element containing the state code.
I assume you don't really want those '@' characters on the attribute names, Paul, since they're not legal in XML.
- Dennis
Eitan Suez wrote:
you have two choices:
1. you can define the mapping for all structures in a single mapping, nesting in the definitions for address and state, or 2. you can define three mappings, one for each type, and reference them.
example for #1: (just for address and state)
<binding> <mapping name="address" class="yourpackagename.Address"> <structure name="state" field="_state"> <value name="code" field="_code" /> </structure> </mapping> </binding>
example for #2:
<binding> <mapping name="address" class="yourpackagename.Address"> <structure field="_state" /> </mapping> <mapping name="state" class="yourpackagename.State"> <value name="code" field="_code" /> </mapping> </binding>
/ eitan
On Apr 11, 2005, at 5:57 PM, Paul Tomsic wrote:
I'm trying to set a class from an attribute, but it's actually two steps down... Here's my xml:
<Person name="Paul"> <Address @city="Philadelphia" @state="PA"/> ....
So my Person class contains an Address class, which contains a State class. How would I set up the Address class and the State class that is a field on the Address?
Here's my classes:
public class Person { private Address _address; ....
public class Address { private State _state;
public class State { private String _code;
What would my mapping look like to set the State from that attribute?
Thanks
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users