栗子:
binding.xml
<?xml version="1.0" encoding="UTF-8"?>
<binding>
<mapping name="Transaction" class="com.robgao.test.jibx.test.bean.Transaction">
<value name="RetailStoreID" field="retailStoreID" />
<structure name="BusinessUnit" field="businessUnit">
<structure name="UnitID" field="unitID">
<value name="TypeCode" style="attribute" field="typeCode" />
<value style="text" field="unitid"></value>
</structure>
</structure>
<structure usage="optional"
get-method="getIgnored" set-method="setIgnored"
marshaller="org.jibx.extras.DiscardElementMapper" unmarshaller="org.jibx.extras.DiscardElementMapper" />
</mapping>
</binding>
JAVA Bean:
package com.robgao.test.jibx.test.bean;
public class Transaction {
private int retailStoreID;
private BusinessUnit businessUnit;
public int getRetailStoreID() {
return retailStoreID;
}
public void setRetailStoreID(int retailStoreID) {
this.retailStoreID = retailStoreID;
}
public BusinessUnit getBusinessUnit() {
return businessUnit;
}
public void setBusinessUnit(BusinessUnit businessUnit) {
this.businessUnit = businessUnit;
}
private void setIgnored(Object ignore) {
}
private Object getIgnored() {
return null;
}
}