Dave-

In Castor such a process is fairly easy. Using a mapping file, you can specify that the <name1> and <name2> elements reside inside <bar> using the location attribute. Here's an example:

<mapping>
   <class name="Foo">
      <map-to xml="foo" />
      <field name="name1" type="string" />
         <bind-xml name="name1" location="bar" />
      </field>
      <field name="name2" type="string" />
         <bind-xml name="name2" location="bar" />
      </field>
   </class>
</mapping>

I only ask that you realize I just wrote that into an e-mail and haven't tested it, so there may be some bugs, but that is the general idea. Let me know if you have any questions.

See also:
http://castor.codehaus.org/xml-mapping.html

Stephen

Zaleta, David wrote:
I am trying to map some xml like:

<foo>
        <bar>
                <name1>val1</name1>
            <name2>val2</name2>
      <bar>
<foo>


I would like to have a single object to hold all of this, something
like:

public class Foo {

        private String name1;
        private String name2;

        ....

        //of course appropriate getters and setters
}


So I basically want to remove the bar when unmarshalling and flatten the
xml hierarchy.
Of course, *IF* I had control of the input xml I could just respecify,
unfortunately I do
not have that control.
So what is the special mapping incantation to make this happen?  Or do I
need to write some
customer handler to make this happen (hoping not since I have never done
this before).

later

dave z

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