Subject:In need for help on converting record oriented flat file to XML Author:Sebastien Vinchon Date:15 Jun 2009 11:36 AM
Hello,
I am in need for an advice on how to tell Stylus Studio Flat File to XML conversion engine to process differently lines depending on the value at a specific position.
As an example, when processing the attached file, I want to create a complex node called:
- L1 when the four character starting at position 85 are equal to 0012
- L2 when the four character starting at position 85 are equal to 0022
- L3 when the four character starting at position 85 are different from 0012 and 0013
Subject:In need for help on converting record oriented flat file to XML Author:Tony Lavinio Date:03 Aug 2009 11:30 PM
What you want to do is create a separate record layout
for each type. To do this, we use what we call "patterns".
Load the file into Custom XML Converters, and do this:
Right-click on the line that will become L1 and choose
"Add node/pattern". For the name, use L1, and for the
pattern use the regular expression ^.{85}0012
Now do similar for L2 with ^.{85}0022
Now, look at the schema tree on the right. It will have several
branches. Go to the one without a pattern showing, and select
the row name and press F2 to rename, and put in L3.
What the .^{85}0012 etc. means is:
^ start matching from the start of the string
.{85} match 85 occurrences of any character
0012 match the string "0012"
You can find more on "regular expressions" by Googling.
Now, with the different record layouts, you can break things
into different fields for each one independently.