2
我正在使用JibX作爲Java對象到XML綁定工具。JibX:如何映射類並避免它作爲XML節點輸出
有了它,我想有以下輸出:
<?xml version="1.0" encoding="UTF-8"?>
<FEAPService>
<Request>
<Function>aaa</Function>
<SubFunction>bbb</SubFunction>
<Operation>ccc</Operation>
</Request>
</FEAPService>
但我發現了這一點:
<?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>
這裏的JiBX綁定文件:
<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>
我猜測可能通過實施我自己的Marshaller來實現,但我不確定這是否是最簡單的方法。