Lukas,

Thanks, that did indeed generate the XML I need.  Now I can marshal
but on unmarshalling I get:

Type conversion error: could not set value of
allergies(java.lang.String) with value of type java.lang.String
        at 
org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:794)

Any ideas?

Thanks in advance,

Ryan

On Mon, Jul 13, 2009 at 2:27 PM, Lukas Lang<[email protected]> wrote:
> Hey Ryan,
>
> Castor XML supports the declaration of a 'location' attribute. The
> marshalled data is put under this tag. Please try the following mapping
> for your field:
>
>    <field name="allergies" type="java.lang.String">
>      <bind-xml name="allergy" location="allergies" />
>    </field>
>
> The output in my case is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <entity>
>    <allergies>
>        <allergy>a</allergy>
>        <allergy>b</allergy>
>    </allergies>
> </entity>
>
> Hope that helps!
>
> Regards,
> Lukas
>
> Ryan Sutter schrieb:
>> Hi,
>>
>> I have a Java POJO with a String[] getAllergies() and
>> setAllergies(String[] allergies) method.  I need to produce XML that
>> looks like this:
>>
>> <?xml version="1.0"?>
>> <RxRefill>
>> <MemberInquiryResponse>
>> ...
>> <allergies>
>> <allergy>Allergy1</allergy>
>> <allergy>Allergy2</allergy>
>> </allergies>
>> ...
>> </MemberInquiryResponse>
>> </RxRefill>
>>
>> My current mapping file looks like this:
>>
>>                <field name="allergies" collection="array" type="strings"
>>                        container="false">
>>                        <bind-xml name="allergies" node="element">
>>                        </bind-xml>
>>                </field>
>>
>> And produces XML like this:
>>
>> <?xml version="1.0"?>
>> <RxRefill>
>> <MemberInquiryResponse>
>> ...
>> <allergies>
>> <string>Allergy1</string>
>> <string>Allergy2</string>
>> </allergies>
>> ...
>> </MemberInquiryResponse>
>> </RxRefill>
>>
>> How to I configure a String[] mapping to specify the element name that
>> will be used for each item so I can map to "<allergy>" instead of
>> "<string>"?
>>
>> Thanks!
>>
>> Ryan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>



-- 
http://ryansutter.net

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to