I have this class model:
abstract class A {
int a;
}
class B extends A {
int b;
}
class C extends B {
int c;
}
And I'd like to get jibx to output this XML:
<B b=1 a=0>
<children>
<C c=2 b=1 a=0/>
</children>
</B>
I have this binding xml:
<binding>
<mapping class="A" abstract="true">
<value name="a" field="a" style="attribute" usage="optional"/>
<collection field="children" type="java.util.ArrayList"/>
</mapping>
<mapping name="B" class="B" extends="A">
<value name="b" field="b" style="attribute" usage="optional"/>
<structure map-as="A"/>
</mapping>
<mapping name="C" class="C" extends="B">
<value name="c" field="c" style="attribute" usage="optional"/>
<structure map-as="B"/>
</mapping>
</binding>
However I keep getting artifacts like this:
<C c=2>
<B b=1 a=0>
<children>
...
</children>
</B>
</C>
As temporary solution I've changed my inheritance structure to have AbstractB and B extends AbstractB and C extends AbstractB, but it really annoys me to have to redesign my class because of jibx.
Anyone knows how to solve this?
Edit: As a bonus question - how do you use code/decode java.util.Map with Jibx? I know it can't be done natively (would be glad to be disproved!) but what would you do to code Map (no strings). Please note we're not using jibx-extras.jar, so solutions should not rely on it.