0
votes

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?

1

1 Answers

0
votes

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?

In this case, the type of input items of your ComposedItemProcessor is X and the output is Y. Y is the type of items going to your item writer. Hence your item writer would not be able to write X' items.

According to your requirement, write all updated X' items to new file and transform each item X' to some new object Y are what makes your steps inter-dependent. So I guess you would need to proceed in two steps as you mentioned.