XML technologies / XSLT / XSLT Cookbook / From XML to text
(Excerpt from “XSLT Kochbuch” by Sal Mangano)
“Text processing has made it possible to right-justify any idea,
even one which cannot be justified on any other grounds.”
J. Finegan
Introduction
In the Internet age, XSL and XSLT output is dominated by formats such as HTML, XHTML, XML and PDF. Plain text, however, never goes out of fashion: it is the common denominator of human-readable and machine-readable formats. XML is often converted into text for import into applications that cannot read XML or do not interpret it as desired. Text output is also useful for terminals or further processing, for example in a Unix pipeline.
Many recipes here use XSLT techniques to create generic XML-to-text converters. Generic means they can easily be adapted to different XML inputs, different outputs, or both. The techniques can be applied beyond the individual recipes and often beyond text processing.
Of all formats supported by xsl:output, text requires the most careful handling of whitespace. This chapter therefore addresses the issue specifically in recipe Handle whitespace. Beginners in XML and XSLT often find whitespace handling inconsistent. Once the rules and ways of using them are understood, producing correctly formatted output becomes easier.
Generating source code from XML clearly falls within XML-to-text transformation, but involves more than transformation and formatting. Chapter Transform XML into HTML therefore treats code generation separately.
Copyright © 2006 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XSLT Kochbuch” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O'Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de