JSON vs XML, Part 1: XML in RPG

What’s the difference?

JSON vs XML: when did these data formats originate, and how are they used in RPG (and development in general)? Both have a tremendous history behind them and are either derived from or parent to a variety of other means to hold data. This article will draw a few mentions to content cited in our previous blog posts on REST[1] vs SOAP[2] APIs (and a comparison[3]). This first in a series of three articles will explore XML, as well as its origins, general structure, and typical uses in RPG. The next article in this series will explore JSON in a similar fashion, while the third will draw comparisons between the two. Before getting too deep into the weeds, let’s define a few important terms mentioned in this series.


Definitions

The realm of client-server communication is loaded with acronyms and terms to keep track of. To begin with, let’s elaborate upon several key terms, and what they mean. 

XML – Extensible Markup Language – XML is a widely used data format, similarly structured to HTML. XML can be used in both SOAP and REST API calls.JSON – JavaScript Object Notation – JSON is arguably the fastest-growing data format used when communicating over HTTP in the present day, thanks to its memory-efficient format.WSDL – Web Service Definition Language – WSDL is an XML-based notation used for describing functionality of a SOAP-based web service[4]. WSDL is used at development time to describe a web service program with procedure names, input/output parameters, the URL of the web service, and the enveloping mechanisms and transport to be used (i.e., SOAP over HTTP).XSD – XML Schema Definition – An XSD is a file type that describes the structure of an XML document.REST – Representational State Transfer – REST is an architectural style, rather than a protocol (protocols define how diverse modules interact, while styles define how sets of protocols are organized[5]). REST utilizes existing web protocols and tools to communicate with APIs.SOAP – Simple Object Access Protocol – SOAP is a data-centric protocol that uses WSDL files for client-consumer communication.RPG – RPG is the primary language used when developing business applications on the IBM i OS. Also known as RPG Free, RPGLE, and RPG IV.IBM i – IBM i is the operating system used on IBM’s POWER servers. IBM i is the OS name, which was formerly i5/OS and OS/400. AS/400 is what was renamed to iSeries, System i, and then IBM Power Systems.

Table of Contents


XML – Extensible Markup Language

An expanded definition

Let’s dig into XML and find out what each of its terms mean. As mentioned in the “Definitions” section, XML stands for Extensible Markup Language. What do each of these terms mean?

Extensible

Oracle’s documentation describes extensibility as “an ability of the software system to allow and accept the significant extension of its capabilities without major rewriting of code or changes in its basic architecture. Extensible systems provide technology, tools, languages that are designed so that developers can expand or add to its capabilities.” [6, Page 5]

For example, when compared to HTML, XML is extensible. While HTML requires you to use a specific set of predefined tags (such as <body>, <head>, <div>, etc), XML accommodates user-defined tags (such as <OrderNumber>, <Quantity>, <Location>, <Status>, etc.).

Markup

Techtarget.com says that “Markup refers to the sequence of characters or other symbols that you insert at certain places in a text or word processing file to indicate how the file should look when it is printed or displayed or to describe the document’s logical structure. The markup indicators are often called tags.” [7]

Language

Techtarget.com also explains that “A markup language is a computer language that uses tags to define elements within a document. It is human-readable, meaning markup files contain standard words, rather than typical programming syntax.” [8]

While most languages programmers use are tied closely to the development of a program (think RPG, COBOL, or CL), markup languages can be considered a metalanguage (i.e. a language used to describe another language). [9]


What is XML’s history?

To get a broad understanding of XML, as well as some trivia, let’s look into XML’s predecessors, and where they came from. Furthermore, we’ll explore the offshoots of XML and similar data formats built parallel to it.

GML – Generalized Markup Language

The earliest roots of XML come from GML, as developed by Charles Goldfarb, Edward Mosher, and Raymond Lorie at IBM in the 1960s.[10] Made long before the advent of HTTP, GML was designed not for data interchange across the web, but for representation. GML documents were built using a series of markup tags intending to specify what a document should look like, rather than representing exactly what it would look like. [11]

SGML – Standard Generalized Markup Language

Extending from GML came SGML, which was formalized as an ISO standard in 1986[12], and defined as having a scope which includes “Standardization in the field of document structures, languages and related facilities for the description and processing of compound and hypermedia documents.”[13

Darla Ferrara at ThoughtCo describes SGML’s use well:

SGML, HTML, and XML are all markup languages… In this family of markup languages, Standard Generalized Markup Language (SGML) is the parent. SGML provides a way to define markup languages and sets the standard for their form. In other words, SGML states what some languages can or cannot do, what elements must be included, such as tags, and the basic structure of the language. As a parent passes on genetic traits to a child, SGML passes structure and format rules to markup languages.[14]

HTML – HyperText Markup Language

HTML, one of the most familiar coding languages, is an extension of SGML  and was released in 1993.[15] It has evolved greatly over the years, and is the primary language used when displaying web pages. 

XML – Extensible Markup Language

Released in 1996, XML is another SGML extension, and is one of the most widely-used data formats available today. While HTML worked well for building websites, its limited extensibility made it unsuitable for storing data in an efficient manner. XML was created in response to that. As described by Chris Collins in ‘A Brief History of XML’,

When it comes to data storage and interchange, HTML is a bad fit, as it was originally intended as a presentation technology, while SGML is considered too complex for general use. XML bridges this gap by being both human and machine readable, while being flexible enough to support platform and architecture independent data interchange.[16]

XHTML – Extensible HyperText Markup Language

XHTML is an extension of both HTML and XML, and its initial release was in 2000. As stated by w3schools.com, “XHTML was developed to make HTML more extensible and flexible to work with other data formats (such as XML). In addition, browsers ignore errors in HTML pages, and try to display the website even if it has some errors in the markup. So XHTML comes with a much stricter error handling.”[17]

Note, the 1-2 lines of text under each circular markup symbol points out general document requirements (or lack thereof) in the history of GML through XHTML.


How is XML structured?

XML is built using a tree structure, and begins with a single root element, which expands into a series of child, parent, and sibling elements. An XML document might be structured like this:

Verified by MonsterInsights