XSLT Quickly (original) (raw)
"If you need to learn how to transform your XML documents, "XSLT Quickly" is the best place to begin...It's ideal as a tutorial for beginners or as a reference for more experienced developers. The price is right - less than $30, and the book easily pays for itself in time saved." - Mark Garrett in since1968.com.
Order online from amazon.com at 30% off list price
Manning's web page for the book, where you can order the book and link to the author forum and errata page.
Download the example files (see readme.txt in the zip file) for the book.
Portugese version now available from Brazilian publisher Ciencia Moderna!
XSLT 2.0 articles: XML.com has a complete list of Bob's Transforming XML columns about XSLT. Many are excerpts from the book; see also this page listing articles that cover new features in XSLT 2.0.
Introductions
The book has two parts: a tutorial and a users guide. The following shows the introductions for these two parts, which will give you an idea of the book's goals.
Part 1: Getting Started with XSLT
This tutorial will get you comfortable with the XSLT techniques necessary to perform the most basic transformation operations as you convert one document into another: reordering, renaming and deleting elements, renaming and deleting attributes, converting attributes into elements and elements into attributes, and selecting elements for processing based on their attribute values.
There's much more to XSLT than these operations, as the rest of this book shows, but these will get you far in tasks such as the following:
- Converting your company's XML data to conform to some industry standard.
- Converting XML data that conforms to an industry standard schema or DTD into something that works with your company's systems.
- Converting your company's XML into something that a client or supplier can understand as part of an XML-based electronic transaction.
- Converting a client or supplier's XML to work with your company's systems as part of an electronic transaction.
All of these tasks usually involve taking a subset of some data, rearranging the order of the pieces, and renaming some pieces. Once you can do these, you're ready to take part in the assembly of some of the most important parts of an e-commerce system.
Part 2: XSLT Users Guide: How do I work with...
This part of the book covers some advanced aspects of XSLT in more detail. Not exhaustive detail, because this isn't a reference book; as a users guide, this part of the book presents background and examples for different areas of XSLT so that you can put them to work in your stylesheets as quickly as possible.
There are seven chapters covering the following areas:
- There's a lot you can do with simple XPath expressions, but once you know the full range of possibilities for putting together axis specifiers, node tests, and predicates into an XPath expression of one or more location steps, you can grab almost anything you want from anywhere on the source document tree regardless of which node you're processing. Chapter 6, _XPath_covers this.
- Part 1 of this book shows some simple ways to manipulate elements; Chapter 7, Elements shows a broader range of techniques for inserting, deleting, moving, and reordering elements, as well as ways to count, combine, and duplicate them. This chapter also describes how to find empty elements in the source tree and how to create them in the result tree, various approaches to dealing with sibling elements, and ways to select elements based on their name, content, children, and parents.
- Like the preceding chapter, Chapter 8, Attributes expands on the basic techniques described in the tutorial. It covers the adding of new attributes to the result tree, converting them to elements, getting their values and names, testing for their existence and values within a particular element, and how to define and re-use groups of attributes in different result document element types.
- Chapter 9, Stylesheets and Templates covers techniques that make it easier to create and manage larger, more complex stylesheets. In addition to explaining how to combine stylesheets, it covers the use of named templates, which let you apply templates explicitly instead of waiting for the XSLT processor to do it for you.
- XML is more than elements and attributes. More sophisticated documents may take advantage of entities (especially to incorporate images and other non-XML data), namespaces, processing instructions, comments, and namespaces. Chapter 10, Advanced XML Markup describes ways to find these in your source documents and techniques for creating and controlling them in your result documents.
- Developers coming to XSLT with a programming background want to know how to perform certain operations offered by most other programming languages: if statements, case (or in XSLT, "choose") statements, loops, setting and using variables, passing values to functions and programs (or in XSLT's case, to named templates and stylesheets), special functions for string and number manipulation, the adding of new functions to use in stylesheets, and the use of other developers' extension functions and elements. Along with these topics, Chapter 11, Programming Issues covers some debugging techniques and provides a guide to using the W3C's official XSLT specification.
- XSLT can be used to read all kinds of XML input and to create all kinds of XML and non-XML output, but certain formats are particularly popular and present their own set of advantages and disadvantages. Chapter 12, Specialized Input and Output covers techniques for dealing with HTML as both input and output, Web browsers, stripping XML markup for plain text output, creating valid XML documents, and creating formatting object files that conform to the XSL specification. It also covers sorting and automatic numbering, handling of white space, creating IDs and links, and splitting of output into multiple files.
Appendixes in XSLT Quickly provide a quick reference to XSLT syntax, notes and sample command lines for running several XSLT command line processors, and a glossary.