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?

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


Reply via email to