I have a XML input files (very large) which must be processed in the following way:
- read each item X from xml file
- for each item X change some fields (such updated X will be denoted as X')
- write all updated X' items to new file
- transform each item X' to some new object Y
- write each transformed Y object to some other new file
Because input/output files are big, I used StaxItemReader and StaxItemWriter to read/write files. In the mean time I have implemented ComposedItemProcessor which transforms X to X' and then X' to Y. The question is: how can I easily use StaxItemWriter to write both: X' and Y?
The easiest way is to process in two steps:
- read from file -> transform to X' -> save X' to file UPDATED_X.xml
- read file UPDATED_X.xml -> transform to Y -> save Y in file Y.xml
but I would like to avoid unnecessary parsing.. Is possible to fork job and write both X' and Y?