On 8/17/05, Zaleta, David <[EMAIL PROTECTED]> 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).

Dave, 

A common manner in which to achieve this type of behavior is to set
the container attribute on the field element to true in the XML
mapping descriptor. This tells Castor that the field is not to be
considered a first class object. However, please note that the
container attribute is typically used for objects like
java.util.Collections and will cause only the fields of each object in
the collection to be marshalled, not the objects themselves. I highly
suggest reading through this description from Keith:

    http://tinyurl.com/bg834

This email is posted on the wiki, but it appears that the machine
hosting the wiki is down right now and is out of our control. Google
cache to the rescue!

Bruce 
-- 
perl -e 'print unpack("u30","D0G)[EMAIL 
PROTECTED]&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

The Castor Project
http://www.castor.org/

Apache Geronimo
http://geronimo.apache.org/

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

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

Reply via email to