Spring Batch
  1. Spring Batch
  2. BATCH-2049

Support multiple fragmentRootElementNames in StaxEventItemReader

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 3.0.0
    • Component/s: Infrastructure
    • Labels:
      None

      Description

      The StaxEventItemReader currently supports only one fragmentRootElementName. This means you cannot process files with a structure as follows:

       
      <root>
        <itemA />
        <itemC />
        <itemA />
        <itemA />
        <itemB />
        <itemA />
        <itemB />
        ...
      </root>
      

      You should be able to configure the StaxEventItemReader with a list of fragmentRootElementNames.

      <bean id="itemReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
          <property name="fragmentRootElementNames" value="itemA,itemB,itemC" />
          ...
      </bean>
      

      The workaround creating a custom MultiFragmentStaxEventItemReader extending StaxtEventItemReader as described on http://forum.springsource.org/showthread.php?88618-Reading-mutilple-element-types-with-StaxEventItemReader doesn't work. To make it properly restartable you would need access to the private XMLEventReader in the jumpToItem(int) method.

        Activity

        Hide
        Jimmy Praet added a comment -
        Show
        Jimmy Praet added a comment - pull request: https://github.com/SpringSource/spring-batch/pull/189

          People

          • Assignee:
            Michael Minella
            Reporter:
            Jimmy Praet
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: