Dealing with Whitespace

One of the challenges of working with any XML document is processing whitespace, especially when want want to generate output other than HTML. As we noted earlier, an HTML browser renders both of these paragraphs the same way:

<p>
   This document contains 
   5
   chapters.
   
</p>
<p>This document contains 5 chapters.</p>

If we generated these two paragraphs as text, however, they would appear as differently in print as they do in the HTML source. We’ll look at several techniques for controlling whitespace in this section.

Get XSLT, 2nd Edition 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.