-
1. Re: Write XML using XSD
cfang Jan 25, 2017 6:12 PM (in response to richardmoore)jberet-support contains reader and writers for flat files and xml files (see jberet-support javadocs):
org.jberet.support.io.BeanIOItemReader
org.jberet.support.io.BeanIOItemWriter
org.jberet.support.io.XmlItemReader
org.jberet.support.io.XmlItemWriter
So you can use BeanIOItemReader for reading from flat files and XmlItemWriter for writing to xml output. jberet-support tests directory should have tests for how to use BeanIOItemReader and XmlItemWriter. For BeanIO reader, you will need to create a mapping file (required by BeanIO) to detail how to map input data fields to model object fields.
Example BeanIO mapping files:
star-entity-beanio-mapping.xml
Since the mapping is offloaded to the mapping file, the job.xml file for BeanIO reader is relatively simple:
org.jberet.support.io.BeanIOReaderWriterTest.xml
XmlItemWriter uses jackson libraries behind the scene, and usually it can automatically generate xml document from your mode objects (e.g., Person.class, Employee.class, etc). In some cases, you will need to add a few jackson annotations to your model class to help the conversion.
Example xmlItemWriter job.xml:
-
2. Re: Write XML using XSD
cfang Jan 25, 2017 6:15 PM (in response to cfang)there is no automatical way to write an object to xml based on its xsd. If you use jberet-support xmlItemWriter, the mapping happens in your model class in the form of jackson and/or jaxb mapping annotations.