|
XMLExpertise on Stylesheets
While schemas address the problem of reading XML data and ensuring that it meets specifications, stylesheets are used to make data of a particular model appear before a user. The term "stylesheet" can be confusing because stylesheets on the internet today come in two prominent flavors: CSS and XSL. Both types of stylesheets are defined by w3c/ietf documents. CSS "Cascading Style Sheets" are used by web site authors to control formatting of their HTML documents by users' web browsers (See The W3C CSS page ). While CSS stylesheets are useful in streamlining a website and making it more responsive and maintainable, XSL stylesheets are capable of transforming data as well as formatting it. And while data transformation is nothing new, please consider carefully the fact that XSL stylesheets are ... XML documents ! This fact is crucially important, because it means that if we have a way to store, retrieve, transmit and manipulate XML, we also have a way to store, retrieve, transmit and manipulate XSL. But wait, we are manipulating XSL ? XSL is the manipulation language, right ? So we are manipulating manipulators ? Yow !!! While XML itself is an approach to information structure, XSL is an approach to programming in a severely restricted context. The specific focus of XSL is on producing formatted output (of any type) based on formatted XML input. At present, the most obvious use of XSL is for formatting XML documents (like the source of the page you are reading now), which currently can be read directly only using advanced browsers or other tools, into browser-friendly HTML. To see an example of HTML created this way, simply use the "View Source" command in the browser you are reading this page with. You will see normal HTML markup, which looks like it would be somewhat onerous to maintain manually. All the nested table layouts you see were created using simple rules defined in an XSL stylesheet. The XML source document I am editing is completely free of layout information - it simply contains text and some tags which identify the semantic role of each paragraph. Now, XSL is not a general purpose programming language. As I mentioned, it is designed as a language for transforming and formatting output based on XML input. It turns out that this focus makes XSL programming very fast and simple for certain tasks, in comparison with previously available web techniques. While many vendors have offered Web content management solutions that were similarly effective for a range of tasks, the unique benefit of XML is that the core concepts and tools are freely available to all developers to use in creating applications. This advantage is similar to the benefit that has been derived from other free, open and standards based software technologies in recent years, such as Java, Unix, SQL, and HTML. In practice, stylesheets are used by running a program called an "XSL stylesheet processor". This program uses a parser, such as Xerces mentioned above, to read 1) an XSL styleheet, and 2) an input XML data document. The stylesheet processor then writes a transformed version of #2 to the output (which could be any web browser, web phone, database, or other digital system). The first stylesheet processor to become familiar with is, like Xerces, from the Apache Group, and is called Xalan . To learn in excruciating detail, depth, and currency about this topic, you might turn to the W3C page on XSL stylesheets . To read more news, how-to information, and articles by experts, agood resource is The "style" page at XML.com. If you would like to learn about XSL by doing, you might like to try out an interactive authoring program such as eXcelon Stylus . |