Systems Integration

Exchange Formats

Prof. Dr. Christian Drumm

2026-10-16

Overview

Exchange Formats

Overview

  • Exchange formats enable communication between systems on the syntax level
  • Exchange formats describe the structure of the data

Common exchange formats

  • CSV (1970s) — simple tabular data, still common in imports/exports
  • EDIFACT (1980s) — standardized business documents, ISO 9735 standard
  • XML (1990s) — flexible, hierarchical, machine- and human-readable, W3C standard
  • JSON (early 2000s) — lightweight alternative for Wbe applications, de facto standard for Web APIs

➜ EDIFACT, XML, and JSON are discussed in detail.

EDIFACT

EDIFACT — Syntax

Building Blocks

  1. Interchange — outermost envelope, control information for the entire data exchange
  2. Segments — specific data elements, each beginning with a three-letter segment tag
  3. Data elements
  4. Composite data elements — multiple sub-elements combined
  5. Separators

Hierarchical Structure

  • Top level element is the interchange
  • An interchange can contain one or more messages
  • Each message consists of multiple segments
|_Service String Advice              UNA  Optional
|____Interchange Header              UNB  Mandatory
     |___Functional Group Header     UNG  Conditional
         |___Message Header          UNH  Mandatory
             |__ User Data Segments       As required
         |__ Message Trailer         UNT  Mandatory
     |__ Functional Group Trailer    UNE  Conditional
|___ Interchange Trailer             UNZ  Mandatory

EDIFACT — Purchase Order (ORDERS)

UNA:+.? '
UNB+UNOC:3+SENDERID+RECEIVERID+240401:1200+123456789'
UNH+00000001+ORDERS:D:96A:UN'
BGM+220+PO12345+9'
DTM+137:20240401:102'
NAD+BY+123456789::16'
NAD+SU+987654321::16'
LIN+1++123456:IN'
QTY+21:5'
PRI+INV:1200.00'
UNS+S'
UNT+11+00000001'
UNZ+1+123456789'

EDIFACT — Service String

UNA:+.? '
UNB+UNOC:3+SENDERID+RECEIVERID+240401:1200+123456789'
UNH+00000001+ORDERS:D:96A:UN'
BGM+220+PO12345+9'
DTM+137:20240401:102'
NAD+BY+123456789::16'
NAD+SU+987654321::16'
LIN+1++123456:IN'
QTY+21:5'
PRI+INV:1200.00'
UNS+S'
UNT+11+00000001'
UNZ+1+123456789'

UNA — Service String Advice

  • UNA — Optional, defines delimiters
  • + — data element separator
  • : — component separator
  • . — decimal notation
  • ? — release char.
  • ' — segment terminator

EDIFACT — Envelope Segments

UNA:+.? '
UNB+UNOC:3+SENDERID+RECEIVERID+240401:1200+123456789'
UNH+00000001+ORDERS:D:96A:UN'
BGM+220+PO12345+9'
DTM+137:20240401:102'
NAD+BY+123456789::16'
NAD+SU+987654321::16'
LIN+1++123456:IN'
QTY+21:5'
PRI+INV:1200.00'
UNS+S'
UNT+11+00000001'
UNZ+1+123456789'

UNB — Interchange Header

  • UNB — Interchange header
  • UNOC:3 — Syntax identifier (UN/EDIFACT with character set level 3).
  • SENDERID — The sender’s ID.
  • RECEIVERID — The receiver’s ID.
  • 240401:1200 — Date and time of preparation (April 1, 2024, 12:00 PM).
  • 123456789 — Interchange control reference number.

UNZ — Interchange Trailer

  • 1 — Number of messages within this interchange.
  • 123456789 — Interchange control reference number, matching the one in UNB.

EDIFACT — Envelope Segments

UNA:+.? '
UNB+UNOC:3+SENDERID+RECEIVERID+240401:1200+123456789'
UNH+00000001+ORDERS:D:96A:UN'
BGM+220+PO12345+9'
DTM+137:20240401:102'
NAD+BY+123456789::16'
NAD+SU+987654321::16'
LIN+1++123456:IN'
QTY+21:5'
PRI+INV:1200.00'
UNS+S'
UNT+11+00000001'
UNZ+1+123456789'

UNH — Message Header

  • 00000001 — Unique message reference number
  • ORDERS — Message type for purchase orders
  • D:96A — EDIFACT directory version (Release 96A)
  • UN — Indicates UN/EDIFACT syntax is being used

UNT — Message Trailer

  • 11 — The number of segments in the message (from UNB to UNT, including both; the UNA and UNZ segments are not counted).
  • 00000001 — Message reference number, matching the number in the UNH segment.

EDIFACT — Message Content

...
BGM+220+PO12345+9'
DTM+137:20240401:102'
NAD+BY+123456789::16'
NAD+SU+987654321::16'
LIN+1++123456:IN'
QTY+21:5'
PRI+INV:1200.00'
UNS+S'
...

