From the Inside Flap
then there was a time before that beginning.
And there was a time before the time
which was before the time of that beginning.
--- Zhuang Zi
This book is about XSLT, or XSL Transformations (XSL stands for Extensible Stylesheet Language), which is a language developed by W3C that can be used to transform XML documents. XSLT is so versatile that it can transform one kind of XML document to another kind of XML document, to an HTML document, or to a text document.
This book is for anybody who wants to use XSLT to transform XML documents to HTML documents. We will look at what XSLT is all about, how it is used for transformation to HTML, and especially how to write the XSLT documents for the transformation. Although XML to HTML is the focus of this book, the principles of transformation do not change whether you want to transform XML documents to HTML, XML, or text. Once you know how to produce HTML documents, you will possess the knowledge to produce the other two types as well. The Main Specifications
Before we get into XSLT, we must become familiar with its four core specifications: XSLT, XML, XML Namespace, and XPath. All four specifications are W3C recommendations; in other words, they are standards for the Web and the final authority for XML, XSLT, XPath, and XML Namespaces. These specifications are available at w3/TR. Because we will be using HTML as the primary output document format, you may want to look at the HTML specifications as well.
The Learning Curve
Although XSLT has concepts that require some programming fundamentals, it is not necessary to have a programming background. In other words, it is typical of the technologies that Web developers encounter and use every day. The definitions and examples should help you grasp the nonprogramming concepts.
This book was written in plain English, with as little computer jargon as possible. However, since you occasionally need to consult the specifications related to XSLT, I have used that terminology in the book.
To perform examples in this book, an XSLT processor program is needed. I use the XSLT processor written by James Clark to verify the examples. This XSLT processor can be obtained from James Clark's Web site: jclark. You can certainly use a different XSLT processor if you wish to. footnote: There is a chance XT may be retired shortly after this book is published.
Appendix A lists URLs that will help you find other tools to write XML and XSLT documents. Conventions Used in This Book
Concepts and terms are set in boldface type the first time they are used. Examples and code are set in the typewriter font. File names are set in italics. The '_' symbol is used to make the invisible space character visible. Organization
This book is organized into four parts and three appendixes. Part I provides you with the features of XML and XSLT that you will use most of the time. Part II describes the concepts of XSLT and XPath in more depth. Part III presents the usage of XSLT. Part IV discusses transformation to XML and text documents. The appendixes include online resources, character sets and encoding schemes, and a reference for XSLT and XPath, with many examples for the elements and functions in different circumstances. Part I
The first three chapters discuss the most frequently used 20 percent of XML and XSLT. You will be able to handle 80 percent of XSLT work in your daily life as an XSLT developer. Chapter 1, "Introduction," explains the importance of XML and the role of XSLT in the scheme of things. Chapter 2, "XML," is a simple introduction to XML. Chapter 3, "Introduction to XSLT," introduces you to XSLT. The most frequently used features are discussed here, with three related examples. Part II
The chapters in Part II explain how the transformation is constructed. Once you understand the transformation, you should have no problem writing XSLT documents to produce your desired result. Chapter 4, "XML Documents as Trees," displays the XML document as a tree. Chapter 5, "Paths," explains the all-important concept of location path. These are expressions that allow you to refer to elements, among other things, in XML documents. Chapter 6, "Transformation," explains the transformation process in XSLT, which uses templates for matching the XML documents. This is the foundation for understanding how XSLT provides a versatile tool to transform XML documents to HTML. Chapter 7, "Control," explains control elements in XSLT that allow you to manipulate XML documents. Chapter 8, "Constructing the Result Tree," shows you how to create the output document that you need for your project. Chapter 9, "Combining Templates," explains how templates can be combined together for reuse. Chapter 10, "Extensions," discusses the extension mechanism in XSLT. Part III
The two chapters in Part III examine the usage aspects of XSLT. Chapter 11, "Idioms and Tips," discusses some of the hard and not-so-hard lessons I learned in various XSLT projects. Chapter 12, "A Case Study," discusses the process and the XSLT documents necessary to design a Web site using XML and XSLT. Part IV
Part IV deals with transformation to XML and text documents. Chapter 13, "Transforming to XML and Text," presents examples of transformations from one XML document type to another XML document type. It also explains how to produce text documents with XSLT. Appendixes
Appendix A, "Tools and Resources," lists some of the URLs for XML and XSLT resources online. Appendix B, "Character Sets and Encoding Schemes," provides a simple explanation of character sets and encoding schemes. Appendix C, "XSLT and XPath Reference," provides examples for the elements and functions in XSLT. Once you understood the basic XSLT concepts, you will consult Appendix C often. Acknowledgments
I thank Kuni Katsuya and Glen Kim for being there when the idea for the book first came up. I thank Lucilla, Susan, and (Young) Brian for being the guinea pigs in my XSL tutorial. I thank David Faria for reading one of the first drafts.
I thank my family for supporting me while I worked 7 days a week, more than 12 hours a day. I thank Melissa for her love and support, even though I have been mentally absent for so long. I thank Opheliar for reading the first draft of the manuscript and offering helpful suggestions.
From the Back Cover
* XML and XSLT fundamentals
* Converting an XML document to a tree
* XPath expressions and context node
* Matching templates and current node
* Control elements in XSLT
* Constructing the result tree and output document
* XSLT idioms and tips for effective use
A complete case study using XML and XSLT to publish a Web site illustrates all the major concepts and techniques in the book. In addition, the CD-ROM provides the code for all the examples in the books, as well as the case study. 0201711036B07092001