XML and XSL
XML (Extensible Markup Language) is a format for representing data, by putting the data within nested “tags”. It is a popular way to provide data to programs, and for those programs to present data, because it is uniform and simple.
XSL (Extensible Stylesheet Language) is used to describe how data that’s formatted in XML should be presented so it will look nice for the user.
For example, suppose you are coding Web-based Rolodex software that needs to display individual virtual Rolodex “cards.” Your programmer can write a program that provides the Rolodex’s data in XML format. Then your designer can come up with an HTML page that displays each card in an attractive way. The designer would then add XSL commands that describe where to insert the XML data on the card, and any other special aspects of how the card should appear.
Advantages
- Design and programming are separate: With XML and XSL, your programmer doesn’t have to worry about the design, and your designer doesn’t have to worry about the programming. The look and feel of a program can be changed entirely just by adjusting the XSL stylesheets—without having to change or recompile the code.
- Readability: Although XML-formatted data isn’t the kind of thing you would want to show users directly, it’s relatively easy for humans to read and interpret.
- Ubiquity: XML is a widely-used standard. XML-formatted data is likely to be usable by software that you use in the future.
Disadvantages
- Sometimes hard to work with: XSL code in particular can be hard to maintain because coding errors can be hard to find.
- Bulky: XML produces a relatively large, complex file for a given amount of data. This may or may not be a problem in any specific situation.
- Time consuming: Programming an interface in XML/XSL can take longer than coding the same interface in other ways.
Choosing XML/XSL
For large content sites where lots of pages need to be generated automatically, this may be the way to go. Each page will be assembled from XML-formatted data, following an XSL template. Once the data has been transformed into the format you want, CSS can handle the ordinary formatting details of how it appears on the page.
For situations in which the bulkiness of XML files is a problem, an alternative called JSON (JavaScript Object Notation) is available. Despite its name, JSON need not be used only with JavaScript.