- Chapter 1: Essential XSLT
- A Little Background
- XML Documents
- What Does XML Look Like in a Browser?
- XSLT Transformations
- Making an XSLT Transformation Happen
- Using Standalone XSLT Processors
- Using Browsers to Transform XML Documents
- Using XSLT and JavaScript in the Internet Explorer
- XSLT Transformations on Web Servers
- XML-to-XHTML Transformations
- XSLT Resources
- XSL Formatting Objects: XSL-FO
- XSL-FO Resources
- Formatting an XML Document
- The XSLT Stylesheet
- Transforming a Document into FormattingObject Form
- Creating a Formatted Document
XSLT Resources
You can find a great deal of material on XSLT online, and it's worth knowing what's out there. Note that all the following URLs are subject to change without noticethese lists are only as up to date as the people that maintain these sites allow them to be, and things can change frequently.
XSLT Specifications, Tutorials, and Examples
The starting place for XSLT resources, of course, is W3C itself. Here are the URLs for the W3C specifications that are used in this book:
http://www.w3.org/Style/XSL/. The main W3C XSL page.
http://www.w3.org/TR/xslt. The XSLT 1.0 specification.
http://www.w3.org/TR/xslt11. The XSLT 1.1 working draft, which makes it easier to extend XSLT, and adds support for the W3C XBase recommendation.
http://www.w3.org/TR/xslt20req. The XSLT 2.0 requirements, which offer apreview of XSLT 2.0, including more support for XML schemas.
http://www.w3.org/TR/xsl/. XSL Formatting objects.
http://www.w3.org/Style/2000/xsl-charter.html. Goals of the XSL committee.
http://www.w3.org/TR/xpath. The XPath 1.0 recommendation.
http://www.w3.org/TR/xpath20req. The XPath 2.0 requirements, which offer apreview of XPath 2.0, which includes more support for XSLT 2.0.
http://lists.w3.org/Archives/Public/www-xml-stylesheet-comments/. The W3C list on XML stylesheets.
Many XSLT tutorials and examples are available from other sources as well; here's a starter list:
http://http.cs.berkeley.edu/~wilensky/CS294/xsl-examples.html. A number of XSLT examples.
http://msdn.microsoft.com/xml/reference/xsl/Examples.asp. XSLT pattern examples used in matching elements.
http://msdn.microsoft.com/xml/XSLGuide/xsl-overview.asp. Getting started with XSLT.
http://www.lists.ic.ac.uk/hypermail/xml-dev/xml-dev-Nov-1999/0371.html. PowerPoint XSLT tutorial.
http://www.mulberrytech.com/xsl/xsl-list/. An open list dedicated todiscussing XSL.
http://www.nwalsh.com/docs/tutorials/xsl/xsl/slides.html. XSLT tutorial.
http://www.oasis-open.org/cover/xsl.html. Coverage of what's going on in XSLT.
http://www.w3.org/Style/Activity. Good page listing what's going on at W3Con stylesheets.
http://www.xml101.com/xsl/. Good set of tutorials on XSLT.
http://www.xslinfo.com. Good collection of XSLT resources, collected byJames Tauber.
http://www.zvon.org/xxl/XSLTutorial/Books/Book1/bookInOne.html. Tutorials on XSLT, XPath, XML, WML, and others.
I know of only one Usenet group on XSLT, however, and it's run by Microsoftmicrosoft.public.xsl. Others will appear in time. You mightalso want to check out an XSL mailing listit's at http://www.mulberrytech.com/ xsl/xsl-list.
Besides W3C specifications, tutorials, and examples, you'll also find plenty of editors that you can use to create XSLT stylesheets online.
XSLT Editors
To create the XML and XSL documents used in this book, all you need is a text editor of some kind, such as vi, emacs, pico, Windows Notepad or Windows WordPad. By default, XML and XSL documents are supposed to be written in Unicode, although in practice you can write them in ASCII, and nearly all of them are written that way so far. Just make sure that when you write a document, you save it in your editor's plain text format.
Using WordPad -
Windows text editors such as WordPad have an annoying habit of appending the extension .txt to a filename if they don't understand the extension you've given the file. That's not actually a problem with .xml and .xsl files, because WordPad understands the extensions .xml and .xsl, but if you try to save documents that you create while working with this book with extensions that WordPad doesn't recognize, it'll add the extension .txt at the end. To avoid that, place the name of the file in quotation marks when you save it, as in "file.abc".
However, it can be a lot easier to use an actual XML editor, which is designed explicitly for the job of handling XML documents. Here's a list of some programs you can use to edit XML documents:
Adobe FrameMaker http://www.adobe.com. Adobe includes great, but expensive, XML support in FrameMaker.
XML Pro http://www.vervet.com/. Costly but powerful XML editor.
XML Writer, on disk, XMLWriter http://xmlwriter.net/. Color syntax highlighting, nice interface.
XML Notepad msdn.microsoft.com/xml/notepad/intro.asp. Microsoft's free XML editora little obscure to use.
eNotepad http://www.edisys.com/Products/eNotepad/enotepad.asp. A WordPad replacement that does well with XML and has a good user interface.
XMetal from SoftQuad http://www.xmetal.com. An expensive but very powerful XML editor, and many authors' editor of choice.
XML Spy http://www.xmlspy.com/. A good user interface and easy to use.
Arbortext's Epic http://www.arbortext.com/. A powerful editor, expensive, and customizable.
You can see XML Spy at work in Figure 1.5, XML Writer in Figure 1.6, and XML Notepad in Figure 1.7.
Figure 1.5 XML Spy editing XML.
Figure 1.6 XML Writer editing XML.
Figure 1.7 XML Notepad editing XML.
In fact, some dedicated XSLT editors are available. Here's a starter list:
http://lists.w3.org/Archives/Public/xsl-editors/. A W3C list discussing XSL editors.
IBM XSL Editor http://www.alphaworks.ibm.com/tech/xsleditor. Java XSLT stylesheet editor that provides a visual interface for writing stylesheets and writing select-and-match expressions. Currently, you must have Java 2 version 1.1 (not 1.2 or 1.3) installed, however.
Stylus http://www.exceloncorp.com/products/excelon_stylus.html. Stylus includes an XSLT stylesheet editor.
Visual XML Transformation Tool http://www.alphaworks.ibm.com/aw.nsf/techmain/visualxmltools. Visual XML Transformation Tool generates XSLT for transforming source documents into target documents for you.
Whitehill Composer http://www.whitehill.com/products/prod4.html. A drag-and-drop, WYSIWYG XSLT generator of XSLT stylesheets.
XL-Styler http://www.seeburger.de/xml. Includes syntax highlighting, tag completion, HTML preview, and more.
XML Cooktop http://xmleverywhere.com/cooktop/. This one is just out, and it looks like a good one, it lets you develop and test XSLT stylesheets.
XML Spy http://www.xmlspy.com/. XML Spy is an XML editor you can also use to edit XSLT.
XML Style Wizard http://www.infoteria.com/en/contents/download. A tool for generating XSLT files. The wizard creates an XSLT file by examining XML data and asking the user questions.
xslide http://www.mulberrytech.com/xsl/xslide. Supports an XSLT editing mode for Emacs.
XSpLit http://www.percussion.com/xmlzone/technology.htm. Enables you to split HTML documents into XML DTDs and XSLT stylesheets.
XSLT Utilities
There are also many XSLT utilities available on the Web, and the following list includes some favorites:
Microsoft XSL ISAPI Extension http://msdn.microsoft.com/downloads/webtechnology/xml/xslisapi.asp. The Microsoft XSL ISAPI Extension simplifies the task of performing server-side XSLT transformations.
Microsoft XSL-to-XSLT Converter http://msdn.microsoft.com/downloads/webtechnology/xml/xsltconv.asp. Converts XSL into XSLT.
XSL Lint http://www.nwalsh.com/xsl/xslint. XSL Lint is a syntax checker for XSLT that detects many types of errors.
XSL Trace http://www.alphaworks.ibm.com/tech/xsltrace. This product enables a user to visually step through XSLT.
XSLT Compiler http://www.sun.com/xml/developers/xsltc. Converts XSLT files into Java classes for transforming XML files.
XSLT test tool http://www.netcrucible.com/xslt/xslt-tool.htm. This tool enables you to run XSLT with various popular processors so that you can make sure your transforms work well on all systems. It also enables you to call Microsoft's MSXML3 from the command-line like any other XSLT processor.
XSLTC www3.cybercities.com/x/xsltc. Compiles XSLT stylesheets into C++ code. It's based on Transformiix, Mozilla's XSLT processor.
XSLTracer http://www.zvon.org/xxl/XSLTracer/Output/introduction.html. XSLTracer is a Perl tool that shows how the processing of XML files with XSLT stylesheet works.
That completes your overview of XSLT in this chapter, the foundation chapter. As you can see, there's a tremendous amount of material here, waiting to be put to work in this book. The rest of this chapter provides an overview of XSL-FO.