|
Home > Products > Key Features > EDI Tools > XML to EDIFACT
EDI Tools
Translating XML documents to EDIFACTOnce an XML document is created that contains the proper content to fill an EDIFACT structure, the adapter will do the syntactical translating for you. But how do you get the XML data to look right? Using the same steps as in Converting EDIFACT to XML, we're going to load an EDIFACT document into the editor, change it, and save it back out — and we'll watch the change occur. This will demonstrate an XML document turning back into EDIFACT. Then we'll see how we can do this automatically as part of an XSLT transformation. Here are the steps for this demonstration:
Open the EDIFACT document in the XML editorPerform the following steps:
Change XML EDIFACTLet's change the recipient from DATADIRECT to SAXONICA. Before:
<UNB03>After:
<UNB03>Save XML document in EDIFACT formatDo See changed EDIFACTComparing the two files shows that you just changed an EDIFACT document without an EDIFACT editor, or even seeing the EDIFACT file itself! ![]() Use EDIFACT document as output of XSLTWe could automate this, and take the input document, change it with XSLT or XQuery, and save it as a new EDIFACT document with our change. Here are the steps:
<xsl:stylesheet version="1.0">
<xsl:template match="/"> <xsl:apply-templates select="node()"/> </xsl:template> <xsl:template match="UNB0301"> <xsl:element name="{local-name(.)}"> <xsl:text>SAXONICA</xsl:text> </xsl:element> </xsl:template> <xsl:template match="node()"> <xsl:choose> <xsl:when test="local-name(.) = '#text'"> <xsl:value-of select="."/> </xsl:when> <xsl:when test="local-name(.) = '#comment'"/> <xsl:otherwise> <xsl:element name="{local-name(.)}"> <xsl:apply-templates select="node()"/> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> What this does is the same thing we just did, but mechanically. It finds the UNB0301 segment and replaces whatever content text was there with the string SAXONICA. It also filters out any comments (but we could pass them along by replacing the line <xsl:when test="local-name(.) = '#comment'"/>
with the lines <xsl:when test="local-name(.) = '#comment'">
but we don't really need them.)
<xsl:comment> <xsl:value-of select="."/> </xsl:comment> </xsl:when> The EDIFACT can be generated completely from XSLTor XQuery, and schemas can be generated against which to map and validate your EDIFACT XML. The adapters can be used in other contexts as well. They may be built right in to your own applications, using either the data conversion API or as part of your file handling or XSLT/XQuery processing through the deployment adapters.
XPath Query EditorStylus Studio's XML Editor has an XPath Query Editor that allows you to easily roubleshoot, test, and debug any XPath expression. Apache XML ProjectThe Apache XML Project provides standards-based, open-source XML solutions for working with W3C XML technologies including XML, XSL, XSLT, XSL:FO XPath, Web services and more. Learn how Stylus Studio provides support for all Apache XML projects. Energy Companies That Use Stylus StudioForget red bull! Many energy companies are using Stylus Studio 2006 for their quick pick me up during the work day. Come see which energy companies are getting the boost they need with Stylus Studio! Improving XSLT and XQuery Performance with Stylus StudioThis online video demonstration covers XQuery and XSLT performance tuning using the Stylus Studio XSLT profiler and the XQuery profiler. Stylus Most Wanted |
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! What's New for X14?New XQuery & Web Services Tools, Support for MySQL, PostgreSQL, HL7 EDI, Microsoft .NET Code Generation and much more! Why Pay More for XML Tools?With Stylus Studio® X14 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! Stylus Studio® EDIFACT ZoneSimplify 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. Related XSD Features & Tutorials |




