XSLT - Making XSLT Your Friend

What and Why

XSLT enables you to convert XML into other forms.

For example, XML markup can be converted to HTML markup for display on the web. Or, XML markup can be converted to a simple text-only Read Me file. Yet another example would be the conversion of XML into FO (Formatting Objects) for PDF production or into help systems such as JavaHelp, Eclipse Help, Microsoft HTML Help 1.x, or WebWorks Help.

10,000ft View

XSLT gives you two basic building blocks:

Templates

Templates enable you to emit markup.

For example, given this input:

XSLT enables you to output a simple HTML document using this XML source:

Matching system

XSLT's matching system enables you to say when/where a template should be used.

Using the XML example above:

For example, given this input:

XSLT allows us to perform different actions in different situations:

Result:

XSLT Transform Playground

You can experiment with XSLT in your browser with WebWorks' "XSLT Transforms" toy. Access it from:

Clicking on the link for "XSLT Transforms" creates a new session for you:

You can create a bookmark to return to this session at any time in the future. The XSLT toy will automatically save and apply changes you make to your XML input and XSLT stylesheet as you type.

Power Hour XML + XSLT

During the Power Hour session, we created a simple XML input document and XSLT transform to display the XML as HTML. We used the following XML input and XSLT stylesheet:

You can experiment with this example by creating a new "XSLT Transforms" toy and cut/pasting contents into the appropriate input area.

Terminology

Stylesheet
XSLT source file which contains your Templates.
Templates
Markup to emit when a particular element/node is matched.
XPath Expression
Way to express how content should be matched. Enables you to treat an XML document like a database and perform queries against it.

BenAllums/@Webinars/Power Hour/2012-01-26 (last edited 2012-01-26 22:53:21 by BenAllums)