As Stephen points out in another post, I seem to have learned today how to 
do this. I am sure someone on the list will correct me if I get it wrong.

I have left out the namespace specifications but you can easily put them 
back in.

<class name="edu.umich.med.cacr.hb.Person">
   <field name="postalAddresses" collection="map">
      <bind-xml name="address" node="element" />
       <class name="org.exolab.castor.mapping.MapItem">
         <field name="key" type="string">
           <bind-xml name="type" node="attribute" />
         </field>
         <field name="value" type="edu.umich.med.cacr.hb.PostalAddress">
           <bind-xml name="address" />
         </field>
       </class>
   </field>
</class>

I *think* that should do it!

Jessica


On Tue, Dec 20, 2005 at 03:43:26PM -0500, Adam Kramer wrote:
> Hi all,
> 
> My first post...
> 
> I has a Person class that has a map of postalAddresses. Each postal 
> address has a key of 'type'. I'd like to marshall the addresses into a 
> form where hte key was an attribute and the value was output as <address>:
> 
> <person>
>      <address type="primary">
>           <street>12424 lane lane</street>
>            <state>MI</state>
>            <postalCode>12421</postalCode>
>            <city>Bobville</city>
>            <country>US</country>
>      </address>
>      <address type="secondary">
>       ....
>      </address>
> </person>
> 
> Right now, I can only get the mapping output that the default 
> MappingItem class sets which is
> <address>
>        <key>Primary</key>
>        <value>
>            <street>12424 lane lane</street>
>            <state>MI</state>
>            <postalCode>12421</postalCode>
>            <city>Bobville</city>
>            <country>US</country>
>        </value>
> </address>
> 
> Any help is greatly appreciated.
> 
> This is what I currently have for my mapping below:
> <class cst:name="edu.umich.med.cacr.hb.Person">
>    <field cst:name="postalAddresses" 
> cst:type="edu.umich.med.cacr.hb.PostalAddress" collection="map">
>       <bind-xml name="address" node="element" />
>    </field>
> </class>
> 
> <class cst:name="edu.umich.med.cacr.hb.PostalAddress">
>    <field cst:name="streetAddressExt" cst:type="java.lang.String">
>      <bind-xml name="streetExt" node="element" />
>    </field>
>    <field cst:name="streetAddress" cst:type="java.lang.String">
>      <bind-xml name="street" node="element" />
>    </field>
>    <field cst:name="state" cst:type="java.lang.String">
>      <bind-xml name="state" node="element" />
>    </field>
>    <field cst:name="postalCode" cst:type="java.lang.String">
>      <bind-xml name="postalCode" node="element" />
>    </field>
>    <field cst:name="city" cst:type="java.lang.String">
>      <bind-xml name="city" node="element" />
>    </field>
>    <field cst:name="country" cst:type="java.lang.String">
>      <bind-xml name="country" node="element" />
>    </field>
>  </class>
> 
> Thanks,
> Adam Kramer
> 
> 
> -------------------------------------------------
> If you wish to unsubscribe from this list, please 
> send an empty message to the following address:
> 
> [EMAIL PROTECTED]
> -------------------------------------------------
> 

-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to