I am making use of Spring Batch and i want to find out if it is possible to modify a file after it was written by a Spring Batch writer or if there are any other solutions for tackling my problem.
Currently my Spring Batch HeaderCallback creates the Header section that includes the Summary tags as well.
The problem i am facing is i do not have the NumberOfSuccessfulTransactions / NumberOfFailedTransactions up front to populate the Summary section in the XML. I only have this once all the chunks have been processed.
I cannot move the Summary section to the FooterCallback section when spring batch writes the file because the file gets validated against a XSD that is sequence aware. Sequence is Header , Summary then Transactions.
The sample of the XML that needs to be followed to create the output file is as follow :
<Doc>
<Header>
<Id></Id>
<CreationDate></CreationDate>
<Header>
<Summary>
<NumberOfSuccessfulTransactions></NumberOfSuccessfulTransactions>
<NumberOfSuccessfulTransactions></NumberOfFailedTransactions>
<Summary>
<Transaction>
<ErrorCode></ErrorCode>
<ErrorDescription></ErrorDescription>
<Transaction>
<Transaction>
<ErrorCode></ErrorCode>
<ErrorDescription></ErrorDescription>
<Transaction>
<Transaction>
<ErrorCode></ErrorCode>
<ErrorDescription></ErrorDescription>
<Transaction>
<Transaction>
<ErrorCode></ErrorCode>
<ErrorDescription></ErrorDescription>
<Transaction>
<Transaction>
<ErrorCode></ErrorCode>
<ErrorDescription></ErrorDescription>
<Transaction>
<Doc>