Chapter 18. Parting Words

It’s time for us to part company. If you have read the whole book, I trust you are fairly competent using XSLT and XPath by now. You should be proud of yourself for sticking with it to the end.

Whatever the case, this book is only an introduction to XSLT and XPath. You can now branch out and discover or rediscover some additional resources that are available for these technologies. Some of these I have mentioned before, but it will be nice to present all these resources in one place for your convenience. Here’s the list:

XSL Transformations (XSLT) Version 1.0

This is the original XSLT recommendation from the W3C. You’ll find it at http://www.w3.org/TR/xslt. It first appeared in November 1999, and it is under 100 pages long.

XML Path Language (XPath) Version 1.0

This concise little XPath recommendation is at http://www.w3.org/TR/xpath. It was introduced on the same day as the XSLT spec.

XSL Transformations (XSLT) 2.0

Here is XSLT 2.0 in working draft form, available at http://www.w3.org/TR/xslt20. It is over twice as long as the original XSLT 1.0 spec, but it offers plenty of new features.

XML Path Language (XPath) 2.0

The latest working draft of the 2.0 specification is available at http://www.w3.org/TR/xpath20. Like the XSLT 2.0 draft, it is considerably longer than its predecessor, and packed with all kinds of new features, not all of which are certain to make it into the final recommendation.

Michael Kay’s XSLT Programmer’s Reference, Second Edition (Wrox)

At over 900 pages, Michael Kay’s standard volume on XSLT weighs in heavily, but there is no fluff or waste. I have the first two editions of this book, and I count on them as a second-tier resource next to the XSLT specification itself. In fact, Michael’s book helps clarify and expand on the spec. If you are serious about XSLT, I suggest that you invest in this book.

Doug Tidwell’s XSLT (O’Reilly)

Doug Tidwell has a brisk and fun writing style that makes quick work of XSLT. I especially like the element and function reference appendixes at the end of the book. If you look up a particular element or function in the appendixes, you will find a complete stylesheet that demonstrates how to use that particular element or function.

Sal Mangano’s XSLT Cookbook (O’Reilly)

Sal’s popular book appeared at the end of 2002. The book crisply addresses just over 100 problems that can be addressed with XSLT recipes. If you do anything serious with XSLT, you’ll be glad to have Sal’s book on your shelf.

XSL-List

This active mail list maintained by Mulberry Technologies, Inc. is the place to go with your questions about XSLT. To subscribe, go to http://www.mulberrytech.com/xsl/xsl-list/index.html. The list archive, complete with search capability, is available at http://www.biglist.com/lists/xsl-list/archives/. Incidentally, Mulberry Tech also offers quick reference cards in PDF form for both XSLT and XPath at http://www.mulberrytech.com/quickref/index.html.

Robin Cover’s Coverpages for XSLT

Robin Cover provides broad and accurate coverage of a number of XML-related topics, including XSLT. Hosted by OASIS, the Coverpages are updated regularly and are considered by some as the resource of last resort when looking for technical information related to XML. See http://xml.coverpages.org/xsl.html.

Dave Pawson’s XSLT FAQ

Dave Pawson’s FAQ for XSLT is at http://www.dpawson.co.uk/. Dave has nicely organized the FAQ into categories. I find it easy to use, and it certainly has helped me pry a few rusty bolts off my stylesheets, so to speak.

Jeni Tennison’s site