BGM — Beginning of Message

  • 220 — Function code for an purchase order
  • PO12345 — Purchase order number
  • 9 — Original message related to this transaction

DTM — Date/Time/Period

  • 137 — Qualifier indicating the document date
  • 20240401 — The date (April 1, 2024)
  • 102 — Date format qualifier (basic date format)

NAD — Name and Address

  • BY — Buyer code
  • SU — Supplier code
  • 123456789 — Buyer’s identification number
  • 16 — Party identifier qualifier

EDIFACT — Message Content

...
BGM+220+PO12345+9'
DTM+137:20240401:102'
NAD+BY+123456789::16'
NAD+SU+987654321::16'
LIN+1++123456:IN'
QTY+21:5'
PRI+INV:1200.00'
UNS+S'
...

LIN — Line Item

  • 1 — Line item number
  • 123456 — Item number
  • IN — Code qualifier indicating internal product identification

QTY — Quantity

  • 21 — Quantity qualifier for the ordered quantity
  • 5 — Ordered quantity

PRI — Price Details

  • INV — Price qualifier (invoice price)
  • 1200.00 — Unit price

UNS — Section Control

  • Indicates the separation between header, detail and summary sections of the message.

EDIFACT — Semantics

Meaning of message types and segments is defined in code lists (UN/CEFACT)

00010   UNH Message header                           M   1
00020   BGM Beginning of message                     M   1
00030   DTM Date/time/period                         M   35
00040   PAI Payment instructions                     C   1
00050   ALI Additional information                   C   5
00060   IMD Item description                         C   999
00070   FTX Free text                                C   99
00080   GIR Related identification numbers           C   10
...
00120       ---- Segment group 2  ------------------ C   99---------------+
00130   NAD Name and address                         M   1                |
00140   LOC Place/location identification            C   99               |
00150   FII Financial institution information        C   5                |

Exercise: Analyzing an EDIFACT Message

  • Analyze the EDIFACT message available here
  • Answer the following questions:
    • What type of transaction does this message represent?
    • What is the document reference and when was it issued?
    • Who are the sender and receiver? What are their identification numbers?
    • What are the monetary amounts involved, including taxes?
    • What items are being invoiced, quantities and unit prices?
    • How many messages are included in this interchange?


EDIFACT

Key Takeaways

  • Robust framework for structured business transactions at scale
  • Widely used despite complexity: logistics, supply chain, global trade
  • Understanding syntax and building blocks is essential for working with legacy systems and EDI-based industries

XML

XML

Overview

  • XML — Extensible Markup Language
    • XML 1.0 published by W3C in 1998
  • Widely-used format for data representation and exchange
  • Designed
    • to be machine-readable and human-readable
    • flexibility to represent complex, hierarchical data structures.
  • XML has become a cornerstone of modern data interchange, particularly in enterprise systems
  • Hundreds of document formats using XML syntax have been developed, including RSS, Atom, Office Open XML, OpenDocument, and SVG.
  • XML also provides the base language for communication protocols such as SOAP and XMPP.

(Wikipedia)

XML

Basic Syntax

<?xml version="1.0" encoding="UTF-8"?>
<product>
  <id>12345</id>
  <name>Mountain Bike</name>
  <price currency="USD">1200.00</price>
  <stock>10</stock>
</product>

Tags

  • Fundamental building blocks of an XML document
  • Used to define the beginning and end of an element
    • Opening tag: <product>
    • Closing tag: </product>

Elements

  • Consists of an opening tag, content, and a closing tag
  • Used to define the structure of the document
  • Contain either data or other nested elements
    • Full element: <id>12345</id>
    • Empty element: <tagname/>

XML

Basic Syntax

<?xml version="1.0" encoding="UTF-8"?>
<product>
  <id>12345</id>
  <name>Mountain Bike</name>
  <price currency="USD">1200.00</price>
  <stock>10</stock>
</product>

Attribute

  • Provide additional information about elements
  • Are placed within the opening tag of an element
  • Consist of a name-value pair, with the value enclosed in double quotes.
    • <tagname attribute="value">content</tagname>

XML Declaration

  • Optional statement at the beginning of an XML document
  • Defines the version of XML being used and the document’s character encoding
    • <?xml version="1.0" encoding="UTF-8"?>

Well-Formed XML

An XML document is well-formed if:

  • Unicode: It contains only properly encoded Unicode characters.
  • Special characters: None of the special syntax characters such as < and & appear except when performing their markup-delineation roles.
  • Nesting:
    • The begin, end, and empty-element tags are correctly nested
    • none missing and none overlapping tags
  • Matching tags:
    • Element tags are case-sensitive. The beginning and end tags must match exactly
    • Tag names cannot contain any of the characters !"#$%&'()\*:;<=>?@[\]^{|}~ nor a space character
    • Tag names cannot start with -, ., , , or a numeric digit
  • Single root element: There is a single “root” element that contains all the other elements

