A Layman's View of XML, Part 2

by Richard G. Baldwin
baldwin@austin.cc.tx.us
Baldwin's Home Page

Dateline: 10/25/99

Prolog

As I discussed in my previous article, I have decided to write a series of articles explaining XML in layman's language, being particularly careful to avoid the use of technical jargon.

The previous article provided the following brief definition of XML:

XML gives us a way to create and maintain structured documents in plain text that can be rendered in a variety of different ways.

Then it proceeded to break down the jargon into plain English and provided some examples of structured documents.

Finally, I promised that this article would discuss, in layman's language, the mechanism by which XML uses plain text to display richly-formatted structured documents.

Achieving Structure

Consider the following simple structure that represents a book having two chapters with some text in each chapter:

Begin Book

Begin Chapter 1
Text for Chapter 1
End Chapter 1

Begin Chapter 2
Text for Chapter 2
End Chapter 2

End Book

Obviously a real book has a lot more structure than this, such as the Preface, the Table of Contents, paragraphs in the text, and an Alphabetical Index. However, I am trying to keep this example as simple as possible.

The Objective

Perhaps the primary reason for using XML is to make it possible to share the same physical document among different computer systems in a way that they all understand. This is no small task. Over the years, dozens of different types of computers have been built, operating under several different operating systems, and running thousands of different programs. As a result, insofar as the exchange of structured documents is concerned, the computer world is a modern manifestation of the "Tower of Babel" where everyone spoke a different language. XML attempts to rectify this situation by providing a common language for structured documents.

What Does XML Contribute?

Without getting into the technical details at this point, XML provides a definition of a simple scheme by which the structure and the content of a document can be established. The resulting physical document is so simple that any computer (or any human) can read it with only a modest amount of preparation.

What Does Meta Mean?

You will sometimes see XML referred to as a "meta" language. In computer jargon, the term meta is often used to identify something that provides information about something else. (If you want to impress someone at your next cocktail party, mention that meta information is information about information.)

For example, consider the listings of stock prices, bond prices, and mutual fund prices that commonly appear in most daily newspapers. The various tables on the page provide information about the bid and ask prices for the various stock, bond, and mutual fund instruments.

Usually somewhere on the page, you will find an explanation as to how to interpret the information presented throughout the remainder of the page. You could probably think of the information contained in the explanation as meta information. It provides information about other information.

So, why might people refer to XML as a meta language?

If you write a book, XML doesn't tell you how to structure the document that represents your book. Rather, it provides you with a set of rules that you can use to establish structure and content when you create the document that represents your book. It is up to you to decide how you will use those rules to establish the structure and content of your book.

You might say that XML is a language that provides information about a new language that you are free to invent.

If you follow the rules for creating an XML document, then the document that you create can easily be transported among various computers and rendered in a variety of different ways.

For example, you might want to have two different renderings of your book. One rendering might be in conventional printed format and the other rendering might be in an online format. The use of XML makes it practical to render your book in two or more different ways without any requirement to modify the original document that you produce.

This leads to the name: eXtensible Markup Language or XML.

Applying XML

Before I wrap up this article, I am going to provide two different examples, either of which might reasonably represent the simple book example presented earlier. The first example follows:

<book>
<chap>
Text for Chapter 1
</chap>
<chap>
Text for Chapter 2
</chap>
</book>

If you compare this example with the book example given earlier, you should be able to see a one-to-one correspondence between the "elements" in this XML document and the description of the book presented earlier.

The following example provides a modest improvement by including an "attribute" in each of the chapter elements that contains the chapter number:

<book>
<chap number="1">
Text for Chapter 1
</chap>
<chap number="2">
Text for Chapter 2
</chap>
</book>

Oops! There I am using technical jargon again (element and attribute). In the next installment, I will pick up at this point and provide a layman's description of the meaning of element and attribute.

Coming attractions...

In my next article I will continue the discussion, including a layman's description of element and attribute.

The XML octopus

Trying to wrap your brain around XML is sort of like trying to put an octopus in a bottle. Every time you think you have it under control, a new tentacle shows up. XML has many tentacles, reaching out in all directions. But, that's what makes it fun. As your XML host, I will do my best to lead you to the information that you need to keep the XML octopus under control.

Credits

This HTML page was produced using the WYSIWYG features of Microsoft Word 97. The images on this page were used with permission from the Microsoft Word 97 Clipart Gallery.

rev12231145

Copyright 2000, Richard G. Baldwin

About the author

Richard Baldwin is a college professor and private consultant whose primary focus is a combination of Java and XML. In addition to the many platform-independent benefits of Java applications, he believes that a combination of Java and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects involving Java, XML, or a combination of the two.  He frequently provides onsite Java and/or XML training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Java Programming Tutorials, which has gained a worldwide following among experienced and aspiring Java programmers. He has also published articles on Java Programming in Java Pro magazine.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

baldwin@austin.cc.tx.us
Baldwin's Home Page

-end-