Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12091

Splitting large Xml files using Camel by having root tags. inheritNamespaceTagName="*" not working as expected.

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      Hi,

      Tried splitting large xml files into 10-10 elements each which has suppose 100 elements (say <ItemType>) with root tag as <ItemImport>. All 10 new splitted xml should have one root tag <ItemImport> on top as in original xml. Example below.

      <ItemImport Priority="0" FillType="FullIncremental" Version="1.0">
      <ItemType> </ItemType>
      <ItemType> </ItemType>
      <ItemType> </ItemType>
      <ItemType> </ItemType>
      <ItemType> </ItemType>
      ....
      </ItemImport>

      Output needed:
      1. xml:
      <ItemImport Priority="0" FillType="FullIncremental" Version="1.0">
      <ItemType> </ItemType>
      <ItemType> </ItemType>
      <ItemType> </ItemType>
      </ItemImport>
      2. xml:
      <ItemImport Priority="0" FillType="FullIncremental" Version="1.0">
      <ItemType> </ItemType>
      <ItemType> </ItemType>
      <ItemImport>

      written XML DSL as below:
      <camel:route id="splitFiles">
      <camel:from uri="file://immediateProcessingfolder" />
      <camel:split streaming="true">
      <camel:tokenize token="${header.TokenName}" inheritNamespaceTagName="*" xml="true" group="10"/>
      <!-- <camel:xtokenize mode="w">//ns1:Item</camel:xtokenize> -->
      <camel:to uri="file://outputfolder" />
      </camel:split>
      </camel:route>

      If using inheritNamespaceTagName="*", its not giving proper output as per expectation. Root tag is coming for all the elements in a single xml file, in this example 10 times root element "ItemImport" for each ItemType element.

      1. xml:
      <ItemImport Priority="0" FillType="FullIncremental" Version="1.0">
      <ItemType> </ItemType>
      </ItemImport>
      <ItemImport Priority="0" FillType="FullIncremental" Version="1.0">
      <ItemType> </ItemType>
      </ItemImport>
      <ItemImport Priority="0" FillType="FullIncremental" Version="1.0">
      <ItemType> </ItemType>
      </ItemImport>
      2. xml:
      <ItemImport Priority="0" FillType="FullIncremental" Version="1.0">
      <ItemType> </ItemType>
      </ItemImport>
      <ItemImport Priority="0" FillType="FullIncremental" Version="1.0">
      <ItemType> </ItemType>
      <ItemImport>

      Let me know if any other detail is needed. Or if solution is already present.

      Also tried using stax by following below link, but it did not generated any output, even though I did not get any error.
      http://camel.apache.org/stax.html

      <bean id="staxRecord" class="org.apache.camel.component.stax.StAXBuilder" factory-method="stax">
      <constructor-arg index="0" value="com.input.model.item.ItemType" />
      </bean>

      <camel:route>
      <!-- pickup XML files -->
      <camel:from uri="file://immediateProcessingfolder" />
      <camel:split streaming="true">
      <camel:ref>staxRecord</camel:ref>
      <camel:to uri="file://outputfolder" />
      </camel:split>
      </camel:route>

      Thanks,
      Devendra

      Attachments

        Activity

          People

            Unassigned Unassigned
            devendra121dev Devendra Tripathi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: