Announcement Announcement Module
No announcement yet.
get attribute using XStreamMarshaller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • get attribute using XStreamMarshaller


    I have step in spring batch that read xml, process and write, but is a problem to get attributes from xml for elements everything work fine.

    I use:
    springVersion: 3.0.1.RELEASE
    springBatchVersion: 2.1.0.RELEASE
    spring-oxm: 1.5.9
    spring-oxm-tiger: 1.5.9
    spring-oxm: 3.0.1.RELEASE

    my xml where problem is get "num" attribute:

    <?xml version="1.0" encoding="UTF-8"?>
    	<trade num="1296">
    	<trade num="1297">
    	<trade num="1298">
    my job.xml

    <step id="importStep" parent="defaultStep">
    		<chunk reader="reader" processor="processor"
    			writer="writer" commit-interval="1" skip-limit="0">
    <bean id="reader" class="org.springframework.batch.item.xml.StaxEventItemReader" scope="step">
            <property name="fragmentRootElementName" value="trade" />
            <property name="resource" value="file:src/test/resources/xmlFiles/my.xml" />
            <property name="unmarshaller" ref="customerMarshaller" />
        <bean id="customerMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller" scope="step">
            <property name="aliases">
                <util:map id="aliases">
                    <entry key="trade" value="" />
            <property name="useAttributeFor">
                <util:map id="useAttributeFor">
                  <entry key="num">
                    <value type="java.lang.Class"></value>
        <bean id="processor" class="" scope="step"/>
        <bean id="writer" class=""
    my POJO:

    public class Customer implements Serializable{
    	private static final long serialVersionUID = -1410817254992066867L;
    	private String num;
    	private String isin;
    	private String quantity;
    	private String price;
    	private String customer;
    	public String getIsin() {
    		return isin;
    	public void setIsin(String isin) {
    		this.isin = isin;
    	public String getQuantity() {
    		return quantity;
    	public void setQuantity(String quantity) {
    		this.quantity = quantity;
    	public String getPrice() {
    		return price;
    	public void setPrice(String price) {
    		this.price = price;
    	public String getCustomer() {
    		return customer;
    	public void setCustomer(String customer) {
    		this.customer = customer;
    	public String getNum() {
    		return num;
    	public void setNum(String num) {
    		this.num = num;

    In MyProcessor I get null for getNum() but for elements tag is OK.

    Please healp.