In the transformation process, XSLT uses XPath to define parts of the source document that match one or more predefined templates. When a match is found, XSLT transforms the matching part of the source document into the result document. The parts of the source document that do not match a template end up unmodified in the result document. |
Need for XSLT |
Before discussing the need for XSLT, you first need to remind yourself why XML has proved to be such a success and generated so much excitement. XML is a simple, standard way to interchange structured textual data between computer programs. Part of its success comes because it is also readable and writable by humans, using nothing more complicated than a text editor, but this doesn’t alter the fact that it is primarily intended for communication between software systems. As such, XML satisfies two compelling requirements: |
Separating data from presentation: The need to separate information (such as a weather forecast) |
from details of the way it is to be presented on a particular device. The early motivation for this arose from the need to deliver information not only to the traditional PC-based Web browser (which itself comes in many flavors), but also to TV sets and WAP (Wireless Application Protocol) phones, not to mention the continuing need to produce print-on-paper. For many information providers, an even more important driver is the opportunity to syndicate content to other organi- zations that can republish it with their own look-and-feel. |
Transmitting data between applications: The need to transmit information (such as orders and |
invoices) from one organization to another without investing in software integration projects. As electronic commerce gathers pace, the amount of data exchanged between enterprises increases daily, and this need becomes ever more urgent. |
Of course, these two ways of using XML are not mutually exclusive. An invoice can be presented onscreen as well as being input to a financial application package, and weather forecasts can be summarized, indexed, and aggregated by the recipient instead of being displayed directly. Another of the key benefits of XML is that it unifies the worlds of documents and data, providing a single way of representing structure regardless of whether the information is intended for human or machine consumption. The main point is that, whether the XML data is ultimately used by people or by a software application, it will very rarely be used directly in the form it arrives in: it first has to be transformed into something else such as another XML format or HTML format. |
To communicate with a human reader, this something else might be a document that can be displayed or printed: for example, an HTML file, a PDF file, or even audible sound. Converting XML to HTML for display is the most common application of XSLT today, and it is the one that will be used in most of the examples in this chapter. After you have the data in HTML format, it can be displayed on any browser. |
learn guitarphysics learnteliphonyxmlphysicsenjoylife