<?xml version="1.0" encoding="UTF-8"?>
<transaction>
<createDate>20160708</createDate>
<dlrCode>100<dlrCode/>
<rec>
<processDate>20190108</processDate>
<srcID/>10<srcID/>
</rec>
<rec>
<processDate>20190108</processDate>
<srcID/>11<srcID/>
</rec>
<rec>
<processDate>20190108</processDate>
<srcID/>12<srcID/>
</rec>
</transaction>
<?xml version="1.0" encoding="UTF-8"?>
<beanio xmlns="http://www.beanio.org/2012/03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">
<stream name="dist" format="xml" xmlName="transaction" >
<record name="HeaderRecord" class="com.myPackage.HeaderRecord" minOccurs="1" maxOccurs="1" order="1" >
<field name="createDate" format="yyyyMMdd" />
<field name="dlrCode" />
</record>
<record name="DisRecord" class="com.myPackage.Record" minOccurs="0" maxOccurs="unbounded" xmlName="rec" order="2">
<field name="processDate" format="yyyyMMdd"/>
<field name="srcID"/>
</record>
</stream>
</beanio>
But the problem is, it generates the header fields inside the HeaderRecord node like this:
<?xml version="1.0" encoding="UTF-8"?>
<transaction>
<HeaderRecord>
<createDate>20160708</createDate>
<dlrCode>100<dlrCode/>
</HeaderRecord>
<rec>
<processDate>20190108</processDate>
<srcID/>10<srcID/>
</rec>
<rec>
<processDate>20190108</processDate>
<srcID/>11<srcID/>
</rec>
<rec>
<processDate>20190108</processDate>
<srcID/>12<srcID/>
</rec>
</transaction>
Is there something misconfigured in the mapping file? How to resolve it?
I'm really blocked on it, Thanks every one in advance
Here are the POJO's (Header and Detail):
public class HeaderRecord implements Serializable {
private static final long serialVersionUID = 1L;
private Date createDate;
private String dlrCode;
//setter and getter
}
public class Record implements Serializable {
private static final long serialVersionUID = 1L;
private Date processDate;
private String srcID;//setter and getter}
Don't you have another a POJO that is composed of the 'HeaderRecord' and a List<Record> of 'Records'?
<stream name="dist" format="xml" xmlType="none">
<record name="HeaderRecord" class="com.mypackage.HeaderRecord" minOccurs="1" maxOccurs="1" xmlName="transaction">
<field name="createDate" format="yyyyMMdd" />
<field name="dlrCode" />
</record>