Mar 12th, 2008, 08:17 AM
StaxEventItemWriter creates invalid xml for zero row documents
The seems to be a minor bug in org.springframework.batch.io.xml.StaxEventItemWrit er which causes it to generate invalid xml for output files that have zero rows e.g.
<?xml version='1.0' encoding='UTF-8'?><modules</modules>
<?xml version='1.0' encoding='UTF-8'?><modules></modules>
It looks like it is due to the frig in endDocument() which writes the end tag manually.
I have subclassed it in my project and overridden the endDocument() and added another event to the writer (writer.add(factory.createCharacters(""))), to get round this problem. This extra 'useless' event seems to result in the startElement event being rendered correctly.
Mar 12th, 2008, 09:07 AM
Thanks for pointing out, I've copy-pasted your description into a JIRA issue: