Chapter 4 - Templates Rule! | |
XSLT For Dummies | |
by Richard Wagner | |
Hungry Minds 2002 |
A Glorified Mail MergeTemplate rules can be thought of as a glorified mail merge. Have you ever used the mail merge feature in a word processor? Even if you havent, the concept is pretty simple. To do a mail merge that creates a personalized letter for each customer in a database, for example, you create a letter in a word processor that includes both normal text and data field placeholders. These fields in the word processed document are linked to an external customer database, so that when you print the document, the word processor prints a letter for each customer in the linked database. This mail merge process is very common; in fact, I am willing to bet you have mail sitting in your mailbox right now that was prepared in this manner. The customer database serves as the source of the information. The word processor document serves as the template. And a printed letter results from the transformation in which the source and template are combined. Similarly, an XML document acts as the source, while the XSLT stylesheet contains templates. The XSLT processor creates a result document based on the source XML document being applied to the stylesheets template rules. Table 4-1 shows the parallels between the two processes.
Some may argue that it is an oversimplification to compare XSLT transformations with a mail merge, but even if it is, the comparison isnt far off and is certainly a good starting point as you get your hands around template rules.
|