XSLT, XPath and XSL Formatting Objects
Extensible Stylesheet Language (XSL) Version 1.0
became a W3C Recommendation on October 15, 2001 after several years of development.
It augments the flexibility of the
XML (Extensible Markup Language) standard.
XSL is a far more sophisticated style language than is
CSS.
XSL draws on earlier specifications including
CSS and
DSSSL.
According to the W3C's XSL page,
Extensible Stylesheet Language (XSL) is a language for expressing stylesheets
consisting of three parts:
- a language for transforming XML documents:
XSLT
- an XML vocabulary for specifying formatting semantics:
XSL, sometimes called XSL-FO
(Extensible Stylesheet Language Formatting Objects; aka XSL-FO, XSL:FO or XSL FO)
- a syntax for addressing parts of a document:
XPath,
a syntax which is also significant in
XPointer and to the
emerging XQuery, an XML query language.
"An XSL stylesheet specifies the presentation of a class of XML documents by describing how an
instance of the class is transformed into an XML document that uses the formatting
vocabulary." In other words, a stylesheet tells a processor how to convert logical structures
(the source XML document represented as a tree) into a presentational structure (the result tree).
Note that an XSL stylesheet is actually an XML document!
In terms of XML Namespaces, these correspond
to <xsl:>
[you might sometimes see the synonymous prefix <xslt:> or <transform:>]
and <fo:>,
for transformations and formatting objects, respectively.
For example:
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
xmlns:fo=
"http://www.w3.org/1999/XSL/Format"
result-ns="fo"
indent-result="yes">
<xsl:template match='/'>
<fo:basic-page-sequence
font-family="serif">
<fo:simple-page-master
page-master-name='scrolling'/>
<fo:queue queue-name='body'>
<xsl:apply-templates/>
</fo:queue>
</fo:basic-page-sequence>
</xsl:template>
<xsl:template match="title">
<fo:block font-weight="bold">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<!-- Parts omitted;
W3C XSLT spec has complete examples. -->
</xsl:stylesheet>
It is important to understand that the transformation part can be used independently of the
formatting semantics. Common transformations include converting XML to HTML, changing the order
of elements, and selectively processing elements.
In fact, as of early 2002, the majority of XSL implementations support only
the transformation part;
many do not yet address the formatting objects at all! This may be confusing if
you view XSL as mainly for rendering style.
However, tools that support XSL-FO are likely to appear rapidly throughout 2002.
(See also our
XSLT and XPath History page,
which tracks the confusing history of the Extensible Stylesheet Language.)
|
Last Modified:
July 9, 2002
XSLT and XSL-FO Starting Points
- Norman Walsh's 9-page article,
The Extensible Style Language: Styling XML Documents, appeared
in Web Techniques
in January 1999 (so some details are out-of-date).
The article covers how XSL works, what it looks like, how it differs from CSS,
Selectors and Patterns, Properties and Formatting Objects, and more.
Walsh is one of the contributors to the XSL specifications.
Great starting point, although dated!
- Norman Walsh's XSL Tutorial
slides - considerably more details based on the XSLT and XPath Recommendations of Nov. 1999
- Getting Started with XSLT and XPath
- G.Ken Holman [XML.com, Aug. 2000]
- XSL Formatting Objects: Here Today, Huge Tomorrow
- Frank Neugebauer [XML-Journal, Volume 3, Issue 01, Jan. 2002]
What are XSLT and XPath?
This page describes
XSLT and XPath,
and also tracks the confusing history of the Extensible Stylesheet Language.
What's New in XSLT 2.0?
This article by Evan Lenz from April 2002
describes the features of the
next version of XSLT which is not yet a W3C Recommendation.
Elliott Rusty Harold gave a related presentation entitled
XSLT 2.0 and Beyond (Feb. 2002)
which covers both XSLT and XPath 2.0.
What's New in XPath 2.0?
This article by Evan Lenz from March 2002
describes the features of the
next version of XPath which is not yet a W3C Recommendation.
XML Query
According to the W3C XML Query home page, the
"mission of the XML Query working group is to provide flexible query facilities to extract data from real
and virtual documents on the Web, therefore finally providing the needed interaction between the web world
and the database world. Ultimately, collections of XML files will be accessed like databases."
TransQuery
TransQuery, XSL Transformations as Query Language,
is a set of XSLT conventions and processing model constraints for using
XSLT as a query language over multiple XML documents. The purpose is to
promote interoperability between XML document management systems (and XML
databases) that use XSLT as their primary data access language.
News Items
Check xmlhack for XSLT/XPath news
and XSL-FO news items.
XSL, XPath, and XSL-FO Tutorials
A number of online XSL, XPath, and XSL-FO Tutorials are available:
A few XSL tutorials are based on old versions of the XSL Working Draft
and are therefore obsolete. They're included here for historical reference.
XSLT and XSL-FO Books, Articles and Papers
- Definitive XSLT and XPath
by G. Ken Holman; Dec. 2001, Prentice Hall
- XSL Essentials
by Michael Fitzgerald; Oct. 2001, John Wiley & Sons
- Professional XSL
by Kurt Cagle, et al; June 2001, Wrox Press
- XSLT Quickly
by Bob DuCharme; July 2001;
Manning
- Inside XSLT
by Steven Holzner; July 2001; companion guide to his
Inside XML book.
- XSLT Programmer's Reference
by Michael Kay; Second edition, April 2001, Wrox Press
- XSLT Working with XML and HTML
by Khun Yee Fung; Dec. 2000, Addison-Wesley
- XSL Companion
by Neil Bradley; Sept. 2000, Addison-Wesley
- Robin Cover's definitive list of XSL/XSLT articles
- Practical Transformation Using XSLT and XPath
by G. Ken Holman; Dec. 2001
- Practical Formatting Using XSL-FO
by G. Ken Holman; Dec. 2001
- Style Matters
- series of excellent articles by Didier Martin
(covering XML style and transformation related topics, such as XSLT and CSS),
- Hands-on XSL: XSL for fun and diversion
by Don R. Day, and
- Getting Started with XSLT Style Sheets and Java Servlets
by Edd Dumbill.
XSL Specifications from the W3C
The current Extensible Style Language spec is a lengthy
XSL Recommendation from the World Wide Web Consortium (W3C).
In April 1999, the tree transformations portion of the XSL Working Draft became a separate
document, XSL Transformations (XSLT).
See the history.
The following documents are completed W3C Recommendations (or requirements
that have been met):
Work on XSL Transformations (XSLT) Version 1.1
was stopped on Aug. 24, 2001, instead favoring XSLT 2.0 development
(to subsume XSLT 1.1 Requirements).
Working Drafts currently under development include:
Note: Extensive syntax changes were instituted in the August 1998 version of the XSL Working Draft.
Be aware that all books, tutorials, articles and examples prior to that time do not reflect the correct syntax.
W3C's Extensible Stylesheet Language Home Page
The W3C XSL home page is a major source of XSL information. It includes sections on:
- XSL News (includes updates to XSL tools)
- Tutorials
- Specs
- Implementations
- Reference
- Articles
- Mailing Lists
See also the W3C Style Sheets Activity page.
XSL FAQs and References
XSL Software and Related Resources
In addition to the current WDVL XSL page, the following sites are major sources of XSL information:
Selected XSLT and XSL-FO Tools
- XSLT Compiler (Sun)
- XSLTC - an XSLT Compiler that generates C++ code (Olivier Gerardin; link broken)
- XT (James Clark) (XSLT processor)
- SAXON XSLT Processor by Michael Kay, now a SourceForge project
- Xalan (Apache XSLT and XPath processor)
- Cocoon (XML publishing using XSLT)
- FOP (XSL Formatting Objects)
- Antenna House XSL Formatter
- LotusXSL (XSLT and XPath)
- IBM XSL Editor
- XJay generates JavaBean code from an XML Schema and XSLT Stylesheet
- XSLTmark - XSLT benchmark and a small compliance testing suite
- RenderX.com XEP Rendering Engine
- converts XSL-FO documents to a printable form (PDF or PostScript)
- PassiveTeX
- library of TeX macros that operate on an XSL-FO file
- MarrowSoft Xselerator - XSL/XSLT/XML IDE: editor, transformation testing and debugger
- Xfinity Designer - Visual XSL Stylesheet development tool for developers
- XSLT Test Tool
- edit XSLT and compare the major XSLT processors side-by-side (Windows only);
supports the following XSLT engines: Microsoft MSXML3,
Saxon,
Xalan,
Oracle XSL,
Sablotron,
Xt,
Unicorn,
Napa,
4XSLT, and
Instant Saxon.
- SAXPath: Simple API for XPath
- XPath Tester
- XSLT Standard Library, a SourceForge project
- EXSLT- community initiative to provide extensions to XSLT
- OASIS XSLT/XPath Conformance Technical Committee
- NIST XSLT and XSL-FO Conformance Testing
- Unofficial XSL DTD by RenderX
- XML.COM XSL -
resources for all three parts of XSL: XSLT, XPath, and XSL FO's.
- XSLT.com by XML Global
- 4xt.org - a site for XT users (get it?)
- Discussion Forum for XML/XSL Resources
- Oliver's XSLT page with examples such as
XML to HTML Verbatim Formatter with Syntax Highlighting
XSLT Quickly: Part 3
This third and final installment of
XSLT
Quickly exams element and attribute manipulation,
attribute value templates, and ends with a summary of the
tutorial.
XSLT Quickly: Part 2
This second installment looks at
a simple XSLT stylesheet, template rules, and running an XSLT processor.
XSLT
Quickly is, quite obviously, for anyone who needs to
learn XSLT quickly.
XSLT Quickly: Part 1
XSLT Quickly is, quite obviously, for anyone who needs to learn
XSLT quickly. This first installment covers XSLT and alternatives.
Getting Up to Speed with XSLT
The folks at Apache XML Project have a useful list of XSLT resources
on their page for xalan, their XSLT processor.
XSL Training
XSL training can be obtained from:
See also WDVL's XML-related Training page.
(Vendors of such XSL training materials may submit additions or
corrections to Ken Sall for
consideration.)
Gallery of Stupid XSLT Tricks
Incremental Development's Gallery of Stupid XSLT Tricks: Fun and Games with XSLT
provides real examples of XSLT transformations with
detailed explanations of how they work.
XSL Formatting Objects Mailing List
"XSL Formatting Objects are an emerging standard from the W3C. At present
there are few tools which do anything with XSL-FO and, until recently, none which
will display XSL-FO natively on screen.
Some early releases of useful XSL-FO tools are now beginning to emerge."
To access the messages, you must subscribe, which also gives you access to
XSL-FO Links.
XSL Mailing List Archive
Mulberry Technologies hosts technical discussions of XSL for developers, established April 1997.
To subscribe to the XSL list, send mail to:
majordomo@mulberrytech.com
In the body of the message put:
subscribe XSL-List
Post messages to: XSL-List@mulberrytech.com
Submit additions or corrections to Ken Sall
for consideration.
|