%@ page language="C#" masterpagefile="~/templates/Master1.master" inherits="Page"
keywords="validate EDI, validate electronic data interchange, validating EDI,
validate EDIFACT, validating electronic data interchange, validating EDIFACT,
EDI XSD, EDI XML Schema, EDIFACT XSD, EDIFACT XML Schema" %>
Either before or after transforming EDIFACT content, we should make sure
that we have all of the necessary components, our codes are in our codelists,
and everything is in the right places. <%= ConfigurationManager.AppSettings["SS"] %> includes a dictionary containing
the EDIFACT standards across multiple versions. From this, the following steps will
let us validate an EDIFACT document. Once we've gone through these four steps, subsequent validations of the same
document structure will be even shorter. If we use our project window and
assign that schema to a folder therein, any EDIFACT Document URL placed into
that project folder will get validated with the given schema. Use File|Open and select your EDIFACT document. This demonstration uses
the sample file edifact-sample.txt
available on this server. Before pressing the Open button, check the
the box labeled Convert to XML using adapter. Another dialog asking for which adapter will come up. Choose the
"Electronic Data Interchange (EDI)" adapter and press OK. Your EDIFACT document will now be opened in the XML editor, as
fully-commented XML. Now you need to generate a matching schema. If you're not sure which
message type or which version the EDIFACT files is from, just look in the editor.
There will be a line that starts like this:Validating EDIFACT Documents with XML Schemas
Open the EDIFACT document as XML
Create the corresponding XML schema
and that's your message type — in this sample ORDERS. Almost immediately below it will be a line like this:
which contains your version number.
Use File|Document Wizards...|EDIFACT to XML Schema and choose version 03B of message ORDERS and a new tab will open with the newly-generated XML Schema that cooresponds to the content of the EDIFACT file you just converted.
Do File|Save As... and save it as 03B-ORDERS.xsd. You now have a reusable XML Schema file for validating EDIFACT version D03B Purchace Order Messages.
Next we need to associate this schema with our document. Go to the menubar and choose XML|Associate XML With Schema... and then open the XSD file you just saved. In a few seconds, the tags should change color to indicate that a schema was found and that they are a valid part of the schema.
Press the
button and your EDIFACT file can now
be validated against the XML Schema you just created.
This can be used to make sure the EDIFACT input you are receiving matches what you expect. It can also be used at the result end of an XQuery or XSLT transform to make sure your output has valid content — which is especially useful to do before writing through the EDI adapter to turn it into valid EDIFACT.
It's phenomenal to consider what we've just done. We've used two completely different technologies — EDIFACT and XML Schema (with completely unrelated ancestries) — and we've used them together in a new way to solve the tough problem of validating EDI. You can use these same features in your projects as well: see details about using the embedded XML converters directly and in conjunction with XSLT and XQuery.
Simplify working with Electronic Data Interchange (EDI) with <%= ConfigurationManager.AppSettings["SS"] %>'s award-winning EDI Tools — Download a free trial of our today!
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.