I don't think this can be done, to be honest. It's exactly the fact that you want to mix and match artifacts from different (object) levels that causes this.

Regards
Werner

farhad ch wrote:
Does anybody know how to do this? Problem is children referencing an attribute of parent.

----- Original Message ----
From: farhad ch <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, March 4, 2008 7:49:20 AM
Subject: Re: [castor-user] Flattening structure for XML

public class Foo {
  private int id;
  private List<Child> children;
  public Foo(int id, List<Child> children){
     this.id <http://this.id> = id;
     this.children = children;
  }
//add setter and getters here
}

public class Child {
     private String name;
     public Child(String name){
        this.name <http://this.name> = name;
    }
    //add setter and getters here
}

Caller class is something like:
    List foos = new ArrayList<Foo>();

    List<Child> children1 = new ArrayList<Child>();
    children1.add(new Child("a"));
    children1.add(new Child("b"));
    children1.add(new Child("c"));
    Foo foo1 = new Foo(1,children1);
    foos.add(foo1);

    List<Child> children2 = new ArrayList<Child>();
    children2.add(new Child("aa"));
    children2.add(new Child("bb"));
    children2.add(new Child("cb"));
    Foo foo2 = new Foo(2,children2);
    foos.add(foo2);

I need to [un]Marshall foos like below as communication between two separate systems:
<Foos>
  <Foo id="1" childName="a"/>
  <Foo id="1" childName="b"/>
  <Foo id="1" childName="c"/>
  <Foo id="2" childName="aa"/>
  <Foo id="2" childName="bb"/>
  <Foo id="2" childName="cc"/>
</Foos>


----- Original Message ----
From: Werner Guttmann <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, March 4, 2008 4:55:59 AM
Subject: Re: [castor-user] Flattening structure for XML

Not sure whether I understand you correctly. What does do the objects
look like ?

Werner

farhad ch wrote:
 > I have list of objects like "Foo" which contains an "id" attribute and a
 > collection of children and want to flat them during marshaling:
 >
 > public class Foo{
 >  int id;
 >  List<Children> children
 > }
 > Creating a nested list is not complex but I would like to have something
 > like:
 > <Foos>
 >  <Foo id="1" childName="a"/>
 >  <Foo id="1" childName="b"/>
 >  <Foo id="1" childName="c"/>
 >  <Foo id="2" childName="aa"/>
 >  <Foo id="2" childName="bb"/>
 >  <Foo id="2" childName="cc"/>
 > </Foos>
 > How can you map these?
 >
 > ------------------------------------------------------------------------
 > Never miss a thing. Make Yahoo your homepage.
 > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




------------------------------------------------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo! Search. <http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>


------------------------------------------------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ >


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to