diff --git a/src/site/docbook/reference/readersAndWriters.xml b/src/site/docbook/reference/readersAndWriters.xml
index 7d8574151..5a36e2200 100644
--- a/src/site/docbook/reference/readersAndWriters.xml
+++ b/src/site/docbook/reference/readersAndWriters.xml
@@ -1530,25 +1530,14 @@ assertEquals(born, values[2]);
<bean id="itemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
- <property name="fragmentRootElementName" value="customer" />
+ <property name="fragmentRootElementName" value="trade" />
<property name="resource" value="data/iosample/input/input.xml" />
- <property name="unmarshaller" ref="customerCreditMarshaller" />
+ <property name="unmarshaller" ref="tradeMarshaller" />
</bean>
-
-<bean id="customerCreditMarshaller"
- class="org.springframework.oxm.xstream.XStreamMarshaller">
- <property name="aliases">
- <util:map id="aliases">
- <entry key="customer"
- value="org.springframework.batch.sample.domain.CustomerCredit" />
- <entry key="price" value="java.math.BigDecimal" />
- <entry key="name" value="java.lang.String" />
- </util:map>
- </property>
-</bean>
+
Notice that in this example we have chosen to use an
- XStreamMarshaller that requires an alias passed
+ XStreamMarshaller which accepts an alias passed
in as a map with the first key and value being the name of the fragment
(i.e. root element) and the object type to bind. Then, similar to a
FieldSet, the names of the other elements that
@@ -1556,18 +1545,12 @@ assertEquals(born, values[2]);
the map. In the configuration file we can use a Spring configuration
utility to describe the required alias as follows:
- <bean id="itemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
- <property name="fragmentRootElementName" value="customer" />
- <property name="resource" value="data/iosample/input/input.xml" />
- <property name="unmarshaller" ref="customerCreditMarshaller" />
-</bean>
-
-<bean id="customerCreditMarshaller"
+ <bean id="tradeMarshaller"
class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="aliases">
<util:map id="aliases">
- <entry key="customer"
- value="org.springframework.batch.sample.domain.CustomerCredit" />
+ <entry key="trade"
+ value="org.springframework.batch.sample.domain.Trade" />
<entry key="price" value="java.math.BigDecimal" />
<entry key="name" value="java.lang.String" />
</util:map>
@@ -1590,14 +1573,14 @@ assertEquals(born, values[2]);
Resource resource = new ByteArrayResource(xmlResource.getBytes())
Map aliases = new HashMap();
-aliases.put("customer","org.springframework.batch.sample.domain.CustomerCredit");
+aliases.put("trade","org.springframework.batch.sample.domain.Trade");
aliases.put("price","java.math.BigDecimal");
-aliases.put("name","java.lang.String");
+aliases.put("customer","java.lang.String");
Marshaller marshaller = new XStreamMarshaller();
marshaller.setAliases(aliases);
xmlStaxEventItemReader.setUnmarshaller(marshaller);
xmlStaxEventItemReader.setResource(resource);
-xmlStaxEventItemReader.setFragmentRootElementName("customer");
+xmlStaxEventItemReader.setFragmentRootElementName("trade");
xmlStaxEventItemReader.open(new ExecutionContext());
boolean hasNext = true
@@ -1620,8 +1603,8 @@ while (hasNext) {
Output works symmetrically to input. The
StaxEventItemWriter needs a
- Resource, a serializer, and a rootTagName. A Java
- object is passed to a serializer (typically a wrapper around Spring OXM
+ Resource, a marshaller, and a rootTagName. A Java
+ object is passed to a marshaller (typically a standard Spring OXM
Marshaller) which writes to a
Resource using a custom event writer that filters
the StartDocument and
@@ -1649,7 +1632,7 @@ while (hasNext) {
<util:map id="aliases">
<entry key="customer"
value="org.springframework.batch.sample.domain.CustomerCredit" />
- <entry key="price" value="java.math.BigDecimal" />
+ <entry key="credit" value="java.math.BigDecimal" />
<entry key="name" value="java.lang.String" />
</util:map>
</property>
@@ -1664,7 +1647,7 @@ FileSystemResource resource = new FileSystemResource("data/outputFile.xml")
Map aliases = new HashMap();
aliases.put("customer","org.springframework.batch.sample.domain.CustomerCredit");
-aliases.put("price","java.math.BigDecimal");
+aliases.put("credit","java.math.BigDecimal");
aliases.put("name","java.lang.String");
Marshaller marshaller = new XStreamMarshaller();
marshaller.setAliases(aliases);