XSL: Transformations and Style
Vincent Quint
World Wide Web Consortium
WWW9 - Amsterdam - 18 May 2000
Extensible Stylesheet Language (XSL)
XSL is a language for expressing stylesheets
- support for browsing, printing, and aural rendering
- formatting highly structured documents (XML)
- performing complex publishing tasks: tables of contents, indexes,
reports,...
- addressing accessibility and internationalization issues
- written in XML
XSL Architecture
XSL Components
XSL is constituted of three main components:
- XSLT: a transformation language
- XPath: an expression language for addressing parts of XML documents
- FO: a vocabulary of formatting objects with their associated
formatting properties
XSL uses XSLT which uses XPath
XSL Transformations
XSLT - Basic Principle
Patterns and Templates
- A style sheets describes transformation rules
- A transformation rule: a pattern + a template
- Pattern: a configuration in the source tree
- Template: a structure to be instantiated in the result tree
- When a pattern is matched in the source tree, the corresponding pattern
is generated in the result tree
An Example: Transformation
<xsl:template match="Title">
<H1>
<xsl:apply-templates/>
</H1>
</xsl:template>
Input :
<Title>Introduction</Title>
Output :
<H1>Introduction</H1>
An Example: Formatting
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
result-ns="fo">
<xsl:template match="/">
<fo:page-sequence font-family="serif">
<xsl:apply-templates/>
</fo:page-sequence>
</xsl:template>
<xsl:template match="para">
<fo:block font-size="10pt" space-before="12pt">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
</xsl:stylesheet>
XPath: XML Path Language
An elementary XPath expression contains
- an axis, which specifies the tree relationship: child, descendants,
ancestors, siblings, attributes,...
- a node test, which specifies the node type
- predicates, to further refine the set of nodes selected
Example: all para
children that have a type
attribute with value warning
child::para[attribute::type="warning"]
XSL Usage
- Format XML documents by generating FOs
- Generate HTML or XHTML pages from XML data/documents
- Transform XML documents into other XML documents
- Generate some textual representation of an XML document
- ...and more
XSL may be used server-side or client-side,
but is not intended to send FOs over the wire
Implementations
XSL software include:
- XSLT transformation engines: 4XSLT, IE5, iXSLT, LotusXSL, Transformiix,
Resin, Sablotron, Saxon, Xalan, XML Parser (Oracle), XT
- FO formatters: FOP, FO2PDF, InDelv browser, Passive TeX, REXP
- XSL stylesheet editors
- Style sheets and transformation sheets
XSL and CSS
XSL is not intended to replace CSS, but provides functionality beyond that
of CSS
XSL/CSS Common features:
- Formatting model
- Properties and values
History
XSL is inspired by both CSS and DSSSL (ISO/IEC 10179:1996)
- Sep 1997: "A Proposal for XSL"
submitted to W3C by Inso, Microsoft, ArborText, U. of Edinburgh
- Jan 1998: The W3C Working Group for XSL is formed
- Feb 1998: The XSL list
starts up
- Aug 1998: The first XSL working draft is published
- Apr 1999: The third XSL working draft is released. A
separate document specifies the transformation language (XSLT)
- Jul 1999: A new working draft of XSLT is released. The
expression language is specified in a separate working draft, XPath (with
XML Linking WG)
- Aug 1999: XSLT, XPath enter Last Call
- Oct 1999: XSLT, XPath move to Proposed Recommendation
status
- Nov 1999: XSLT, XPath become W3C Recommendations.
- Jan 2000: New XSL (FO) working draft published
- Mar 2000: XSL enters Last Call
Current Situation
- XPath 1.0 is a W3C Recommendation
- XSLT 1.0 is a W3C Recommendation
- XSL (FO) is in Last Call
What the Future Holds
Next step: move XSL 1.0 to W3C Recommendation status
New WG proposed to work on new versions of all 3 specifications: XSL, XSLT,
XPath
- FOs: additional
support of internationalized formatting objects, general regions
- XSLT,
XPath: expanded extension mechanism, requirements from
appendix G of XSLT version 1.0
XPath is used in XPointer and XLink, considered by XML Query WG
More information
W3C XSL page: http://www.w3.org/Style/XSL
XSL, XSLT, XPath specifications: http://www.w3.org/TR
Public mailing list:
http://www.mulberrytech.com/xsl/xsl-list