Installing Xalan Getting Started

page 22 To make sure Xalan is installed correctly, go to a command prompt and type the following command: java org.apache.xalan.xslt.Process This is a Java class, so everything is case sensitive. You should see an error message like this: java org.apache.xalan.xslt.Process =xslproc options: -IN inputXMLURL [-XSL XSLTransformationURL] [-OUT outputURL] [-LXCIN compiledStylesheetFileNameIn] [-LXCOUT compiledStylesheetFileNameOutOut] If you got this error message, youre all set Youre ready for the next chapter, in which well build our very first XSLT stylesheet.

1.4 Summary

In this chapter, weve gone over the basics of XML and talked about DOM and SAX, two standards that are commonly used by XSLT processors. We also talked about other technology standards and how to install the Xalan stylesheet processor. At this point, youve got everything you need to build and use your first stylesheets, something well do in the next chapter. page 23

Chapter 2. The Obligatory Hello World Example

In future chapters, well spend much time talking about XSLT, XPath, and various advanced functions used to transform XML documents. First, though, well go through a short example to illustrate how stylesheets work.

2.1 Goals of This Chapter

By the end of this chapter, you should know: • How to create a basic stylesheet • How to use a stylesheet to transform an XML document • How a stylesheet processor uses a stylesheet to transform an XML document • The structure of an XSLT stylesheet

2.2 Transforming Hello World

Continuing the tradition of Hello World examples begun by Brian Kernighan and Dennis Ritchie in The C Programming Language Prentice Hall, 1988, well transform a Hello World XML document.

2.2.1 Our Sample Document

First, well look at our sample document. This simple XML document, courtesy of the XML 1.0 specification, contains the famous friendly greeting to the world: ?xml version=1.0? greeting Hello, World greeting What wed like to do is transform this fascinating document into something we can view in an ordinary household browser.

2.2.2 A Sample Stylesheet

Heres an XSLT stylesheet that defines how to transform the XML document: xsl:stylesheet xmlns:xsl=http:www.w3.org1999XSLTransform version=1.0 xsl:output method=html xsl:template match= xsl:apply-templates select=greeting xsl:template xsl:template match=greeting html body h1 xsl:value-of select=. h1 body html xsl:template xsl:stylesheet