Translating X12 documents to XML
X12 and other EDI dialects are handled easily by Stylus Studio®, which has a comprehensive set of tools for managing and converting X12 transaction sets, segments, elements, and codelists. It uses this X12 dictionary for helping you write syntactically pure and semantically accurate X12 and to diagnose problems with incoming and outgoing X12 data.
This page will cover these areas involved with the X12 XML Converter:
(Note that the X12 converter and the EDIFACT converter use the same URL; the EDI converter engine figures out from the document itself whether it should switch to EDIFACT or X12 mode. Not too shabby, huh?) (And while we are in parentheses, remember that the data conversion utilities can be called from your own programs through the data conversion API. More details can also be found on the XML Converters page. Now back to your regularly-scheduled and un-parenthesized content.)
The "special ingredient" to using X12 with different sorts of 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 converted in real time through one of these converters. X12 is just one type; others include one for making HTML into proper XML (actually, XHTML) and another one to convert Comma-Separated Values to 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 X12 file, and prepending it with the
For example, to treat
There can be other options before the
Creating the URL can be done manually or through the Open|File dialog.
Since just opening the file automatically exposes the URL, let's see how straight forward it is to go from X12 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 select the correct 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 X12 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 choosing the filename, checking one checkbox, pressing one button (Open), selecting the converter and pressing another button (OK), we've got a converted file in our XML editor.
To use this file as input to XSLT for example, we could use this same File|Open step to fill the "Source XML URL:" field in the XSLT Scenario dialog:
and try the following identity transform that just copies the input to the output:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Using XQuery, go to 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 X12 file but in XML form.
From this you see that it is trivial to use X12 anywhere you are accustomed to using XML. Happy converting!
PURCHASE STYLUS STUDIO ONLINE TODAY!!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Try Stylus X12 Tools
Simplify working with X12 technologies using Stylus Studio®'s award-winning X12 Tools — Download a free trial today!
What's New for X15?
New XQuery & Web Services Tools, Support for MySQL, PostgreSQL, HL7 EDI, Microsoft .NET Code Generation and much more!
Deploy your X12 Applications
Only Stylus Studio provides the necessary tools and components to develop and deploy your data integration applications that access legacy data formats including X12, EDIFACT and EDI to a live production environment using W3C XML Standards.