Hi Keith, 

Thanks for the reply.  I do have the <map-to> element...Here's a more
inclusive description of what I'm doing:



----------------- input:


<body-element name="server2">
 <person name="mark" />
</body-element>

----- mapping:

<mapping>

  <class name="package.BodyElement" >
    <map-to xml="body-element" />
    <field name="name" type="string">
      <bind-xml name="name" node="attribute" />
    </field>
    <field name="body" type="java.lang.Object">
      <bind-xml auto-naming="deriveByClass"  node="element" />
    </field>
  </class>

  <class name="package.Person">
    <map-to xml="person" />
    <field name="name" type="string">
      <bind-xml name="name" node="attribute" />
    </field>
  </class>

</mapping>

---------  Code:

public class BodyElement {
  String name;
  Object body;

  public Object getBody() {
    return body;
  }

  public void setBody(Object body) {
    this.body = body;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }
}



public class Person {
  String name;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }
}



I have no problems unmarshalling a <person> from a document.  I just
can't seem to get it to be assigned to my body:java.lang.Object field.

Thanks again!




On 9/1/05, Keith Visco <[EMAIL PROTECTED]> wrote:
> Mark,
> 
> If you use deriveByClass you also need "<map-to/>" element in your
> package.Person class mapping eg:
> 
> <class name="package.Person">
>    <map-to xml="person"/>
>    ...
> </class>
> 
> Did you try that?
> 
> --Keith
> 
> Mark Priatel wrote:
> > I'm having problems mapping deriveByType elements into an
> > java.lang.Object propery.  Any help would be appreciated!
> >
> >
> > I have a class:
> >
> > class BodyElement{
> >    String id;
> >    Object body;
> >
> >    set/get methods...
> > }
> >
> >
> > class Person{
> >    String name;
> > }
> >
> >
> > ---------- With mapping:
> >
> > <class name="package.BodyElement">
> >   <map-to xml="body-element" />
> >   <field name="id" type="string">
> >      <bind-xml name="id" node="attribute" />
> >   </field>
> >   <field name="body" type="java.lang.Object">
> >      <bind-xml auto-naming="deriveByClass"  node="element" />
> >   </field>
> > </class>
> >
> > <class name="package.Person">
> >   .. no problems here.
> > </class>
> >
> > ---------- With Input:
> >
> > <body-element id="001" >
> >    <person name="foo" />
> > </body-element>
> >
> > if I change the type to 'package.Person' instead of 'java.lang.Object'
> > this works.  I figured the deriveByClass automatically determined the
> > type, and then would map it to the body property...
> >
> > I've tried using 'location' 'set-method=setBody' etc...I'm sure I'm
> > missing something simple.
> >
> > -------------------------------------------------
> > 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]
> -------------------------------------------------
> 
>

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

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

Reply via email to