Accessibility

Table of Contents

XML Overview

Why Do You Need XML?

In order to figure out where XML should be used, you should bear in mind its key advantages. I briefly mentioned some of them earlier. This section takes an in-depth look at XML advantages over other mark-up languages or similar technologies.

X Stands For "eXtensible"

When working with XML, people often forget the X stands for "Extensible." Extensibility means you can define any number of extra tags, without crashing the application. For instance, you can add children to this element:

<employee>
 	<name>John Doe</name>
	<job>Software Analyst</job>
    	<salary>2000</salary>
</employee>

To make it look like this:

<employee>
  	<name>John Doe</name>
	<job>Software Analyst
		<responsibility>Write technical specifications</responsibility>
		<responsibility>Translate client requirements into software requirements</responsibility>
	</job>
	<hire_date>Jun 25, 2005</hire_date>
	<salary>2000</salary>	
</employee>

The application reading this XML document will still understand which employee is referred.

Different Platforms, One Language

Portability comes from the fact that you get to define the tags and attributes. No special libraries or application servers are required to "read" an XML document (although your development environment needs some configuring in order to become XML-aware, as I will explain in a future article). XML documents are plain-text files, hence they do not require a proprietary software to interpret them, as do most binary files. This means you can use Notepad to open and edit an XML file.

Therefore, XML is the choice, when information needs to be exchanged across several (incompatible) hardware or software platforms or applications. This has led to several applications of XML in communication technology, including the popular WML (Wireless Markup Language) and WAP (Wireless Application Protocol). WML is an XML-based language used to markup Internet applications for hand-held devices, such as phones or PDAs. To learn more about WML, you can read this tutorial from the W3 Consortium.

Portability also comes in handy in business-to-business applications, where many companies need to exchange a large amount of financial information in a platform-independent way. Different applications use SOAP (Simple Object Access Protocol), a popular XML-based protocol, to exchange such information over the Internet. These XML-based information sharing applications are called web services.

Content is Separated From Presentation

With XML, you can reduce the risk of content redundancy. Your clients will concentrate on using HTML and CSS for defining the layout and presentation, which will not be affected by any changes in the underlying information stored separately in an XML file.

For instance, a content management system might supply documents to end-users in a variety of formats: HTML, PDF, etc. However, there is no point in storing a separate version of each document for each format. The content would be duplicated and would take up valuable disk space, making the CMS clogged with redundant information and slower to use. Using an engine based on XML, the content can be stored only once and then extracted and displayed in the desired format.

If XML Separates Content From Presentation, What Do I Use to Present My Data?

Any processing or formatting requirements should be handled by a separate XSL (Extensible Style sheet Language) document. An XSL style sheet specifies the presentation of data contained by an XML file. XML and XSL are combined at output time to apply the required formatting to the data in the same way that Cascading Style Sheets (CSS) let you style HTML.

I will cover XSL in more detail in my next articles, and I will explain how to use the two together to produce formatted output for your application. Dreamweaver 8 offers you a quick, visual way to create your own XSL style sheets for a custom XML file. You’ll learn how simple it is to import an RSS feed in your site and provide your visitors with the latest news or updates.

If you look at the three important benefits of XML, you'll understand immediately where XML should be used:

  • In applications that manipulate large amounts of data, but need to stay flexible and extensible. Such applications can include web portals, job listings, or financial applications.
  • Where content redundancy is a risk, such as in content management systems, document libraries or site tracking systems.
  • Where a large amount of data needs to be exchanged across several different platforms, such as b2b applications, e-mail clients with news feeds support, or mobile devices.
  • Where information needs to be made easily available to a large number of clients. Such information may include news headlines, company press releases, important notices and announcements, bookmarks, playlists, event calendars, or mailing lists.

Already XML is widely used to transfer data between different database applications. Most DBMS (including Microsoft Access or phpMyAdmin already allow exporting database tables as XML files.

RSS (Really Simple Syndication) is one of the most popular applications of XML. RSS is just another XML document format designed for syndicating news and news-like content. Popular websites that rely on RSS include community sites like Wired and Slashdot, or personal blogs. Macromedia makes its Developer Center articles available as an RSS feed. The main advantage of RSS is that you have people read your content in the format they want and import it in their own websites. I will show how to consume a RSS feed in one of my next articles, using Dreamweaver 8.

It's easy to figure out where you shouldn't use XML, just by looking at some of its disadvantages.

  • XML should not be used on small, personal websites, or company presentation websites, which are scarce in content or have just a few pages. Static HTML and some CSS/Flash design can better do the trick.
  • XML should not be used on websites with a vast amount of content, where data retrieval and security are paramount. In this case, databases provide a much better solution. Such applications may include corporation websites, data warehouses, etc.
  • XML should not be used to replace HTML or to replace databases. If your website is already database-driven, there is no point in switching to XML. You can, however, add a RSS feed to carry news or company announcements and let your clients import them directly in their websites.