XML Introduction

XML: Parts 1–2

Version 1.11

Hype

Discussion:

Introduction to Writing XML

XML Building Blocks

Make sure we understand:

Five Commandments

Discussion: students give examples that violate each commandment:

  1. Case-sensitive tags
  2. Opening tags must have closing tags except for abbreviated empty elements.
  3. Elements may not overlap.
  4. Attribute values must be quoted.
  5. There must be one (and only one) root element in a document.

A document is well-formed if it obeys these five rules.

Tree Structure

These rules imply that an XML document is tree structured.

Remember that the relational model came into favor after earlier "hierarchical" (tree) and "network" (graph) data models. Now the hierarchical model is back, in the form of XML!

Special Symbols

Certain symbols have special meaning in XML and cannot be written verbatim—actually this is a bit of an overstatement; some of them can be written verbatim, but not in all contexts.

XML Declaration

XML Editors

I recommend using a good text editor. Emacs handles XML well; so do many others. Not Notepad; Windows users should consider Notepad++.

First XML Document

Discussion:

Exercises

On page 40, #1–2.

In addition, check if the document is well-formed:

$ xmlwf FILE

or

$ xmllint --noout FILE

  1. Version history:
    • Version 1.1, 2011 Apr 6: Moved DTD section to its own file. Corrected notation for &. Added remark about hierarchical database model.
    • Version 1.0, 2011 Apr 5.