December 25, 2001 - Justifying XML | WebReference

December 25, 2001 - Justifying XML

Yehuda Shiran December 25, 2001
Justifying XML
Tips: December 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

The proliferation of XML to many Web applications can be explained, among other factors, by its added information compared with HTML. HTML has become a standard for presenting information on the Web. HTML tags, on the other hand, do not contain any information about the data. Look at the following HTML page's top portion:

<H1>MyDvd Rental Store on the Web</H1>
<H2>Periodical Sales Report</H2>
<P>Sales report for January, February, and March of 2001</P> 
In this example, "MyDvd Rental Store on the Web" is a large heading (H1), "Periodical Sales Report" is a smaller heading (H2), and the rest is a paragraph (P). When displayed in a Web browser, you can easily understand these three pieces of information. The size and location of each piece tells you what the author had in mind when writing the HTML page. XML, on the other hand, explicitly defines the data. Here is the same example in XML:

<heading>MyDvd Rental Store on the Web</heading>
<subhead>Periodical Sales Report</subhead>
<description>Sales report for January, February, and March of 2001</description> 
Information in HTML is usually stored in its final form. If you need to present the same Web page in two different way, you need to create two different HTML pages, each storing the same data. Information in XML, on the other hand, can be presented in a multitude of ways for different target audiences. XML parsers are used to interpret the data.

Another difference between HTML and XML is that unlike HTML, XML provides no formatting information. In HTML, the tag name discloses its format. For example, you expect text within an H1 tag to be larger than text within an H2 tag. XML, on the other hand, has no notation of format whatsoever. You need to use XSL (Extensible Stylesheet Language) or XSLT (XSL Transformation) to display XML information on the Web. XML and XSLT constitute a dynamic and flexible system for handling data and presentation.