XSLT for Dummies
|
Chapter 2 - Writing Your First XSLT Stylesheet | |
XSLT For Dummies | |
by Richard Wagner | |
Hungry Minds 2002 |
Every craftsman needs tools to perform his or her job adequately, and as a new XSL transformer, you are no exception. You need two primary software programs to add to your tool belta text editor and an XSLT processor. Tip Some software tools actually combine the capabilities of the text editor and XSLT processor within a single application. X-Factor, a tool I describe in the next section, is such an example.
Text editor
XML and XSLT documents are ordinary text files, so finding software that allows you to create and edit them is a breeze . You simply need a text editor. If you are Windows user , you can use Notepad. Or if you already have a favorite editor, then feel free to use it. However, to help make the task of learning XSLT easier, I recommend you start by using X-Factor as your editor. X-Factor is an easy-to-use software program specifically designed to be a learning tool for XSLT. The application enables you to open up your XML source and XSLT stylesheet at the same time, perform transformations with the click of a button, and view the results of the transformation inside the application window (see Figure 2-1). X-Factor is available as a free download from the XSLT For Dummies Web site at www.dummies.com/extras/xsltfd or from Nombas, Inc. at www.nombas.com . To set up X-Factor, download the setup file from either of the preceding locations and run setup.exe on your computer. The X-Factor setup program guides you through the installation process.
XSLT processor
The second piece of software that you need for transformations is an XSLT processor. This essential component takes the source XML document, looks at the rules you have set up in your stylesheet, performs the transformation, and outputs the results to a new file. An XSLT processor is quite different than a text editor, such as Notepad. It usually has no real user interface or window to work with. Instead, most are command-line toolsthings youd work with only inside a command prompt window (you know, the DOS-like window that takes you back to the 1980s). In Chapter 20, I list ten XSLT processors you can download from the Web. Although you can feel free to use any of those to transform stylesheets, if you use X-Factor, the Instant SAXON processor is included with it, so you dont need to install or configure it. An XSLT processor parallels the engine of an automobile. When you drive a car, youre aware that the engine is there, but its usually hidden from view under the hood. You interact with the engine, but minimally . You dont say much more than speed up or slow down. In the same way, if you work with an XSLT processor directly, you give an XSLT processor the names of your XML document and XSLT stylesheet to process and tell it where you want to put the results, and it does the rest. However, if you use X-Factor, it manages the processor for you so you never have to call the processor directly. Tip Many XSLT commercial-grade software tools are available that provide more functionality than X-Factor. Visit the Web sites discussed in Chapter 19 to find out more about these enhanced tools.
|