XML to record-separated fixed-length fields Flat File
This example is another type of transformation to perform with a parser. An XML file will be transformed into a record-separated fixed-length fields flat file.
Input File:
<BankRepository>
<Files>
<File>
<ID>SampleFour</ID>
<Messages>
<Message>
<IgnorePrecedingFieldSeparator>0</IgnorePrecedingFieldSeparator>
<DefaultEmptyFieldValue>
<Numeric>0</Numeric>
<Alpha></Alpha>
</DefaultEmptyFieldValue>
<DefaultAlignment>
<Numeric>RIGHT</Numeric>
<Alpha>LEFT</Alpha>
</DefaultAlignment>
<DefaultPadding>
<Numeric>0</Numeric>
<Alpha> </Alpha>
</DefaultPadding>
<DefaultTrim>
<Numeric>0</Numeric>
<Alpha>0</Alpha>
</DefaultTrim>
<Name>Sample</Name>
<TagName>Sample</TagName>
<EscapeChar/>
<RecordSeparator>\n</RecordSeparator>
<FieldSeparator></FieldSeparator>
<Records>
<Record>
<Name>SampleRecord</Name>
<TagName>SampleRecord</TagName>
<MinOccur>1</MinOccur>
<MaxOccur>0</MaxOccur>
<Fields>
<Field>
<Name>SampleFieldOne</Name>
<TagName>SampleFieldOne</TagName>
<DataType>Alpha</DataType>
<PaddingChar/>
<DecimalLength/>
<Alignment>LEFT</Alignment>
<StartPos>1</StartPos>
<Length>3</Length>
<DefaultValue></DefaultValue>
<Identifier>0</Identifier>
</Field>
<Field>
<Name>SampleFieldTwo</Name>
<TagName>SampleFieldTwo</TagName>
<DataType>Alpha</DataType>
<PaddingChar/>
<DecimalLength/>
<Alignment>LEFT</Alignment>
<StartPos>4</StartPos>
<Length>3</Length>
<DefaultValue></DefaultValue>
<Identifier>0</Identifier>
</Field>
</Fields>
</Record>
</Records>
</Message>
</Messages>
</File>
</Files>
</BankRepository>
Input file:
<SampleMessage>
<SampleRecord>
<SampleFieldOne>AAA_One</SampleFieldOne>
<SampleFieldTwo>BBB</SampleFieldTwo>
</SampleRecord>
<SampleRecord>
<SampleFieldOne>CCC</SampleFieldOne>
<SampleFieldTwo>DDD</SampleFieldTwo>
</SampleRecord>
<SampleMessage>
The expected result will be:
AAABBB
CCCDDD