Translating EDIFACT documents to XML
Stylus Studio® has a built-in comprehensive dictionary of EDIFACT messages, segments, elements and codelists. It uses this EDIFACT respository for helping you write clean EDIFACT and diagnose problems with existing EDIFACT data streams.
This page will cover these topics relating to using the EDIFACT XML Converter:
(Note that the EDIFACT converter and the X12 converter use the same URL; the EDI converter engine figures out from the document itself whether it should switch to EDIFACT or X12 mode. Pretty cool, huh?)
(If you think this is keen, neat, cool or groovy, see also the data conversion API for using this stuff from your own programs as through you had prepared them from scratch. For the rest of the recipe, see the XML Converters page.)
The "secret sauce" to using EDIFACT with all of the various XML Tools is that Stylus Studio® has an advanced URI Resolver that does on-the-fly conversions of documents from one syntax to another.
Anything that can be addressed by URL can be morphed in real time through one of these converters. EDIFACT is just one type; others include one for Comma-Separated Values and one to convert HTML into XML.
The way an EDI file is converted is by taking any place a regular XML URL would go,
and instead putting the URL to the EDIFACT file, and prepending it with the
For example, to treat
There can be other options before the
To create the URL, it can be done manually or through the Open|File dialog.
Since just opening the file naturally exposes the URL, let's see how simple it is to convert EDIFACT to XML.
First, use the same File|Open dialog you are used to in other applications to choose the file, except right before hitting Open, put a check in the special box labeled "Convert to XML using converter".
Next we choose the proper converter, which in this case is the "Electronic Data Interchange (EDI)" converter.
On the right side, there are several options that vary by converter. Changing them changes the URL prefix shown at the bottom of the dialog. Properly formed EDIFACT files will open without any changes, but occasionally you might need to suppress some of the automatic structural validation to get things to open.
So, after picking the filename, checking one checkbox, pressing one button (Open), choosing the converter and pressing another button (OK), we've got a converted file in our XML editor.
To use this file as input to XQuery for example, we could use this same File|Open step to fill the "Main input:" field in the XQuery Scenario dialog:
Then run an XQuery program consisting of solely a single period, and you should get as output the entire EDIFACT file but in XML form.
Using XSLT, go to the "Source XML URL:" field in the XSLT Scenario dialog:
and try the following only slightly more sophisticated XSLT transform:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
From this you see that it is trivial to use EDIFACT anywhere you are accustomed to using XML. Happy transforming!
PURCHASE STYLUS STUDIO ONLINE TODAY!!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Try Stylus EDIFACT Mapping Tools
Download a free trial of our industry-leading EDIFACT mapping tools today!
What's New for Stylus Studio® X16?
New XQuery & Web Services Tools, Support for MySQL, PostgreSQL, HL7 EDI, Microsoft .NET Code Generation and much more!
Stylus Studio® EDIFACT Zone
Simplify your next legacy data integration project with the help of the EDIFACT Zone, the world's largest, free online reference covering all EDIFACT and UN/CEFACT versions.