XSLT Fundamentals Class

This XSLT course is the last two days of the five-day XML training course, but it can be taken independently of the full package.

This XSLT class examines XSLT and XPath. XSLT is used to transform your XML documents into a format appropriate for particular applications (e.g., browsers) such as HTML or text. XPath allows you to specify a location in the referenced XML document to indicate which content or information you would like to use or extract. XPath provides a number of functions that may be applied to calculate, limit, or filter the query results.

XSL - The Language

XSL or Extensible Style Language is really a collection of several different languages including XSL Formatting Objects (XSLFO) and XSL Transformations (XSLT). Because of the complexity of XSLFO, we focus on XSLT and its sister technology, XPath. During your introduction to XSL, you will learn about:

the XSL family - its history, goals, state of development and common uses

the notion of transformation - specifically transforming XML into HTML

XSLT Templates

The transformation process relies upon templates that you define in your XSL. The XSL processor then matches portions of the XML that you dictate and replaces these portions with the code you described in your template, resulting in a brand new file. We examine the XSL templates and how the transformation process proceeds. In this course you will learn how to:

establish XSLT templates

designate matches with basic XPath

extract data from XML elements to be placed in the templates

extract data from XML element attributes

use a simple XSL processor

define the output type for your new document

transform XML to text

transform XML to HTML

apply particular (or all) templates

XSLT Elements

XSLT's power becomes more evident when we introduce several useful XSL elements. The folks at the W3 clearly sought a robust language when crafting XSL and provided tools for conditionals, loops, sorting, selection by regular expression (i.e., patterns) and more. In this course you will learn about:

testing and filtering results using XPath and XSLT conditionals

XSLT conditionals including XSL:IF and XSL:CHOOSE

XSLT simple "for-each" loops

how to sort the output of a for-each loop

how to create a secondary sort (subsort)of the data

how to add text to the resulting document

XPath in Use

XPath's power truly emerges when specifying complex node paths and utilizing XPath functions. In this part of the course you will learn how to:

specify a context, parent, child and attribute node

apply some valuable XPath functions

count the number of items in a node-set

perform basic math functions on numerical data

generate IDs for each node in a node-set

determine an element node's name and whether it has content using XPath

determine when and where an XPath function may be called

XSLT in Action

Our final segment illustrates some useful implementations of XSLT. Specifically, we will create a table of contents for our HTML output. In this course you will learn how to:

create and apply multiple templates for the same content

"call" a template or "apply" a template

add an attribute to an element in the resulting document

create a table of contents

Prerequisites:

Intermediate HTML, or equivalent experience

Intro to XML or equivalent experience

Some programming experience is helpful but not required: understanding of variables, conditionals, and loops