P1: 61
WL040C-197-Quin WL040/Bidgoli-Vol III-Ch-56 June 23, 2003 16:38 Char Count= 0
694 WEBCONTENTMANAGEMENTstylesheet documents. When CSS is used to define format-
ting styles for a tag or class of tags, it automatically applies
the styling and overrides any default styling that may ap-
ply (such as the formatting tags H1, H2, etc.). Although
CSS is useful for formatting and determining how a doc-
ument will look, it is a strict language in the sense that
the source content can only appear in the order as it is.
In other words, no reordering is allowed and hence offers
nothing for structural transformation.
XSL is a language that provides the mechanism to
transform and manipulate XML data. The XSL specifi-
cations consist of a number of components: XSL trans-
formation (XSLT), XSL formatting objects (XSL-FO), and
XML path language (XPath) (W3C, 2002b). The benefits
of using separate styles to transform content includeReuse of fragments of data: the same content should
look different in different contexts;
Multiple output formats: different media (paper, online),
different sizes (manuals, reports), and different classes
of output devices (workstations, hand-held devices);
Styles tailored to the reader’s preference (e.g., acces-
sibility): print size, color, simplified layout for audio
readers;
Standardized styles: corporate stylesheets can be ap-
plied to the content at any time; and
Freedom from style issues for content authors: technical
writers needn’t be concerned with layout issues because
the correct style can be applied later (Grosso & Walsh,
2000).Unlike CSS, which is limited in presenting XML data,
XSLT describes rules for transforming a source tree (as
defined in the form of a document-type definition (DTD)
or an XML schema) into a result tree. The result tree
may or may not bear the same structure as the source
tree because XSLT specifications permit transformation
templates to reorder the sequence of XML data elements,
create new elements, and manipulate loop processing of
XML data. By associating XML document structures with
XSL templates, the transformation matches the structural
patterns against elements in the source tree and generates
a result tree that is separate from the source tree (Fig-
ure 5) (W3C, 1999c). A transformation expressed in XSLT
is called a stylesheet. This is because, in the case when
XSLT is transforming into the XSL formatting vocabu-
lary, the transformation functions as a stylesheet. Listing
4 shows the template for transforming the XML instance
into an HTML document.Figure 5: An example of XSL transformation: the data ele-
ments are reordered and new elements are created in the result
tree.<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "C:\\box5.
dtd">
<xsl:stylesheet version="1.0" xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
xmlns fo="http://www.w3.org/1999/XSL/
Format"><xsl:template match="/">
<html>
<head>
<title>Books in Stock</title>
</head>
</body>
</xsl:apply-templates/>
</body>
</html>
<xsl:template><xsl:template match="Book">
<h2>
<xsl:apply-templates select=
"Title">
</h2>
</xsl:template><xsl:template match="Authors">
<p>
<xsl:for each select="Author">
<xsl:value-of select=
"Author"/>
</xsl:for-each
</xsl:apply-templtes/>
</p>
</xsl:template><xsl:template match="Book">
<xsl:value-of select="Publisher"/>
<xsl:value-of select="PubDate"/>
<xsl:value-of select="ISBN"/>
<xsl:apply-templates/></xsl:template></xsl:stylesheet>
Listing 5:The Transformation Stylesheet for the Example in
Listing 4In Listing 4, the first template creates an HTML
shell for the content and the second and third tem-
plate rules transform the title, author, publisher, publi-
cation date, and ISBN into HTML elements. Compared to
CSS, XSLT offers much more capabilities in manipulating
XML data.
To complete the transformation from XML to vari-
ous deliverable presentations, XSLT must work together
with two other component languages—XPath and XSL
formatting language. XPath is used to reference specific
parts of an XML document while the XSL formatting
language describes a set of formatting objects and pro-
perties.