What is XML?

DITA is based on the Extensible Markup Language (XML). XML is a meta-language for creating new languages. To understand what DITA is, it is important to understand what XML is and how it works.

XML Elements

XML is a markup language (like HTML) and is both human-readable and machine-readable. This means that text or other content is marked up with elements, called tags.

An XML document always has a tree structure, meaning it has a single root element. Elements consist of an opening and a closing tag. A tag has a name, that is wrapped in a lower than char (<) and a greater than char (>).

<!-- An opening tag -->
<recipe>

<!-- A closing tag (indicated by the "/" char) -->
</recipe>

<!-- The short form, a combination of opening and closing tag. The "/" is placed after the name -->
<recipe/>

An XML document may contain comments that are not processed by XML processors. A comments starts with <!-- and ends with -->.

<!-- A comment -->

Elements may have attributes which add additional information. Attributes are included in the opening tag.

<element attribute="value"/>

Schemas

The structure of an XML file can be specified using a schema. There are 3 common schema languages, that are can be used to specify an XML structure.

  • Document Type Definition (DTD)
  • XML Schema (XSD)
  • Relax NG (RNG/RNC)

The DITA XML structure is defined in all 3 languages. An information architect can choose, which schema language he wants for validating the DITA files.

Note: The structure and principle of working with grammar files is not going to be explained here.

A Simple XML document

The following sample file shows a basic XML file representing a recipe to cook sunny side-up eggs.

<?xml version="1.0" encoding="UTF-8"?>
<recipe>
  <title>Sunny side-up egg</title>
  <ingredients>
    <ingredient>1 egg</ingredient>
    <ingredient>olive oil</ingredient>
    <ingredient>salt</ingredient>
  </ingredients>
  <steps>
    <step>Get frying pan on a medium head.</step>
    <step>Add olive oil.</step>
    <step>Crack the egg into the pan.</step>
    <step>Cook the egg until the tops of the whites are set but the yolk of the egg is still runny.</step>
    <step>Remove the pan from the head and take the egg using a spatula.</step>
    <step>Serve the egg with a sprinkling of the salt.</step>
  </steps>
</recipe>