Tim,

You need to mark your fields that are zero or more with the appropriate collection attribute as such:

 <field name="localTier" type="integer" collection="arraylist">
    <bind-xml name="loc_tier" node="element" />
 </field>

It's a bit outdated, but take a look at the online documentation here:

http://castor.codehaus.org/xml-mapping.html#3.4-The-%3Cfield%3E-element

--Keith


Urberg, Tim M wrote:
Hello Everyone,

I am using Castor to do XML unmarshalling and the xml I'm mapping to has
an element with zero or 1 occurances.  I was wondering how I could map
this in the xml mapping file.  Here's what I have:

<locations>
        <locations_row>
                <location_id>1</location_id>
                <location_class_id>1</location_class_id>
                <loc_marketing_nm>Marketing Name</loc_marketing_nm>
                <loc_prim_city_nm>City</loc_prim_city_nm>
                <loc_prim_state_cd>State</loc_prim_state_cd>
                <loc_prim_zipcode_cd>zip</loc_prim_zipcode_cd>
        
<loc_prim_street_address>Address</loc_prim_street_address>
                <loc_phone_no>(555) 555-5555</loc_phone_no>*
                <loc_ext_clinic_id>1</loc_ext_clinic_id>*
                <loc_tier>1</loc_tier>*
                <quality_index>1</quality_index>*
                <cost_index>1</cost_index>*
                <ccs_cost_display_dcd>Cost
Display</ccs_cost_display_dcd>*
        </locations_row>
</locations>

The ones with a * next them are the ones that are zero or more. Here's
the xml mapping file:

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN" "http://castor.org/mapping.dtd";>

<mapping>
        <class name="LocationFavorites">
                <map-to xml="locations"/>
                                
                <field name="favoriteClinicLocations"
type="LocationDetail" collection="arraylist">
                        <bind-xml name="locations_row" />
                </field>
        </class>

        <class name="LocationDetail" auto-complete="true">
                <field name="locationId" type="integer">
                        <bind-xml name="location_id" node="element" />
                </field>
                
                <field name="locationClassId" type="integer">
                        <bind-xml name="location_class_id"
node="element" />
                </field>
                
                <field name="locationName" type="java.lang.String">
                        <bind-xml name="loc_marketing_nm" node="element"
/>
                </field>
                
                <field name="locationCity" type="java.lang.String">
                        <bind-xml name="loc_prim_city_nm" node="element"
/>
                </field>
                
                <field name="locationState" type="java.lang.String">
                        <bind-xml name="loc_prim_state_cd"
node="element" />
                </field>
                
                <field name="locationZipCode" type="java.lang.String">
                        <bind-xml name="loc_prim_zipcode_cd"
node="element" />
                </field>
                
                <field name="locationStreetAddress"
type="java.lang.String">
                        <bind-xml name="loc_prim_street_address"
node="element" />
                </field>
                
                <field name="locationPhone" type="java.lang.String">
                        <bind-xml name="loc_phone_no" node="element" />
                </field>
                
                <field name="externalLocationId" type="integer"
transient="true">
                        <bind-xml name="loc_ext_clinic_id"
node="element" />
                </field>
                
                <field name="localTier" type="integer" transient="true">
                        <bind-xml name="loc_tier" node="element" />
                </field>
                
                <field name="qualityIndex" type="integer"
transient="true">
                        <bind-xml name="quality_index" node="element" />
                </field>
                
                <field name="costIndex" type="integer" transient="true">
                        <bind-xml name="cost_index" node="element" />
                </field>
                
                <field name="ccsCostDisplay" type="java.lang.String"
transient="true">
                        <bind-xml name="ccs_cost_display_dcd"
node="element" />
                </field>
        </class>
        
</mapping>

Currently, I'm just using transient to ignore them, which is fine, but
phone number I need and it throws an exception if I leave it the way it
is.  Any suggestions?

Thanks,
Tim
________________________________________
This e-mail and any files transmitted with it are confidential and are intended 
solely for the use of the individual or entity to whom they are addressed. If 
you are not the intended recipient or the individual responsible for delivering 
the e-mail to the intended recipient, please be advised that you have received 
this e-mail in error and that any use, dissemination, forwarding, printing, or 
copying of this e-mail is strictly prohibited.
If you have received this e-mail in error, please immediately notify the HealthPartners Support Center by telephone at (952) 967-6600. You will be reimbursed for reasonable costs incurred in notifying us.

-------------------------------------------------
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