XML to Fixed-Length Records and Fields

This example is another type of transformation to perform with a parser. An XML file is transformed into a flat file with fixed-length records and fields.

Input File:

<BankRepository>
	<Files>
		<File>
			<ID>SampleSix</ID>
			<Messages>
				<Message>
               <IgnorePrecedingFieldSeparator>1</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>1</Numeric>
                  <Alpha>0</Alpha>
                </DefaultTrim>
					<Name>TopNode</Name>
					<TagName>TopNode</TagName>										
					<EscapeChar/>
					<RecordSeparator></RecordSeparator>
					<FieldSeparator></FieldSeparator>
					<FixedLengthSeparator>1</FixedLengthSeparator>
					<Records>
						<Record>
							<Name>RecordOne</Name>
							<TagName>RecordOne</TagName>
							<MinOccur>1</MinOccur>
							<MaxOccur>0</MaxOccur>
							<Fields>
								<Field>
									<Name>Field1</Name>
									<TagName>Field1</TagName>
									<DataType>Alpha</DataType>
									<PaddingChar/>
									<DecimalLength/>
									<Alignment>LEFT</Alignment>
									<StartPos>1</StartPos>
									<Length>1</Length>
									<DefaultValue></DefaultValue>
									<Identifier>0</Identifier>
								</Field>
								<Field>
									<Name>Field2</Name>
									<TagName>Field2</TagName>
									<DataType>Alpha</DataType>
									<PaddingChar/>
									<DecimalLength/>
									<Alignment>LEFT</Alignment>
									<StartPos>2</StartPos>
									<Length>1</Length>
									<DefaultValue></DefaultValue>
									<Identifier>0</Identifier>
								</Field>
							</Fields>
						</Record>
					</Records>
				</Message>
			</Messages>
		</File>
	</Files>
</BankRepository>

Input file:

<TopNode>
    <RecordOne>   
        <Field1>a</Field1>
        <Field2>b</Field2>
    </RecordOne>>
    <RecordOne>
        <Field1>C</Field1>
        <Field2>D</Field2>
    </RecordOne>>
    <RecordOne>
        <Field1>e</Field1>
        <Field2>F</Field2>
    </RecordOne>>
    <RecordOne>
        <Field1>G</Field1>
        <Field2>h</Field2>
    </RecordOne>
</TopNode>

The expected result is:

abCDeFGh