WebReference.com - Excerpt from Inside XSLT, Chapter 2, Part 3 (2/5)
Literal Result Elements
If an element in a template body is not an XSL instruction or an extension element, then the XSLT processor must treat it as a literal result element. This means that an element must be treated literally and copied to the result tree (that is, copied to the output node tree created by the XSLT processor).
For example, in the following template body, the
<TD> element is a
literal result element, which will be copied to the output document:
<xsl:template match="RADIUS"> <TD>RADIUS</TD> </xsl:template>
Literal result elements may themselves have content, which is then treated as another template body and parsed by the XSLT processor. You'll see how this works later in this chapter.
Literal result elements may also have attributes, which are interpreted by the
XSLT processor. For example, you can use the
version attribute to specify that all XSLT elements
inside a literal result element must be XSLT version 1.0 elements, as follows:
<xsl:template match="RADIUS"> <TD xsl:version="1.0">RADIUS</TD> </xsl:template>
The following list includes all the possible literal result element attributes (note that they're all optional):
- Attribute Value Templates (optional). Any XPath expressions in curly braces are evaluated, and the string value of the result is copied to an attribute in the result tree. Set to an attribute value template (see Chapter 3).
xsl:exclude-result-prefixes(optional). Specifies which namespaces are not to be copied to the result tree. Set to a whitespace-separated list of namespace prefixes.
xsl:extension-element-prefixes(optional). Makes the XSLT processor treat child elements of the literal result element in the listed namespaces as extension elements rather than literal result elements.
xsl:use-attribute-sets(optional). The attributes in the listed attribute sets are added to the literal result element and copied to the result tree. Set to a list of
QNamesthat identify named
xsl:version(optional). Sets the version of XSL elements enclosed in the literal result element. Set to a number.
Now it's time to put this information to work.
Created: September 26, 2001
Revised: September 26, 2001