The Meta-Language





The Meta-Language

XML is an acronym that means eXtensible Markup Language. But this is a little misleading. XML is in fact a meta-language, because you use it to build a specific language (not that I think we should rename it XMML). It is a set of rules for how any language you build should act and look. Listing 8.1 shows a simple example of some XML that describes this book.

A Simple XML Document
<Book xmlns="http://keithba.com/Book" ISBN="12345">
<Title>
     Putting up with Keith: A Guide for the Living
</Title>
<Author>
   Lara Ballinger
</Author>
<Publisher>
... Addison-Wesley
</Publisher>
</Book>

Generally speaking, this entire piece of XML would be called a document. In this case, the document is a simple set of tags to describe this book. As you can see, this is very readable by humans, especially those of us with experience in HTML. The difference between HTML and XML is that HTML dictates a specific set of tag names and attributes to use (such as <head>), whereas XML says you can have whatever elements (e.g., <Book>) you want, and whatever attributes (e.g., isbn) you want.

Why does XML exist? There have been many, many markup languages that do similar things. There are also hundreds, if not thousands, of standardized formats for sending data in a generic fashion. So why is XML the big one these days? I can think of three main reasons.

XML is simple. Simplicity is perhaps the number-one reason why XML is so popular. Creating an XML parser is very easy. Just about every developer I know has written one at some time or another. In fact, you can find XML parsers on every operating system and for every language I can think of.

XML is easy to read. Just like HTML, XML is simple for humans to read and understand (in most cases.) XML is a text format, not a binary format. This means that every text editor on the planet can read and write XML documents. Now, I think that XML isn't really for human consumption, but rather for machines to read and write. But a human's ability to read it certainly makes debugging a lot easier.

Everyone was ready for a standard, and chance picked XML. It was time for a common format. The programming world has become more and more complex, and more applications need to interact, often with applications on other machines. A common format for sending data means that tools can be found on any platform, any operating system, for any language. XML is the common format that the programming community has chosen over the past several years.

I think there are other reasons for the popularity of XML, but these cover the major reasons, at least to my thinking. Even better, I think they provide us a path for using XML. If we create XML documents and XML-based systems that violate the spirit of simplicity and standardization, then I think we diminish the power that XML gives us.


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows