XSLT Fundamentals

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

An XSLT results in the creation of a new XML tree. This clear separation between the source document and the result trees fulfills the goal of XML to separate content from presentation by allowing both the grammar and structure of the XML source to be independent of the presentation language and structure.

At its most basic, XSLT provides a capability similar to a "mail merge." The style sheet contains a template of the desired result structure, and identifies data in the source document to insert into this template. This model for merging data and templates is referred to as the template-driven model and works well on regular and repetitive data. This model will be familiar to users of Active Server Pages (ASPs), which embed bits of script within an HTML template to control processing and insert data. Microsoft Internet Explorer data binding also uses a template-driven model — elements in the HTML page provide templates for displaying bound data.

XSLT also provides capabilities for handling highly irregular and recursive data, as is typical in documents. Template fragments are defined, and the XSLT processor combines the results of these fragments into a final result tree based on the shape of the source data. Each template fragment declares the type and context of source nodes it is appropriate for, allowing the XSLT processor to match source nodes with template fragments. This model is known as the data-driven model because the shape of the data drives the shape of the final output.

Template-driven and data-driven transformation mechanisms can be combined in a single style sheet, making XSLT appropriate to a wide variety of XML applications.

The following topics will introduce you to the basic XSLT syntax:

You can learn more about the XSLT language from the following topics: