Hello,
I have configured a StaxEventItemReader to read correctly the following XML file as input:
My problem is that I need to have a Fragment like this in order to store each item in my DB:Code:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <Export> <Header> <Material>Material</Material> <Address>Address</Address> </Header> <Body> <Item> <RefDate>RefDate1</RefDate> <NameSurname>Name1</NameSurname> <Value>80</Value> </Item> <Item> <RefDate>RefDate2</RefDate> <NameSurname>Name2</NameSurname> <Value>42.9</Value> </Item> <Item> <RefDate>RefDate3</RefDate> <NameSurname>Name3</NameSurname> <Value>87.2</Value> </Item> </Body> </Export>
- Material
- Address
- RefDate
- NameSurname
- Value
But the "Material" and "Address" node are in the "Header" node and not directly in the "Item".
How can I manage this composite fragment?
Which node ROOT should I use as fragmentRootElementName property of the StaxEventItemReader? Is it "Export" node or "Item" node?
THANK YOU!Code:<bean id="itemReader" class="org.springframework.batch.item.xml.StaxEventItemReader"> <property name="fragmentRootElementName" value="???" /> <property name="resource" value="data/iosample/input/input.xml" /> <property name="unmarshaller" ref="myMarshaller" /> </bean>


Reply With Quote