<employee>
<name> John </name>
<supervisor> Mary </supervisor>
</employee>
In this example,
we see a record with an employee’s name (John) and the name of his supervisor
(Mary). Note that this record is as easy to understand for a person, as it uses
everyday words, as it is for a computer, as it has a structure that computers
understand.
What makes XML self-describing
is that the computer can describe the very structure of the previous record,
using the same format. It is done as follows:
<record>
<title> employee </title>
<element> name </element>
<element> supervisor </element>
</record>
Here again, a
person can understand readily how a record called “employee” contains the name
and the supervisor of the employee. You can easily match the usage of the words
“name” and “supervisor” in both the description and the original record to see
how the latter expression describes the former one.
Of course, we
have to be fair and mention that we are very much over-simplifying, but this
all should evoke the right idea of what XML is. Naturally, the process of
self-description can progress ad infinitum, just as it can in natural language,
where I can say that John is an employee, that this information is contained in
a record, that this record is to be found in a drawer, that this drawer is
sitting in a room, and so on.
So far what we’ve
seen is all like an English encyclopedia, except it is an encyclopedia that a
computer understands.
Computers can
use XML to send messages to each
other. For example:
<message>
<from> http://www.my-company.com
</from>
<to> http://www.your-company.com
</to>
<content>
<employee>
<name> John </name>
<supervisor> Mary
</supervisor>
</employee>
</content>
</message>
As we can see by
reading from top to bottom, the first computer at “my-company.com” has sent to
the second computer at “your-company.com” a message whose content is an
employee record.
In fact,
messages are a little bit richer than we said so far. Instead of what we saw
previously, we are more likely to see the following, where we have added one
line under the banner “schema”:
|