The Caboteria / Tech Web / XmlCssExperiment (11 Nov 2003, TobyCabot)
(TobyCabot - 11 Nov 2003)

Everybody complains about the weather, but nobody does anything about it. Same with HTML. XML is the future, but can XML be sent to browsers with some hope of being displayed in interesting ways? Not yet - Internet Explorer is the problem. Mozilla seems to do a pretty good job displaying simple XML documents and applying style to them, but IE fails on trivial examples.

What does XML look like in a browser? To start with, here's a trivial XML document:

<?xml version="1.0" ?>
 This is an XML document.  It's well-formed but doesn't have a DTD so
 we can't say if it's valid or not.  Because it has no instructions
 telling a browser how to display it they will probably show it in
 "raw" form including the elements and braces.

It will be displayed "raw" in most browsers. Now we want to provide instructions to the browser telling it how to display the document. We do this using an XML processing instruction that points to a CSS stylesheet (CSS sheets can be used for XML as well as HTML). The instruction looks like:

<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="trivial.css" ?>

The CSS stylesheet doesn't have to be very complex, just a few instructions that set the colors:

body {
 display: block;
 background: #ccc;
 color: #0c0;

The result is now displayed in a more stylish way, however IE 6 will botch the display and give the page a white background, instead of grey as it was instructed. So at this point there's not really much hope, at least until IE7, unless you're in the unlikely (but lucky) position of having a user community that uses only Mozilla.

XSLT is another technology that can be used in a similar way, you can learn more at XmlXslCssExperiment.

Edit | Attach | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Copyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback