Home > XML IDE - XML Editor > XML Editor Key Features > EDI Tools > Validating X12
Validating X12 Documents with XML schemasIn order to make sure the X12 content we're dealing with is valid, either before transforming it or after, we need something against which to validate it. Stylus Studio® includes a dictionary containing the X12 standards across multiple versions. From this, the following steps will let us validate an X12 document.
We can save the XML Schema so that we do not need to rebuild it each time. And by assigning that schema to a folder in our project window, any X12 Document URL placed into that folder will get validated with the assigned schema. Open the X12 document as XMLUse File|Open and select your X12 document. You may use x12-sample.txt for this demonstration. But... before pressing the Open button, put a check in the box Convert to XML using converter. Another dialog asking for which converter will come up. Choose "Electronic Data Interchange (EDI)" and then press OK. Your X12 file will now be opened in the XML editor, as fully-commented XML. Create the corresponding XML schemaNow you need to generate the appropriate schema. If you're not sure which transaction set or which release the X12 files is from, just look in the editor. There will be a line that starts like this: <GS08><!--480: Version / Release / Industry-->003040
<!--Draft Standards Approved for Publication by ASC X12 Procedures Review Board through October 1993--></GS08> and that's your release - in this case, 003040. Next find the line that starts like this: <ST01><!--143: Transaction Set Identifier Code-->831
<!--X12.49 Application Control Totals--></ST01> and that's your transaction set. Do File|Document Wizards...|X12 to XML Schema and choose release 003040 and transaction set 831, and you'll have a new document created that is the schema for this X12 document. Use File|Save As... and save it as something like 3040-831.xsd. You now have a reusable XML Schema file for validating X12 Application Control Total transaction sets for release 003040. Attach the schema to the documentNow, let's tell the document where to find the schema. Use XML|Associate XML With Schema... and choose the file you just created. 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. ValidatePress the button and your X12 document can now be validated against the XML Schema you've created. This can be used to make sure the X12 EDI data you are getting in matches what you expect. It can also be used at the end of an XQuery or XSLT transform to make sure your output has valid content, immediately before writing back through the EDI converter to turn it into valid X12. The XML Converters are specifically design to help you do this, as is the data conversion API.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Try Stylus EDI ToolsSimplify working with Electronic Data Interchange (EDI) with Stylus Studio®'s award-winning EDI Tools — Download a free trial of our today! 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! 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! Related XSD Features & Tutorials |