CONVERT EDI TO XML
Overview of EDI to XML Conversion
This example shows how Convert to XML can be used to transform EDI files into XML. Either the end result can be used directly, or subsequent processing can be done through XQuery or XSLT.
Understanding the Raw EDI data
EDI files have a qualifier at the start of each record which determines the record layout. We can use this with the Match Pattern feature of Convert-to-XML to produce a unique set of elements for the information in each differently-structured row.
For our sample, let's use a little X12 EDI document of type 831, "Application Control Totals" like this. We include this file (named 831.x12) in the "Convert to XML" folder of the sample project that ships with Stylus Studio®.
Since some EDI files don't have line breaks per se, but instead use segment terminators, this sample was wrapped to fit in the browser window at a 60-character margin. But notice that in this example, there is a separator between each record; it is the tilde "~" character. And immediately after each tilde is a record-type specifier. There is also one at the start of the file which defines this as an X12-format EDI file, and tells us just what this separator is. But we don't really need to know all this; we're just giving an idea of one of the many pieces of information that Stylus Studio® can deduce from the input file automatically.
Opening the EDI file
Now, fire up Convert-to-XML and put this in as the input file, and this is what we see:
(click image to enlarge)
Note that such settings as "Line Terminator" and "Component Separator" have already been deduced from the input file for you.
Previewing the EDI to XML Default Conversion
A preview of this would generate the following XML:
... and so on
Now, each <code> element tells us the structure of the segment, and according to the X12 EDI specification, we have the following segments in our message:
Building a Match Pattern for an EDI Segment
For each type, there is a different layout, and we can use the Match Pattern feature to process each different segment type individually. Let's just pick the QTY segment, and see how it would be processed.
Generating the XML Output from the EDI Input
These simple steps above produce the following output:
(click image to enlarge)
Further Reading on EDI
There are various standards, such as:
Some are publicly available; for others, you need a membership to the regulating organization in order to obtain the specifications. Often, though, if you are dealing with another entity, that other business will already have some standard published that you can make use of. Stylus Studio also maintains an archive of EDI-L, a popular forum for discussing EDI issues, and now you can stay up-to-date with our RSS and Atom feeds for EDI-L which are only available from Stylus Studio.
Stylus Studio® includes the ability to understand the raw EDI formats, though, and can get you a long way towards solving your EDI-to-XML integration needs.
All of the files used here are available in the sample project that ships with Stylus Studio®, in the "Convert to XML" folder, so that you may use them as references or experiments with the options on your own.
For more information on working with non-XML formats see Convert to XML
PURCHASE STYLUS STUDIO ONLINE TODAY!!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Try Stylus EDI Mappping
Simplify EDI Mapping by Downloading a free trial of our award-winning EDI mapping tools.
Attend a Live Webinar This Week!
Learn about Stylus Studio's unique features and benefits in just under an hour. Register for the Stylus Studio QuickStart Training WebCast!
Support XQuery in the Microsoft .NET Framework
10 Simple things you can do to help support XQuery in the Microsoft .NET 2.0 Framework - Read on!