Jeni Tennison is a top XSLT consultant and author whose web site (http://www.jenitennison.com) offers plenty of helpful information, including advice on how to perform grouping in XSLT 1.0.

Be sure to check the appendix, which follows this chapter, for references to XSLT processor resources. One last tool I’ll mention is a simple Java package I’ve written called Ox.

The Ox Documentation Tool

Although this book provides a glossary, it doesn’t provide alphabetical references for XSLT and XPath, partly because the other books I recommend, such as those written by Doug Tidwell and Michael Kay, have already provided excellent reference material. Short of that, you can still easily get the reference information you need about XSLT and XPath by using the glossary in this book and the Ox documentation tool that is provided with this book’s resources.

Ox is a small, extensible, open source command-line Java tool that quickly and easily provides brief, syntax-based documentation on a given topic. You can find the tool in the examples/Ox directory of the example archive that you downloaded with this book. Ox accepts one or more terms on a command line and then returns brief documentation on each term. At this time, Ox supports only XSLT 1.0 and XPath 1.0.

Give it a try. While in the directory examples/Ox, type the following command where the term is the name of an XSLT element. Ox is case sensitive, and all XSLT element names must be given in lowercase, as shown here:

java -jar ox.jar xsl:apply-templates

Ox will return the following information to you on standard output:

xsl:apply-templates XSLT instruction element
 Applies templates, processing a node-set (the matching
 node and its children, if any).
   
Attributes:
 select = An expression [optional]
 mode = The mode [optional]
   
Content:
 template
 <xsl:sort/> [optional]
 <xsl:with-param/> [optional]
   
Example:
 <xsl:template match="/">
  <xsl:apply-templates/>
 </xsl:template>
   
See Also: xsl:sort, xsl:value-of

You can also submit multiple terms to Ox, as shown in the following line:

java -jar ox.jar xsl:template xsl:apply-templates

This whitespace-separated list on the command line produces documentation on both terms:

xsl:template XSLT top-level element
 Container for an XSLT template.
   
Example:
 match = pattern [optional if name attribute present]
 mode = QName for mode [optional]
 name = QName for template [optional if match attribute present]
 priority = number for template's priority, the higher the number,
 the higher the priority [optional]
   
Content:
 template
 xsl:param [zero or more]
   
Examples:
 <xsl:template match="/">
  <xsl:apply-templates/>
 </xsl:template>
   
See Also: xsl:apply-templates
   
---------
   
xsl:apply-templates XSLT instruction element
 Applies templates, processing a node-set (the matching
 node and its children, if any).
   
Attributes:
 select = An expression [optional]
 mode = The mode [optional]
   
Content:
 template
 <xsl:sort/> [optional]
 <xsl:with-param/> [optional]
   
Example:
 <xsl:template match="/">
  <xsl:apply-templates/>
 </xsl:template>
   
See Also: xsl:sort, xsl:value-of

You can also submit one or more prefixed terms to Ox by using the -xsl switch:

java -jar ox.jar -xsl template apply-templates

This line will return the same output at the previous, prefixed example.

In addition to element names, you can also submit definitional terms to Ox, like XSLT:

java -jar ox.jar XSLT

Ox will return with:

XSLT
 Extensible Stylesheet Language Transformations

Phrased terms that contain spaces must be enclosed in quotes, as shown in the following line:

java -jar ox.jar "literal result element"

With this term, Ox will give you:

XSLT literal result element
 A non-XSLT element, defined literally in a template, that creates
 an element in the result tree.

If you submit a term that Ox doesn’t know, such as an XSLT 2.0 element name:

java -jar ox.jar xsl:result-document

Ox barks back, but also gives you a venue where to issue a complaint:

Term "xsl:result-document" not found.

If enough people show interest in Ox, it will grow and expand to meet the demand. Ox uses Java properties files to store its documentation. The Ox package includes a template (template.ox) that you can use to create your own documentation package or simply add terms on your own. All you have to do is add your properties file to the Ox JAR file (ox.jar), and you will have access to the terms from the command line.

Signing Off

Once again, the appendix provides information on where to download XSLT processors, and how to install and run them. There also is a glossary at the end of the book where you can look up XML, XSLT, and XPath terms. All the terms in the glossary are also available in the Ox tool, though the terms in Ox may be updated more regularly than those in the book.

As with any new technology, once you get past the jargon and barriers of entry, XSLT can be fun to learn and use. If you are doing anything with XML, it’s likely that you will have a reason to use XSLT, too. I hope this book has helped make the learning process go quickly for you. Now that you know what you’re doing, go ask your boss for a promotion.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.19.243