Namespaces in XML

<bookstore xmlns:bk="http://example.org/books">
  <bk:book>
    <bk:title>Learning XML</bk:title>
    <bk:author>John Doe</bk:author>
    <bk:price>39.95</bk:price>
  </bk:book>
</bookstore>
  • Avoid naming conflicts when combining data from different sources or standards
  • Declared via xmlns attribute (typically in the root element)
  • Prefix (e.g. bk) qualifies elements as belonging to the namespace

XML Schema Languages

Document Type Definition (DTD)

  • One of the oldest schema languages for XML
  • Defines elements, attributes, order, simple types
<!DOCTYPE product [
  <!ELEMENT product (id, name, description, price, stock)>
  <!ELEMENT id (#PCDATA)>
  <!ELEMENT name (#PCDATA)>
  <!ELEMENT description (#PCDATA)>
  <!ELEMENT price (#PCDATA)>
  <!ATTLIST price currency CDATA #REQUIRED>
  <!ELEMENT stock (#PCDATA)>
]>

XML Schema Languages

XML Schema (XSD)

  • Written in XML itself and supports richer validation
  • Advantages over DTD:
    • Data Types: XSD supports built-in data types (e.g., strings, integers, dates)
    • Namespaces: XSD fully supports XML namespaces ➜ more suitable for complex applications
    • Extensibility: XSD allows for more complex structures, including nested elements and attribute validation
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="product">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="id" type="xs:string"/>
        <xs:element name="name" type="xs:string"/>
        <xs:element name="description" type="xs:string"/>
        <xs:element name="price">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:decimal">
                <xs:attribute name="currency" type="xs:string" use="required"/>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
        <xs:element name="stock" type="xs:integer"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Exercise: Analyzing an XML Document

Given the customer XML document and the corresponding XSD (cf. lecture notes):

  1. Does the XML document conform to the schema? Why or why not? If not, what changes would be needed?
  2. How would validation fail if the country field had more than 2 characters?
  3. What happens if email is missing, given that it’s a mandatory field?

JSON

JSON

JavaScript Object Notation — standardized as ISO/IEC 21778:2017

  • Lightweight, text-based format for structured data
  • Originally designed for JavaScript — now de facto standard for Web APIs
  • Libraries available in most modern programming languages
{
  "product": {
    "id": 12345,
    "name": "Mountain Bike",
    "price": 1200.0,
    "currency": "USD",
    "stock": 10
  }
}
  • Strings — "...", escaped with \
  • Numbers — decimal, fraction, exponent
  • Booleans — true / false
  • Arrays — ordered: ["Bike", "Helmet"]
  • Objects — key-value pairs: {"name": "Bike"}
  • Null — missing/empty data

JSON Schema

  • JSON has no native schema system
  • JSON Schema can be used to define and validate structure, types, constraints of JSON documents
{
  "$schema": "http://json-schema.org/draft/2020-12/schema#",
  "title": "Product",
  "type": "object",
  "properties": {
    "id": { "type": "number" },
    "name": { "type": "string" },
    "price": { "type": "number", "minimum": 0 },
    "currency": { "type": "string" },
    "inStock": { "type": "boolean" },
    "discount": { "type": ["number", "null"] }
  },
  "required": ["id", "name", "price", "currency"]
}

Exercise: Validating JSON Data

Given the product JSON data and the JSON schema:

{
  "$schema": "http://json-schema.org/draft/2020-12/schema#",
  "title": "Product",
  "type": "object",
  "properties": {
    "id": { "type": "number" },
    "name": { "type": "string" },
    "price": { "type": "number", "minimum": 0 },
    "currency": { "type": "string" },
    "inStock": { "type": "boolean" },
    "discount": { "type": ["number", "null"] }
  },
  "required": ["id", "name", "price", "currency"]
}
{
  "id": 12345,
  "name": "Mountain Bike",
  "price": 1200.0,
  "currency": "USD",
  "inStock": true
}
  1. Does the data conform to the schema?
  2. What happens if price is set to -100?
  3. What if the currency field is missing?
  4. How does validation behave if an extra field (e.g. description) is added?

Comparison: JSON vs. XML

Feature JSON XML
Simplicity Simple, minimal syntax More verbose and flexible
Readability Easily human-readable Human-readable but more complex
Structure Key-value pairs and arrays Hierarchical tree structure
Schema Support No native schema (external tools) Native schema via DTD or XSD
Type Handling Simple (number, string, boolean) Extensive, with custom types
Usage Common in APIs, web applications Common in document-based systems

JSON: lightweight and easy for web services and APIs. XML: sophisticated options for complex data with schema validation.

Summary

What are the advantages of EDIFACT, XML and JSON? What are their disadvantaged?

Which of the three technologies is the best for systems integration?