[This local archive copy mirrored from the canonical location: http://www.ltg.ed.ac.uk/~ht/swindon.html; see this official version of the document.]

An Introduction to XSL
Henry S. Thompson
HCRC Language Technology Group
University of Edinburgh

Slides from a talk to SGML UK

Oct 27 1997

1. Acknowledgements

This work was carried out at the Human Communication Research Centre, whose baseline funding comes from the UK Economic and Social Research Council, with support from both Microsoft and Sun.

2. What is XSL?

XML as chartered included three components:

The document A Proposal for XSL grew out of discussions between James Clark, Istvan Cseri and Henry Thompson, and eventually involved significant representation from people intimately involved with both DSSSL and CSS.

3. The Status of XSL

The document submitted to W3C is expected to be the starting point for the XSL standardisation effort, which is in the process of being spun off from the XML effort within W3C.

As a W3C Note it has no official status beyond being on record as such.

Accordingly although this talk is about the document, not the thing itself, the document represents a pretty good guess as to what the thing itself will eventually look like.

4. XSL is XML

No parentheses!

XSL is notated with XML element types

DSSSL semantics without DSSSL syntax

5. Fundamental Aspects of XSL

A declarative approach, using XML to specify both the "pattern" and the "action" of construction rules.

An XML DTD for a set of flow object types and attributes adequate to provide on-screen display as well as some printing support.

A smooth escape to an expression language similar to JavaScript when computation is required.

Extensibility for both the declarative and procedural aspects.

6. Pattern-Action Construction Rules

Both the pattern and the action use XML nesting to represent source (respectively output) nesting.

The pattern is built up from element types target-element, element and attribute.

The action is uses element types named after flow-object classes (DSSSL or HTML, see below).

<rule>
 <element type='div'>
  <target-element type='title'/>
 </element>

 <p font-weight='bold'>
  <children/>
 </p>
</rule>
7. XSL and DSSSL

The example above translates into DSSSL as follows

(element (div title)
  (make p font-weight: "bold"
   (process-children)))

A series of draft extensions to DSSSL exists, known as DSSSL2, which make translation from XSL to DSSSL easier.

The pattern component of element construction rules is much richer, extending what is already possible with match-element?, enabling the richer XSL patterns to be translated.

Limited side-effects have been introduced to the expression language, to facilitate XSScript translation.

8. XSL and CSS

We could try translate our example into CSS as follows:


div title { font-weight: bold }

But that would of course be wrong:

Also the interpretation of nesting is different: The XSL pattern matches title elements with div as parent, where the CSS pattern matches title elements with div as ancestor at any remove.

9. More Flexible Patterns

XSL allows a rich declarative pattern language.

Wild-cards

<element type='div'>
 <element>
  <any>
   <target-element type='title'/>
  </any>
 </element>
</element>

This will match title elements under div only if the are not immediate children thereof.

There are other attributes on (target)-element which allow specialisation to particular positions wrt siblings.

9.1. Richer Patterns, cont'd

Attributes can be tested for

Patterns can extend to children and descendants of the target element, using the same element types (element, target-element, attribute but not any).

<target-element type='employee'>
 <element type='salary'/>
</target-element>

This will match employee elements provided they have at least one salary child.

This emphasises that in many cases the choice of attribute vs. sub-element in content models is pretty arbitrary.

10. Richer Patterns, CSS influences

class and id attributes provide privileged syntax for CSS-style matching.

Style- rules without flow-object actions are additive.

<style-rule>
 <target-element class='important'/>

 <apply font-weight: 'bold'/>
</style-rule>
11. Specificity

With all these pattern variants, what happens if two rules match?

Drawing on both DSSSL and CSS, there are a set of precedence rules.

Basically, the richer the pattern, the higher precedence.

If all else fails, there are importance and priority attributes.

12. XSL and HTML

A set of alternative, HTML4-based flow-objects are provided for.

Exactly how this will work is as yet unclear.

13. Expression Language

What about the need to actually compute things?

Still no round parens!

Imperative style language based on ECMAScript (standardised JavaScript)

Can be used both in attributes and body

<div font-size="=inheritedFontSize*1.2">

<eval>
var hier=hierarchicalNumberRecursive("div",this);
return formatNumberList(hier,"1",".");
</eval>
14. Implementations of XSL

Two implementations known to be underway:

15. Shameless Plugs

The HCRC Language Technology Group supplies a C-based XML parser and tool-kit.

We're giving a 4-day introductory document management course, covering document management both top down (was is document management and what can it do for you) and bottom-up (SGML, XML, DSSSL, XSL, HTML), with hands-on work, in the first week in December.

I'm doing a two-day electronic formatting course covering DSSSL, CSS and XSL for Technology Appraisals on 26 and 27 November.