Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Content
A text node. The element may also be empty. It must not contain other elements such as
Effect
Text appearing within a sequence constructor in the stylesheet is copied to the result sequence (in the form of a new text node), whether it is enclosed by
The
disable-output-escaping
attribute controls whether special characters such as
<
should be escaped (that is, converted to a character reference or entity reference such as
<
) if they appear in the text. The default value is
no
. This attribute is deprecated but is retained for backward compatibility with XSLT 1.0; for further information, see page 945 in Chapter 15.
Usage
There are two main reasons for using
disable-output-escaping
attribute is deprecated in XSLT 2.0, but there are still cases where it is useful; for details, see Chapter 15. The following section describes the more orthodox use of
Whitespace Control
The most obvious case where
the space between the first name and the last name will be lost, because it is part of a node that contains whitespace only (a single space character). To force a space to appear between the first name and the last name, write:
The arrangement on three lines here is purely for readability, but it does not affect the output, because the newline characters are now in whitespace-only nodes that will not be output.
If you find this long-winded, another way of achieving the same effect is to write:
The other aspect of the problem is to prevent the output of unwanted whitespace. Fortunately in HTML output extra whitespace usually doesn't matter, because the browser will ignore it. For XML or text output, however, avoiding unwanted whitespace can be important.
If you are suffering from excess whitespace in your output, the first thing to establish is whether it comes from the source document or from the stylesheet. If the whitespace is adjacent to text copied from the source document, then it probably comes from the source document, but if it is adjacent to text that appears in the stylesheet, then this is the most likely source. Check also that the unwanted whitespace isn't coming from the serializer, by setting
If the unwanted whitespace comes from the source document, consider using
normalize-space()
function to remove leading and trailing spaces around visible text.
The
[
The intention here is to output a stage direction enclosed in square brackets. But the text nodes containing the opening and closing square brackets also contain a newline character and several spaces, which will be written to the output destination along with the brackets themselves. To prevent this behavior, the simplest way is to wrap an