Own Your Own Island
Have you seen the online-investing advertisement where a grungy-looking tow truck operator turns out to be a multimillionaire? And the photograph of what we think is his favorite vacation spot turns out to be his own island --his own country, in fact. Beginning with Internet Explorer 5 (IE5), you too can have your own island -- thousands if you prefer. XML data islands may not be as warm and inviting as the Cayman Islands, but when you are trying to do sophisticated data transformations on a browser client, they may be the ticket.
A data island is nothing more than a uniquely identified XML document included or referenced within an HTML page. When the page is parsed, a dynamic representation of the island is stored temporarily in the client browser’s document model. IE5 allows the browser to make use of data stored in the island without visiting the server. When you spend time on a tropical island, the change in latitude is often accompanied by a change in attitude. Once adjusted, you get the satisfying feeling that you have everything you need, and a trip to the mainland is the furthest thing from your mind. Data islands are designed to give a browser the same feeling. Rather than frantically calling the mainland -- a Web server -- every time the browser needs the smallest data transformation, XML data islands help ensure that a browser only makes a server roundtrip when absolutely necessary.
IE5 supports data islands with the new HTML tag <XML>, but this tag will cause errors in older browsers. Microsoft also supports an alternate syntax using the familiar <SCRIPT> tag, but script tags don’t get parsed unless the browser allows script execution. You will have to weigh the tradeoff. Creating a data island is as simple as this:
Data islands are not restricted to storing data, per se. Because XML schemas and extensible style sheets (XSL) are also described using XML, you can create an archipelago that includes schema islands and layout islands, as well. XSL can easily redefine the look of your data by transforming a data island into HTML. XML schemas can be used to ensure that data in an island follows a prescribed format. The result: Using data islands and the document object model (DOM), you can create, read, modify, transform, and validate data with little programming. Moreover, all this work can be done without a roundtrip to the Web server.
Data islands make easy work of a number of popular use cases. A typical application for a data island is presenting query results with client-side sorting and filtering. In this use case, the entire result set is provided as an island when the original HTML page is served. The page is re-sorted and filtered by calling the transform method and providing an appropriate XSL layout. Using data islands, it is possible to create completely stateless Web applications without cookies or server-side storage. In this scenario, the application’s state is stored in an island. This technique can circumvent the stringent privacy requirements of some European countries, which prohibit storing any user information on a server without explicit permission. A slightly more exotic application of data islands is the specialty grammar Vector Markup Language (VML) proposed by AutoDesk, Hewlett-Packard, Microsoft, Macromedia, and Visio. VML allows embedding high-quality vector drawings within a Web page.
I've convinced you. You are ready to pull up stakes and move to the islands, but there is a catch. Try any of these XML techniques anywhere but IE5 and you’ll get nothing but errors. Within an enterprise, it may be reasonable to recommend an upgrade, but you’ll never get the whole Web universe to upgrade. There’s nothing you can do to add data island capability to older browsers. But, you can use almost identical techniques on the server to simulate islands. If you create your data-centric Web pages by transforming XML data with an XSL layout, you are paving the way to eventually providing this service on the client. It’s even possible to write server code that defers these functions to the browser only for versions that support data islands.
Whether you are creating applications that can move to the islands today or preparing applications for a future move, the weather is certainly inviting. XML is the new de facto standard for describing any kind of content and data islands make it a breeze to include XML in your Web pages. --Eric Binary Anderson is a development manager at PeopleSoft's PeopleTools division (Pleasanton, Calif.) and has his own consulting business, Binary Solutions. Contact him at email@example.com.