Skip to Content
XSLT
book

XSLT

by Doug Tidwell
August 2001
Intermediate to advanced
480 pages
11h 16m
English
O'Reilly Media, Inc.
Content preview from XSLT

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 &lt; and &gt; to their associated characters.

Here’s an <xsl:text> element with the normal setting and the results it generates:

<xsl:text>Hey, y&apos;all!</xsl:text>

Output:

Hey, y'all!

Here’s the same listing with output escaping disabled:

<xsl:text disable-output-escaping="yes">Hey, y&apos;all!</xsl:text>

Output:

Hey, y&apos;all!

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.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XSLT

Learning XSLT

Michael Fitzgerald
Inside XSLT

Inside XSLT

Steven Holzner
XSLT Cookbook

XSLT Cookbook

Sal Mangano

Publisher Resources

ISBN: 0596000537Supplemental ContentCatalog PageErrata