Transforming to EDI

EDI (Electronic Data Interchange) has been around for over 30 years, and has a loyal following of hundreds of thousands of organizations, which use it for conducting secure business transactions between EDI-compatible organizations. EDI transactions follow a syntax called X12, which provides security and flexibility in a compact and rigidly standardized format. Because of this, transformations between EDI and XML are possible, but standards have to be just as rigid on the XML side to make sure the original transaction message is not lost in the transformation. In order to overcome any roadblocks, the United Nations CEFACT (United Nations body for Trade Facilitation and Electronic Business) has begun to put together some standards for XML and EDI integration, but has not published anything as yet. Detailed information on ebXML can be found at:

http://www.ebxml.org

Along with these standards, other commercial and non-commercial organizations are working on standards that pertain to a single vertical industry, or several industries with similar challenges. Among these are World Wide Web Consortium, the IETF, CommerceNet's eCo Working Group, OBI, IOTP, RosettaNet, BizTalk, ebXML, and OASIS.

For this example, we'll show you a simple transformation of our DXL data into something that EDI could consider compatible in terms of format, but not from a syntax point of view. EDI transactions have a very distinct file delimitation, using a A to separate different elements in a transaction file. For this example, we'll build on the previous formatting examples using plain and delimited text, and produce a text file that could be transformed into an EDI transaction with further XML transformation.

We've copied the TransformXMLtoDelimitedTextFile to a new agent called TransformXMLtoEDIFormat. In the new agent we've specified a new XSL stylesheet to use for the transformation and a new output file name. Please refer to the previous section to get an overview of the environment and the Java agent that is used to generate this example. The new output file name is c:\\temp\\delimitedEDIoutput.txt. The new stylesheet is called c:/temp/DXLtoEDIFormat.xsl. Here's the stylesheet in it's entirety:

Chapter 4. Transforming XML data in Domino 233

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/"> <xsl:apply-templates select = <xsl:apply-templates select = <xsl:apply-templates select = <xsl:apply-templates select = </xsl:template>

<xsl:template match="item[@name='FishID']">

<xsl:for-each select="textlist/text">^<xsl:value-of select =

</xsl:template>

<xsl:template match="item[@name='FishName']"> <xsl:for-each select="textlist/text">^<xsl:value-of select = "."/>*</xsl:for-each> </xsl:template>

<xsl:template match="item[@name='Subcategory']"> <xsl:for-each select="textlist/text">^<xsl:value-of select = "."/>*</xsl:for-each> </xsl:template>

<xsl:template match="item[@name='FishDescription']"> <xsl:for-each select="textlist/text">^<xsl:value-of select = "."/>*</xsl:for-each> </xsl:template>

</xsl:stylesheet>

As with the previous text output examples, the main code for the output is contained in the match templates. Let's have a look at the first match template for an example, as they all are identical:

<xsl:template match="item[@name='FishID']">

<xsl:for-each select="textlist/text">^<xsl:value-of select =

</xsl:template>

In this illustration, the FishID template match code instructs the XSLT DOM processor to match any values that match the pattern /item containing an attribute called name whose value is FishID. For each match that is found, we

"/document/item[@name='FishID']"/> "/document/item[@name='FishName']"/> "/document/item[@name='Subcategory']"/> "/document/item[@name='FishDescription']"/>

234 XML Powered by Domino use a for-each instruction to wrap a A character around each end of the returned data. here's the EDI-formatted output:

*640**641**642**643**644**645**646**647**648**649**650**651**652**653* *Blacktip**Bronze Whaler**Eastern School**Grey

Nurse**Gummy**Hammerhead**other**Pencil**Spurdcg**Thickskin**Tiger**Whiske ry**White Pointer**Wobbegong*

^Shark^Shark^Shark^Shark^Shark^Shark^Shark^Shark^Shark^Shark^Sha rk**Shark^Shark^Shark*

Chapter 4. Transforming XML data in Domino 235

236 XML Powered by Domino

0 0

Post a comment

  • Receive news updates via email from this site