Internet
Seminar

Spring 2019
course
site

References

XML - eXtensible Markup Language - 1997

XML is descendant of SGML, which was a descendant of GML - IBM's General Markup Language from 1960 which was used to implement markup tags for the IBM text formatter, SCRIPT. Both XML and HTML are descendants of SGML which wasn't a markup language itself, but rather a technology for defining general markup languages for documents in industry that needed to remain machine-readable for decades. XML is a markup language that reads rather closely to HTML, however it has stricter requirements (tags must be closed, hierarchy is must line up) and it lets you make your own tags rather than using strictly pre-defined ones in html. In both languages white-space is largely ignored. It is used as a way to store data in a platform and language-agnostic way and it lends itself well to domain-specific storage procedures. For instance there are standards of pre-defined tags and structures used in healthcare and e-learning: SCORM (used in e-learning) and HL7 (used in healthcare). RSS, MathML (a mathematical markup language). XML is the data type used in Ajax requests.

basic example:

<person>
  <firstName>John</firstName>
  <lastName>Smith</lastName>
  <age>25</age>
  <address>
    <streetAddress>21 2nd Street</streetAddress>
    <city>New York</city>
    <state>NY</state>
    <postalCode>10021</postalCode>
  </address>
  <phoneNumber>
    <type>home</type>
    <number>212 555-1234</number>
  </phoneNumber>
  <phoneNumber>
    <type>fax</type>
    <number>646 555-4567</number>
  </phoneNumber>
  <gender>
    <type>male</type>
  </gender>
</person>

can also be serialized using attributes instead of tags:

<person firstName="John" lastName="Smith" age="25">
  <address streetAddress="21 2nd Street" city="New York" state="NY" postalCode="10021" />
  <phoneNumber type="home" number="212 555-1234"/>
  <phoneNumber type="fax" number="646 555-4567"/>
  <gender type="male"/>
</person>

JSON - JavaScript Object Notation - 2001

JSON evolved from a need for direct, stateless communication between browsers and servers rather than using flash or java applets. It is a subset of javascript. Data types supported: number, string, boolean, array, object, null. Whitespace is ignored and there is no syntax for comments. Everything is delineated in brackets and curlies. Heavily used in browser-based applications as an alternative to Ajax and xml for communicating between the server/browser.

basic example:

{
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 27,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    },
    {
      "type": "mobile",
      "number": "123 456-7890"
    }
  ],
  "children": [],
  "spouse": null
}

YAML - YAML Ain’t Markup Language - 2001

YAML is meant as a very human-readable format for data organization. It is very commonly used as a configuration file for many different pieces of software. It uses a python-style arrangement of vertical alignment to indicate nested elements and it largely gets rid of the brackets and tags used in JSON and XML. One nice feature of YAML is that a set of JSON or XML encoded data can be easily embedded inside a code-block as an extended string. Most YAML parsers can parse json as it JSON is the same thing as writing YAML with optional “inline styling” as shown below:

martin: {name: Martin D'vloper, job: Developer, skill: Elite}
fruits: ['Apple', 'Orange', 'Strawberry', 'Mango']
— delineates the start of a document
- delineates list items
| string appears as written with newlines
> string appears as a single line string

basic example:

---
# An employee record
name: Martin D'vloper
job: Developer
skill: Elite
employed: True
foods:
    - Apple
    - Orange
    - Strawberry
    - Mango
languages:
    perl: Elite
    python: Elite
    pascal: Lame
education: |
    4 GCSEs
    3 A-Levels
    BSc in the Internet of Things

Other data type encoding examples: CSV, OGDL

https://cs.marlboro.college /cours /spring2019 /internet /www /nweeks /xmljsonyaml
last modified Sun May 5 2024 6:40 pm