I am using JibX as a Java Object to XML Binding tool.
With it, I want to have the following output:
<?xml version='1.0' encoding='UTF-8'?> <FEAPService> <Request> <Function>aaa</Function> <SubFunction>bbb</SubFunction> <Operation>ccc</Operation> </Request> </FEAPService>
But I’m getting this:
<?xml version='1.0' encoding='UTF-8'?> <FEAPService> <Request> <baseForm> <!-- I DO NOT WANT THIS baseForm TAG --> <Function>aaa</Function> <SubFunction>bbb</SubFunction> <Operation>ccc</Operation> </baseForm> </Request> </FEAPService>
Here’s the JibX binding file:
<binding name='requestBinding_com_struts_form_SpecificForm'> <mapping name='baseForm' class='com.struts.form.BaseForm'> <value name='Function' field='function' /> <value name='SubFunction' field='subFunction' /> <value name='Operation' field='operation' /> </mapping> <mapping name='FEAPService' class='com.struts.form.SpecificForm' extends='com.struts.form.BaseForm'> <structure name='Request'> <structure map-as='com.struts.form.BaseForm' /> </structure> </mapping> </binding>
I guess it might be achieved by implementing my own Marshaller, but I’m not sure if that’s the easiest way.
I managed to remove the undesired XML node, there are 2 ways:
1st option:
2nd option: implement your own Marshaller:
And here is my binding.xml: