Introduction to XSLT CHAPTER 6 In this chapter and the one that follows, you ll explore Extensible Stylesheet Language Transformations (XSLT). XSLT is a World Wide Web Consortium (W3C) recommendation, and you can find out more about it at http://www.w3.org/Style/XSL/. The W3C has two XSLT recommendations 1.0 and 2.0. At the time of writing, XSLT 2.0 is a candidate recommendation. You use XSLT to transform a source XML document into a different XML document, called the results tree. As XHTML is a vocabulary of XML, you can also use XSLT to transform XML into XHTML for display in a web browser. In Chapter 5, you saw how to use Cascading Style Sheets (CSS) to display XML. Using CSS, the XML document can take on many style attributes to make it appear like an XHTML page. You can use some advanced CSS techniques to add additional content or to display images. However, the browser still displays an XML document. XSLT offers an alternative approach because it generates XHTML from the XML document. You can then use CSS to apply styling. XSLT makes it much easier to add extra content compared with CSS. You can also use advanced features such as sorting and filtering. XSLT isn t limited to producing XHTML documents. It can also convert your content into alternative formats, such as Rich Text Format (RTF) documents and comma-separated values (CSV) files for Microsoft Word and Excel. XSLT s cousin, Extensible Stylesheet Language Formatting Objects (XSL-FO), can create printed content such as that found in PDF files. CSS and XSLT serve different purposes when working with XML. XSLT is a very powerful tool, but CSS can often be better for simple tasks. Sometimes you need to use a combination of both technologies to achieve the right outcome. This chapter will provide you with enough information so that you can decide which technology is appropriate for your needs. In Chapters 11 to 13, you ll learn how to apply XSLT transformations server-side. In this chapter, I ll focus on client-side transformations. I ll give you an overview of XSLT and demonstrate how to style XML in the web browser. Chapter 7 will cover some more complicated applications of XSLT. Let s start by looking at which browsers support XSLT. Browser Support for XSLT As you saw in Chapter 4, most recent browsers support XSLT 1.0, with the exception of Opera 8.5. At the time of writing, the forthcoming Opera 9 release is expected to support XSLT. Table 6-1 shows the support for XSLT in the most recent browser versions.
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.