I have an input xml, which i need to parse and bind using JibX.
We make use of a value in a specific node() of our xml to determine the type of child class that has to be initialized.
sample.xml
<MainClass>
<TypeCode>ChildClassType</TypeCode>
<!--Optional:-->
<ChildClassOne_Attribute1></ChildClassOne_Attribute1>
<!--Optional:-->
<ChildClassOne_Attribute2></ChildClassOne_Attribute2>
<!--Optional:-->
<ChildClassTwo_Attribute1></ChildClassTwo_Attribute1>
<!--Optional:-->
<ChildClassTwo_Attribute2></ChildClassTwo_Attribute2>
<!--Optional:-->
<ChildClassThree_Attribute></ChildClassThree_Attribute>
</MainClass>
Is is possible in JibX to parse the above xml and initialize one of the three classes - ChildClassOne, ChildClassTwo, ChildClassThree, based on the 'TypeCode'.
My end result should look like,
Class MainClass{
String TypeCode
}
If my TypeCode is "TypeOne" I need "ChildClassOne" to be initialized
Class ChildClassOne extends MainClass{
ChildClassOne_Attribute1;
ChildClassOne_Attribute2;
}
If my TypeCode is "TypeTwo" I need "ChildClassTwo" to be initialized
Class ChildClassTwo extends MainClass{
ChildClassTwo_Attribute1;
ChildClassTwo_Attribute2;
}
If my TypeCode is "TypeThree" I need "ChildClassThree" to be initialized
Class ChildClassThree extends MainClass{
ChildClassThree_Attribute;
}
Is this possible in JibX or am i asking too much??
Thanks in advance Praveen