Modeling EDIFACT data by using DFDL
View Details

IBM Knowledge Center

Learn how to model EDIFACT data by using Data Format Description Language (DFDL).
Back To Gallery

Import projects

Click Import and two shared libraries are imported into your workspace.

Library EDIFACT-D03B contains a pair of DFDL schemas that model a UN/EDIFACT Supply Chain interchange for release D.03B. Definitions for message types INVOIC and ORDERS are provided. Test data files are included in the library.

Library EDIFACT-Common contains a DFDL schema to define default values for DFDL properties, and a DFDL schema to model the Uxx service segments and service messages for syntax version 4.

Exploring the schemas

The EDIFACT-D03B and EDIFACT-Common libraries are shown in the Application Development view of your workspace.

The EDIFACT-SupplyChain-Messages-D.03B.xsd DFDL schema in the EDIFACT-D03B library opens in the DFDL editor. If it does not open, double-click the DFDL schema to open it in the editor.

The Interchange message is highlighted and it models a whole EDIFACT interchange. The main editor view shows the logical components of the message, such as elements and sequences. You can explore the Interchange message structure by expanding the elements.

The physical rendering of each logical component is described by the DFDL properties in the Representation Properties tab. DFDL properties can be specified locally on the component, or can be inherited from pre-defined sets of DFDL properties. Inherited properties have an icon shown next to them, and hovering over the icon reveals where the property is defined. In this schema, inherited properties are obtained from schema IBM_EDI_Format.xsd in the EDIFACT-Common library.

Because the settings of delimiters in an EDIFACT interchange can vary, the DFDL properties Terminator, Separator, Escape Character and Decimal Separator are set dynamically using DFDL expressions that refer to DFDL variables. The variables have default values and are overridden by the settings in a UNA segment if present. You can see this if you expand the UNA element in Interchange, select any of the child elements, and click on the Variables tab next to Representation Properties.

You will be test parsing example EDIFACT data by using the Interchange message. The test parsing takes place entirely within the DFDL editor, so there is no message flow in this tutorial and no Deploy step. Before test parsing, switch to the DFDL Test perspective by clicking Window > Open Perspective and then clicking DFDL Test. (Alternatively, you can use the toolbar icon ).

Tip: If this Tutorial Steps View tab disappears when you switch perspectives, use the Window > Show View menu option to add it back.

Follow these steps to complete the tutorial

The EDIFACT-SupplyChain-Messages-D.03B.xsd DFDL schema is open in the DFDL editor. The Interchange message should be highlighted in green.

  1. Test parse an example data file:
    1. Click the Test Parse Model button in the DFDL editor toolbar. The Test Parse Model window opens.
    2. In the Message section, select Interchange.
    3. In the Parser Input section, select Content from a data file then click Browse.
    4. Select the ORDERS_D.03B_Interchange.txt file from EDIFACT-D03B then click OK.
    5. Set the Encoding to ASCII.
    6. Click OK. If asked to confirm switching to the DFDL Test perspective, click Yes.
  2. The results of the test parse are displayed. You should see the message Parsing completed successfully. You can dismiss this message.
  3. You can view the parsed data file in the DFDL Test - Parse view. The results of the parse can be viewed in the DFDL Test - Logical Instance view, as a tree or as XML. You can view a log of the parser actions in the DFDL Test - Trace view.
  4. Test serialize the logical instance that resulted from the parse:
    1. Click the Test Serialize Model button in the DFDL editor toolbar. The Test Serialize Model window opens.
    2. In the Serializer Input section, select Content from a DFDL Test - Logical Instance.
    3. Set the Encoding to ASCII.
    4. Click OK.
  5. The results of the test serialize are displayed. You should see the message Serialization completed successfully. You can dismiss this message.
  6. You can view the serialized data file in the DFDL Test - Serialize view. You can view a log of the serializer actions in the DFDL Test - Trace view.
  7. Repeat steps 1 through 6 for the INVOIC_D.03B_Interchange_with_UNA.txt example data file.
  8. As an alternative to the toolbar buttons, you can also test from the DFDL Test - Parse and DFDL Test - Serialize views, using the Browse button to select a data source and the green play icon to run the DFDL parser or serializer.

The supplied DFDL schemas parse UN/EDIFACT interchanges with or without new lines at the end of each segment, but will serialize interchanges without new lines. If you need to serialize with new lines, you can edit the EDIFACT-Service-Segments-4.1.xsd file in the EDIFACT-Common library and change the DFDL expression used by setting the SegmentTerm DFDL variable to the commented-out value.

If you need to support UN/EDIFACT syntax version 3 instead of syntax version 4, you can edit the IBM_EDI_Format.xsd file in the EDIFACT-Common library. In this file, set the RepeatSep DFDL variable to take the default value '+' (plus) instead of '*' (asterisk).

If you need to support ',' (comma) as the default decimal separator instead of '.' (period), you can edit the IBM_EDI_Format.xsd file in the EDIFACT-Common library. In this file, change the DecimalSep DFDL variable to take the default value ',' (comma) instead of '.' (period).

The two shared libraries can be deployed to an integration node for use by message flows.