Hi all,

I need to marshal a given object model to a given xml, but I can't persuade
Castor to do as needed.
This is the problem:
I have two java types A and B where B has a field "id" and A holds
references to B. Now I need the field "id" of B as an attribute of the xml
element <a>, that represents A.

class A{
  B[] field;
}

class B{
  String id;
  int value;
}

a collection of objects of type A shall be marshalled to some xml like this:

<data>
  <a id="b1">
    <value>15</value>
    <value>8</value>
  </a>
  <a id="b2">
    <value>12</value>
    <value>17</value>
    <value>8</value>
    <value>3</value>
  </a>
</data>

Somehow I can't see, how I can split the fields of the B type into an
attribute "id" of the <a> element and a child element <value> of the <a>
element.


I appreciate any help

best regards, Georg

Reply via email to