Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Invalid
-
2.19.1
-
None
-
None
-
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