Introduction to XSL

Introduction to XSL

XSL stands for EXtensible Stylesheet Language. The World Wide Web Consortium (W3C) started to develop XSL because there was a need for an XML-based Stylesheet Language. Thus it is a language for expressing Stylesheets.

A stylesheet specifies the presentation of XML information using two basic categories of techniques:

  • An optional transformation of the input document into another structure.
  • A description of how to present the transformed information.

The components of the XSL language The full XSL language logically consists of three component languages, which are described in three W3C (World Wide Web Consortium) Recommendations:

  • XPath: XML Path Language is an expression language used by XSLT to access or refer specific parts of an XML document
  • XSLT: XSL Transformations is a language for describing how to transform one XML document (represented as a tree) into another.
  • XSL-FO: Extensible Stylesheet Language Formatting Objects is a language for formatting XML documents
    and Formatting Properties.

Understanding XSL Stylesheet Structure (a) XSLT namespace

The XSL stylesheet starts with the root element <xsl:stylesheet> or <xsl:transform> that declares the document to be an XSL style sheet.

The correct way to declare an XSL style sheet according to the W3C XSLT


Recommendation is:

<?xml version=”1.0" ?>
<xsl:stylesheet version=”1.0"


<xsl:transform version=”1.0"

Since an XSL style sheet is an XML document itself, it always begins with the XML declaration: <?xml version=”1.0" ?>

To get access to the XSLT elements, attributes and features we must declare the XSLT namespace at the top of the document. The xmlns:xsl=” Transform” points to the official W3C XSLT namespace. If you use this namespace, you must also include the attribute version=”1.0". This specification uses a prefix of xsl: for
referring to elements in the XSLT namespace. However, XSLT stylesheets are free to use any prefix.

Now set it up to produce HTML-compatible output:

<xsl:output method=”html”/>

(b) Stylesheet Element

The <xsl:template> Element
An XSL style sheet consists of a set of rules that are called templates. Each template “matches” some set of elements in the source tree and then describes the contribution that the matched element makes to the result tree. Most templates have the following form:

<xsl:template match=”/”>
Mar  2008 | Java Jazz Up | 12
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

, 59,

Download PDF