D.13. How Do I Control Angle Brackets and Quote Marks in My Output?
The XML 1.0 Specification defines five entities you can use to generate special characters: the apostrophe, or single quote mark (defined as '); the ampersand (defined as &); the less-than sign, or left angle bracket (defined as <); the double-quote mark (defined as "); and the greater-than sign, or right angle bracket (defined as >). You can use these entities to output one of these special symbols without an eager XML parser attempting to process them as metacharacters along the way.
If using the predefined entities doesn't do the trick, use the disable-output-escaping attribute of the <xsl:text> element. If you set this attribute to yes, the XSLT processor will not convert entities such as < and > to their associated characters.
Here's an <xsl:text> element with the normal setting and the results it generates:
Here's the same listing with output escaping disabled:
<xsl:text disable-output-escaping="yes">Hey, y'all!</xsl:text>
Be aware that the disable-output-escaping attribute may not be supported by all XSLT processors, and it may result in XML that is not well formed. For these reasons, the XSLT specification advises that disable-output-escaping "should be used only when there is no alternative."
Copyright © 2002 O'Reilly & Associates. All rights reserved.