PDA

View Full Version : StaxEventItemWriter creates invalid xml for zero row documents



Andy M
Mar 12th, 2008, 08:17 AM
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>

rather than

<?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.

robert.kasanicky
Mar 12th, 2008, 09:07 AM
Thanks for pointing out, I've copy-pasted your description into a JIRA issue:

http://jira.springframework.org/browse/BATCH-448