Okay, the way you load the mapping is just fine (as there's plenty of
folks using one of the static methods for unmarshalling).
[EMAIL PROTECTED] wrote:
> Hi Werner,
>
> The unmarshaller is called like this:
>
> Mapping mapping = new Mapping();
> mapping.loadMapping("src-resource/castorMapping.xml");
>
> Unmarshaller unmarshaller = new Unmarshaller(clazz);
> unmarshaller.setMapping(mapping);
> obj = unmarshaller.unmarshal(reader);
>
>
> Am I right in thinking that I need only define the error class in the
> mapping file? I have not defined the container class and assumed that
> the error class fields will be overridden?
It depends; for completeness sake, can you please define a class mapping
for the container class as well, and check whether this makes a
difference ?
>
> I appreciate your help.
>
> Thanks,
>
> Dan.
>
> Quoting Werner Guttmann <[EMAIL PROTECTED]>:
>
>> Hmm, with the given mapping, this should work out of the box. How are
>> you actually calling the Unmarshaller ? What does the code sequence look
>> like ?
>>
>> Werner
>>
>> [EMAIL PROTECTED] wrote:
>>> Hi all,
>>>
>>> I have a situation where my application may receive XML attributes with
>>> underscored names:
>>>
>>> <CONTAINER KEY="1"><ERROR _MSGNO="1002" _MSGTEXT="Message Text"
>>> /></CONTAINER>
>>>
>>> My Java objects are CONTAINER and ERROR, and although the error object
>>> is correctly set on the container, the attributed of the error object
>>> are always null.
>>>
>>> However if I modify the XML and remove the underscore from the attribute
>>> names both are set correctly.
>>>
>>> I have names my variables in the ERROR class variants of _MSGNO and
>>> MSGNO with no effect. I have also tried to manually map the fields like
>>> this:
>>>
>>> <mapping>
>>> <class name="my.package.ERROR">
>>> <map-to xml="ERROR" />
>>>
>>> <field name="MSGTEXT" type="java.lang.String">
>>> <bind-xml name="_MSGTEXT" node="attribute"/>
>>> </field>
>>>
>>> <field name="MSGNO" type="java.lang.String">
>>> <bind-xml name="_MSGNO" node="attribute"/>
>>> </field>
>>> </class>
>>> </mapping
>>>
>>> Am I missing something?
>>>
>>> Kind Regards,
>>>
>>> Dan
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
>
>
>
> ---------------------------------------------------------------------
> 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