XSLT

Executive Summary

XSLT (Extensible Stylesheet Language Transformations) is a language for transforming and processing XML documents that is itself expressed using an XML syntax. It has typical programming constructs such as looping, decision structures, and conditionals. It is the essential method for processing XML-encoded information.

What It Is

Wikipedia defines XSLT as "an XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing document." The word "document" should be interpreted loosely, however, since the output of an XSLT transformation may simply be a stream of data sent to another application.

To use XSLT, you must have an XML document, an XML parser (e.g., Saxon, Xerces, etc.), and an XSLT stylesheet. The parser is called and provided with the XML file and the XSLT stylesheet as input. The parser reads the XML document into memory, creating a "tree' depiction of the document based on its hierarchical structure. This structure is then compared against the XSLT stylesheet for any matching "templates" or chunks of code that should be applied to specified sections of the XML document. It should be noted that this is a completely different processing model than standard programming languages, and therefore can represent a learning challenge for programmers accustomed to a different mode of processing data.

What Can Be Done With It

XSLT can be used to process any XML file. Processing can include such things as translating to another format (e.g., another XML file, HTML, etc.) or providing selected input to a software program.

Since XSLT is similar to programming languages that can be used to accomplish virtually anything computer-based, XSLT is a basic tool that can be applied in a virtually infinite number of ways.

Examples

At FreeLargePhotos.com I have tiny little XML files for each of the 700 or more photographs I have available on the web. They look like this:

<photo>
<title>A sunset dinner on the Esplanade.</title>
<subject>Esplanade</subject>
<subject>Sunset</subject>
<subject>Grand Canyon National Park</subject>
<subject>Arizona</subject>
</photo>

This XSLT stylesheet:

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
<xsl:output method="html"/>

<xsl:template match="/">
   <p><i>Photo:</i> <b><xsl:value-of select="//title"/></b>
   <br /><i>Subjects:</i>
    <xsl:for-each select="//subject">
        <br /><xsl:value-of select="."/>
    </xsl:for-each></p>
</xsl:template>

</xsl:stylesheet>

can transform this file into this:

Photo: A sunset dinner on the Esplanade.
Subjects:
Esplanade
Sunset
Grand Canyon National Park
Arizona

Who Should Be Using It

Anyone who is working with XML. Initially, this includes large libraries of any type, many mid-sized libraries of all types, and even some small libraries.

More Information

General Information
A Focus on XSLT 2.0: Understanding the Development and Business Benefits - InfoTrends Cap Venture

Wikipedia entry on XSLT

Technical Sources
XSLT Tutorial
XSLT Reference