XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Francois MalanSubject: Flat file conversion to XML
Author: Francois Malan
Date: 16 Jul 2009 06:56 PM
I am reviewing the StylusStudio software capabilities to convert a flat file(txt) to XML:

We have a text file with statement information for different accounts and would like to produce a separate statement for each customer account.
The text file contains data elements (e.g. RecordType, Customer Id, Lastname & Firstname) which are all on separate lines and can be identified through unique matching patterns. (e.g. 101, 102, 104)
999 Indicates the start of a new statement.
The first 25 characters are a combination of prefixes and matching patterns and the data element is in the last 25 characters and then terminated by a CR/LF.
Example text file extract is:

99900000000000000000000000000000000000000000000000
101 000000000000000000111456789
102 000000000000000000MR JOHN
103 000000000000000000SMITH
104 21 MAY 478887 CHEQUE PAYMENT 41.00
104 22 MAY 478888 CHEQUE PAYMENT 42.00
104 23 MAY 478889 CHEQUE PAYMENT 43.00
99900000000000000000000000000000000000000000000000
101 000000000000000000222456679
102 000000000000000000MR DAVID
103 000000000000000000DOE
104 14 MAY 508888 CHEQUE PAYMENT 31.00

The desired outcome must be a single file with multiple XML definitions, each Statement line to represent the XML customer statement.
<?xml version="1.0"?>
<StatementList>
<Statement>
<AccNumb>111456789</AccNumb>
<Mod05>
<FirstName>MR JOHN</FirstName>
<LastName>SMITH</LastName>
</Mod05>
<Mod10>
<TxLine>21 MAY 478887 CHEQUE PAYMENT 41.00</TxLine>
<TxLine>22 MAY 478888 CHEQUE PAYMENT 42.00</TxLine>
<TxLine>23 MAY 478889 CHEQUE PAYMENT 43.00</TxLine>
</Mod10>
</Statement>
<Statement>
<AccNumb>222456679</AccNumb>
<Mod05>
<FirstName>MR DAVID</FirstName>
<LastName>DOE</LastName>
</Mod05>
<Mod10>
<TxLine>14 MAY 508888 CHEQUE PAYMENT 31.00</TxLine>
</Mod10>
</Statement>
</StatementList>

Issues that I currently have are:

1. Formatting the XML to get desired outcome.
2. Allocating substring values of a row to a XML field

Any recommendation/advice will be welcome.

Thanks
Francois

Posttop
Tony LavinioSubject: Flat file conversion to XML
Author: Tony Lavinio
Date: 21 Jul 2009 03:44 PM
We do it in two steps.

The CustomXMLConverter is used to build the map from the text to a
simple XML representation, and then XQuery is used to rearrange the
output into the nested structure.

This lets each tool do one thing well.

The attached .zip file contains a m.prj project file for Stylus Studio
which includes a .conv converter map and a .xquery that uses it to do
the job.

Just open the .xquery program and run it to see the results.


Unknownmalan.zip
m.*

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.