Table of contentsAppendices |
2.3 Literal Result Element as StylesheetLiteral Result Element as StylesheetA simplified syntax is allowed for stylesheets that consist of only
a single template for the root node. The stylesheet may consist of
just a literal result element (see [Literal Result Elements]). Such a stylesheet is equivalent to a
stylesheet with an <html xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<head>
<title>Expense Report Summary</title>
</head>
<body>
<p>Total Amount: <xsl:value-of select="expense-report/total"/></p>
</body>
</html>
has the same meaning as <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<xsl:template match="/">
<html>
<head>
<title>Expense Report Summary</title>
</head>
<body>
<p>Total Amount: <xsl:value-of select="expense-report/total"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
A literal result element that is the document element of a
stylesheet must have an The allowed content of a literal result element when used as a stylesheet is no different from when it occurs within a stylesheet. Thus, a literal result element used as a stylesheet cannot contain Top-level elements. In some situations, the only way that a system can recognize that an XML document needs to be processed by an XSLT processor as an XSLT stylesheet is by examining the XML document itself. Using the simplified syntax makes this harder. NOTE: Therefore, the simplified syntax should not be used for XSLT
stylesheets that may be used in such a situation. This situation can,
for example, arise when an XSLT stylesheet is transmitted as a message
with a MIME media type of |