XSL Free Tutorial

Web based School

The components of the XSL language


Next Next


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--a language for referencing specific parts of an XML document

  • XSLT: XSL Transformations--a language for describing how to transform one XML document (represented as a tree) into another

  • XSL: Extensible Stylesheet Language--XSLT plus a description of a set of Formatting Objects and Formatting Properties


XML to result tree
An XSLT "stylesheet" transforms the input (source) document's tree into a structure called a result tree consisting of result objects.

Result tree doctypes

The result tree's structure is that of an XML document, and its objects correspond to elements with attributes

The result tree's structure and "tag set" can match that of any XML document or doctype. In particular, the result tree could be:

HTML/XHTML

result tree is easily written out as an HTML document

other XML doctype

result tree is easily written out as an XML document in this other doctype (for some further application-specific processing)

FO result tree

result tree's structure (and element and attribute names) matches the set of formatting objects and formatting properties defined by the (non-transformation) part of XSL

Serialization of the result tree is not necessary for further processing of the result tree.

An XSL stylesheet

An XSL stylesheet basically consists of a set of 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

Generally, elements in a stylesheet in the "xsl" namespace are part of the XSLT language, and non-xsl elements within a template are what get put into the result tree

HTML vs. XSL Formatting Objects
  • Transformation is independent of the target result type

  • Most people are more familiar with HTML so many of the examples in this tutorial use HTML

  • The XSL implementation in IE5 is incomplete. The examples in this tutorial will not work in IE5

  • The techniques apply equally well to XSL Formatting Objects or other tag sets

  • XSLT is a tree-to-tree transformation process

  • Serialization may vary depending on the selected output method

  • There is a distinction between HTML element names and HTML


The Structure of a Stylesheet
  • XSLT Stylesheets are XML documents; namespaces  (http://www.w3.org/TR/REC-xml-names)  are used to identify semantically significant elements.

  • Most stylesheets are stand-alone documents rooted at <xsl:stylesheet> or <xsl:transform>. It is possible to have "single template" stylesheet/documents.

  • <xsl:stylesheet> and <xsl:transform> are completely synonymous.

Note that it is the mapping from namespace abbreviation to URI that is important, not the literal namespace abbreviation "xsl:" that is used most commonly.





Next Next