I was able to convert csv to xml using code My question is what changes are needed in EmployeeDTO.java to get the expected output below -( I want the child attributes to be displayed)
MY EmployeeDTO.java
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@CsvRecord(separator = ",", skipFirstLine = true)
public class EmployeeDTO implements Serializable{
@XmlAttribute
@DataField(pos = 1)
private int employeeId;
@XmlAttribute
@DataField(pos = 2)
private String firstName;
@XmlAttribute
@DataField(pos = 3)
private String lastName;
@XmlAttribute
@DataField(pos = 4)
private String role;
}
And camel-context.xml is
<bean id="bindyDataformat" class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat">
<constructor-arg value="com.fusesource.sample.dto" />
</bean>
class="com.fusesource.samples.FileServiceRoute"/>
-->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent" disabled="false" />
<route>
<from uri="file:src/data?noop=true" />
<unmarshal ref="bindyDataformat" />
<to uri="file://TESTOUT?fileName=sampada.xml"/>
</route>
</camelContext>
Actual Output xml file
<?xml version='1.0' encoding='UTF-8'?>
<list>
<map>
<entry>
<string>com.fusesource.sample.dto.EmployeeDTO</string>
<com.fusesource.sample.dto.EmployeeDTO>
<employeeId>23445</employeeId>
<firstName>Ambarish</firstName>
<lastName>Deshpande</lastName>
<role>Java Lead</role>
</com.fusesource.sample.dto.EmployeeDTO>
</entry>
</map>
</list>
EXPECTED OUTPUT
<Employees id="" total="">
<Employee>
<employeeId id="" reportGroup="">23445</employeeId>
<firstName>Ambarish</firstName>
<lastName>Deshpande</lastName>
<role>Java Lead</role>
</Employee>
<Employees>