Home > XML IDE - XML Editor > XML Editor Key Features > XML Mapping > Convert EDI to XML
XML Mapping
CONVERT EDI TO XMLOverview of EDI to XML ConversionThis 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 dataEDI 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®. ISA:00: :00: :01:1515151515 :01:515151 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 fileNow, 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 ConversionA preview of this would generate the following XML:
<?xml version="1.0" encoding="utf-8"?> ... 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 SegmentFor 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 InputThese simple steps above produce the following output: (click image to enlarge) Further Reading on EDIThere 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 MapppingSimplify EDI Mapping by Downloading a free trial of our award-winning EDI mapping tools. Learn XQuery in 10 Minutes!Say goodbye to 10-minute abs, and say Hello to "Learn XQuery in Ten Minutes!", the world's fastest and easiest XQuery primer, now available for free! Why Pay More for XML Tools?With Stylus Studio® X16 XML Enterprise Suite, you get the most comprehensive XML tool suite at one incredibly low price. Value: it's just one of many reasons why smart XML developers are choosing Stylus Studio! Support XQuery in the Microsoft .NET Framework10 Simple things you can do to help support XQuery in the Microsoft .NET 2.0 Framework - Read on! |