Spring Batch
  1. Spring Batch
  2. BATCH-448

StaxEventItemWriter creates invalid xml for zero row documents

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0.m5
    • Fix Version/s: 1.0.0.rc1
    • Component/s: Infrastructure
    • Labels:
      None

      Description

      Copied from http://forum.springframework.org/showthread.php?t=51054 :

      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.

        Activity

        Hide
        Robert Kasanicky added a comment -

        As suggested, fixed by adding the empty character event before writing the end tag manually.

        Show
        Robert Kasanicky added a comment - As suggested, fixed by adding the empty character event before writing the end tag manually.
        Hide
        Dave Syer added a comment -

        Assume closed as resolved and released

        Show
        Dave Syer added a comment - Assume closed as resolved and released

          People

          • Assignee:
            Robert Kasanicky
            Reporter:
            Robert Kasanicky
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1h
              1h
              Remaining:
              Remaining Estimate - 1h
              1h
              Logged:
              Time Spent - Not Specified
              Not Specified