Exchange Formats
2026-10-16
➜ EDIFACT, XML, and JSON are discussed in detail.
|_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 MandatoryUNA — Optional, defines delimiters+ — data element separator: — component separator. — decimal notation? — release char.' — segment terminatorUNB — Interchange headerUNOC: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.1 — Number of messages within this interchange.123456789 — Interchange control reference number, matching the one in UNB.00000001 — Unique message reference numberORDERS — Message type for purchase ordersD:96A — EDIFACT directory version (Release 96A)UN — Indicates UN/EDIFACT syntax is being used11 — 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.220 — Function code for an purchase orderPO12345 — Purchase order number9 — Original message related to this transaction137 — Qualifier indicating the document date20240401 — The date (April 1, 2024)102 — Date format qualifier (basic date format)1 — Line item number123456 — Item numberIN — Code qualifier indicating internal product identification21 — Quantity qualifier for the ordered quantity5 — Ordered quantityINV — Price qualifier (invoice price)1200.00 — Unit priceMeaning 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 |
- Start with UNH and BGM.
- Use the message type directory for further analysis.
Key Takeaways
Overview
- 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)
Basic Syntax
Tags
<product></product>Elements
<id>12345</id><tagname/>Basic Syntax
Attribute
<tagname attribute="value">content</tagname>XML Declaration
<?xml version="1.0" encoding="UTF-8"?>An XML document is well-formed if:
< and & appear except when performing their markup-delineation roles.!"#$%&'()\*:;<=>?@[\]^{|}~ nor a space character-, ., , , or a numeric digitxmlns attribute (typically in the root element)bk) qualifies elements as belonging to the namespaceDocument Type Definition (DTD)
XML Schema (XSD)
<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>Given the customer XML document and the corresponding XSD (cf. lecture notes):
country field had more than 2 characters?JavaScript Object Notation — standardized as ISO/IEC 21778:2017
"...", escaped with \true / false["Bike", "Helmet"]{"name": "Bike"}{
"$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"]
}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"]
}price is set to -100?currency field is missing?description) is added?| 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.
What are the advantages of EDIFACT, XML and JSON? What are their disadvantaged?
Which of the three technologies is the best for systems integration?
Systems Integration | Exchange Formats | Prof. C. Drumm