1.8. Transformation

It may sound like something out of science fiction, but transforming documents is an important part of XML. An XML transformation is a process that rearranges parts of a document into a new form. The result is still XML, but it may be radically different from the original. Think of it as a food processor for information.

One purpose of transforming a document is to convert from one XML application to another. For example, suppose you have written a document in an XML application you invented. The document cannot be viewed in older browsers that understand only HTML, but you can transform it into XHTML through a transformation. This retains all the content while changing the markup, and allows your document to be viewed even by HTML-only browsers.

Transformation can also be used to filter a document, retaining only a portion of the original. You can generate excerpts or summaries of a document, for example to total up your expenditures in a checkbook or print the section titles of a book to generate a table of contents.

Documents are transformed by using the Extensible Style Language for Transformations (XSLT). You write XSLT transformation instructions in a document resembling a stylesheet, and then use a transformation engine to generate a result.

1.8.1. Transformation Engines

The following are a few useful transformation engines that can be used with XSLT to transform XML documents:

XT

This fast and simple transformation engine was written in Java by ...

Get Learning XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.