Introduction


In the age of the Internet, formats such as HTML, XHTML, XML, and PDF clearly dominate the output of XSL and XSLT. However, plain old text will never become obsolete because it is the lowest common denominator in both human- and machine-readable formats. XML is often converted to text for import into another application that does not know how to read XML or does not interpret it the way you prefer. Text output is also used when the result will be sent to a terminal or post-processed in, for example, a Unix pipeline.

Many examples in this section focus on XSLT techniques that create generic XML-to-text converters. Here, generic means that the transformation can be customized easily to work on many different XML inputs or produce a variety of outputs, or both. The techniques employed in these examples have application beyond the specifics of a given recipe and often beyond the domain of text processing. In particular, you may want to look at Recipe 7.2 through Recipe 7.5, even if they do not address a present need.

Of all the output formats supported by xsl:output, text is the one for which managing whitespace is the most crucial. For this reason, this chapter addresses the issue separately in Recipe 7.1. Developers inexperienced in XML and XSLT are often vexed by what seems like fickle treatment of whitespace. However, once you understand the rules and techniques for exploiting the rules, it is easier to create output that is formatted correctly.

Source-code generation from XML is arguably in the domain of XML-to-text transformation. However, code generation involves issues that transcend mere transformation and formatting. Chapter 10 will deal with code generation as a subject unto itself.




XSLT Cookbook
XSLT Cookbook: Solutions and Examples for XML and XSLT Developers, 2nd Edition
ISBN: 0596009747
EAN: 2147483647
Year: 2003
Pages: 208
Authors: Sal Mangano

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net