Hi-
I've just started
using Castor and am excited about its potential, but I've run into a
problem. I would like to map two fields to a single wrapper
element. I tried using the 'location' attribute of bind-xml, but it
yielded two wrapper elements. The example below, I hope, will make
this clearer. Is it possible to nest multiple elements within
a single wrapper element?
Thanks,
Dan
Marcus
Given a bean like
this:
public class Foo
{
private int barLeft;
private int barRight;
public int getBarLeft(){
return
barLeft;
}
public int getBarRight(){
return barRight;
}
}
I would like to
create xml like this:
<foo>
<bar>
<left/> <!-- Note
left and right are both within a single bar-->
<right/>
</bar>
</foo>
Unfortunately, using
the mapping below, it looks like this:
<foo>
<!-- Note the 2 bar elements! -->
<bar>
<left>0</left>
<bar>
<bar>
<right>5</right>
<bar>
</foo>
Here's
the mapping:
<class
name="Foo">
<map-to xml="foo"/>
<field name "barLeft" type="integer">
<bind-xml name="left"
location="bar" node="element"/>
</field>
<field name "barLeft" type="integer">
<bind-xml name="right"
location="bar" node="element"/>
</field>
</class>
