Contact us Heritage collections Image license terms
HOME ACL ACD C&A INF CCD CISD Literature
Further reading □ Overview □ 1998 □ 123456789101112 □ 1999 □ 131415161718192021222324 □ 2000 □ 252627282930313233343536 □ 2001 □ 373839404142434445464748 □ 2002 □ 495051525354555657585960 □ 2003 □ 616263646566676869707172 □ 2004 □ 737475767778798081828384 □ 2005 □ 858687888990919293949596 □ 2006 □ 979899100101102103104105106107108
Harwell Archives Contact us Heritage archives Image license terms

Search

   
CISD and DCILiteratureW3C UK News (1998-2006)
CISD and DCILiteratureW3C UK News (1998-2006)
ACL ACD C&A INF CCD CISD Archives
Further reading

Overview
1998
123456789101112
1999
131415161718192021222324
2000
252627282930313233343536
2001
373839404142434445464748
2002
495051525354555657585960
2003
616263646566676869707172
2004
737475767778798081828384
2005
858687888990919293949596
2006
979899100101102103104105106107108

Issue 9: September 1998

XSL

On 18 August, 1998, W3C announced the first public working draft of the Extensible Style Language (XSL) 1.0 specification.

You may well ask why we need another style sheet language as well as CSS2. The good news is that XSL is not designed to replace CSS, both XSL and CSS will be developed in parallel. CSS will still be used to style HTML and XML documents on the Web. XSL is aimed at activities such as rearranging the document that are not supported by CSS. XSL and CSS share the same underlying concepts and use the same terminology where possible.

With XSL, you will be able to specify the print styling of Web documents at least as well as a typical word processor. Future support for high-end print typography is also planned. XSL comes in basically two parts:

We will just give a flavour of the first. The XML source document is considered as a tree. So, for example, a fragment of XML might be:

<today>
<garden>
<item>Find mower</item>
<item>Cut grass</item>
</garden>
<leisure>
<item>Read book</item>
<item>Watch TV</item>
<item>Have dinner</item>
</leisure>
<work>
<item>Drive to work</item>
<item>Learn XML</item>
<item>Drive home</item>
</work>
</today>

Which would have a tree:

XSL Tree

XSL Tree
Full image ⇗
© UKRI Science and Technology Facilities Council

The associated text strings would hang off the item nodes.

In XSL, you can then define a set of rules (written in XML) that transform this source tree into a result tree. You do this by defining patterns that identify nodes in this tree and associating a template that defines an action to be applied. The two parts define a template rule.

The simplest style sheet is:

<xsl>
</xsl>

which does not look too exciting. However, there is a built-in template rule which says if no template rule exists for a node, just process the children nodes of that node in order. So the XSL style sheet above would start at the top and do a tree walk where the default process for the leaves is to output the content of the node thus transforming the tree into:

Find mower
Cut grass
. . . . .

Now suppose we would like to generate a Web page (we could have said XML, RTF or troff as well). The simplest thing to do would be something like:

<xsl>
<template match="item">
<P>
<process-children/>
</P>
</template>
</xsl>

We have omitted some detail but the example gives a flavour of what the style sheet would be like. The tree walk would eventually get to an item node and this time there would be a pattern rule to apply. The action is to output an HTML paragraph. The process-children command causes all the children nodes of the node in question to be processed in order. In our case, this would just cause the text to be output so we would have:

<P>Find mower</P>
<P>Cut grass</P>
<P>Read book</P>
. . . . .

Clearly, some differentiation has to be made between what are XSL rules and what is output which gets us into how you differentiate XML namespaces but we will not go into that here! It gets more interesting when you start using the full complexity of the pattern matching you can do. In our example, it would be more appropriate for the garden part of the tree to generate a list:

<template match="garden">
<OL>
<process-children/>
</OL>
</template>
<template match="garden/item">
<LI>
<process-children/>
</LI>
</template>

The first rule matches the garden node while the second just deals with item nodes as children of garden nodes. The result would be:

<OL>
<LI>Find mower</LI>
<LI>Cut grass</LI>
</OL>

For the other item nodes, the earlier, less specific rule would still apply.

We can give specific actions for nodes dependent on position. So we could have:

<template match="garden">
<P>
<process-children/>
</P>
</template>
<template match="garden/item[first-of-type]">
<process-children/>
</template>
<template match="garden/item[last-of-type]">
<text>THEN</text>
<process-children/>
</template>

producing:

<P>Find mower THEN Cut grass</P>

The major difference between CSS and XSL is the ability to define a different order for the output in XSL so we could have:

<template match="today">
<process select="leisure/item[first-of-type]">
<process select="work">
<process select="leisure/item[last-of-type]">
<process select="garden">
<process select="leisure/item[first-of-type]">
</template>

The item node selector has a qualifier added which indicates which child node is being processed. In this example, we read a book, learn XML at work, have dinner, do the garden and read a book again before going to bed and we don't watch TV at all! This illustrates that you can process information twice (useful for Contents pages, for example) and can ignore parts of the tree.

Clearly, we have only given a really quick introduction to a large document. If it has wetted your appetite, the full draft is available for comment by all at: http://www.w3.org/TR/WD-xsl.

New Members

There is a strong presence of European and Asian-Oceania companies joining W3C this month with the number of members now standing at 275.

Recent new members are:

Date for the Diary

We are planning to hold a full day event in London on Tuesday, 8 December, 1998 which will give details of the latest Web Recommendations from W3C and end-user experience of these. Further details will be available in next month's Newsletter.

⇑ Top of page
© Chilton Computing and UKRI Science and Technology Facilities Council webmaster@chilton-computing.org.uk
Our thanks to UKRI Science and Technology Facilities Council for hosting this site