<beans:property name="resource" ref="outputFile" />
<beans:property name="marshaller" ref="customerMarshaller" />
<beans:property name="rootTagName" value="customers" />
<chunk reader="customerFileReader" writer="xmlOutputWriter"
<step id="step1" parent="formatStep"/>
Of the 69 lines of XML that it took to configure the original formatJob as shown in Listing 9-7, the
formatJob in Listing 9-19 has changed only 14 lines (shortening the file overall by one line). The changes
begin with the definition of a new ItemWriter, xmlOutputWriter . This bean is a reference to the
StaxEventItemWriter the section has been talking about and defines three dependencies: the resource to
write to, the Marshaller implementation, and the root tag name for each XML fragment the Marshaller
Just below xmlOutputWriter is customerMarshaller . This bean is used to generate an XML fragment
for each item the job processes. Using Spring's org.springframework.oxm.xtream.XStreamMarshaller
class, the only further configuration you're required to provide is a Map of aliases to use for each type the
Marshaller comes across. By default, the Marshaller uses the attribute's name as the tag name, but you
provide an alias for the Customer class because the XStreamMarshaller uses the fully qualified name for
the class by default as the root tag of each fragment ( com.apress.springbatch.chatper8.Customer instead
of just customer).
In order for the job to be able to compile and run, you need to make one more update. The POM file
needs a new dependency to handle the XML processing, a reference to Spring's Object/XML Mapping
(OXM) library. Listing 9-20 shows the update to the POM that is required.