The title of this page sounds formidable but under this unfortunate term is hidden a very simple feature which is used in almost every stylesheet.
Literal results elements are all elements in the stylesheet which do not belong to the XSLT namespace (and are not extension instructions). These elements are copied together with their attributes to the output and we are using this feature from the beginning of this tutorial.
In this example the elements xxx, yyy, and zzz are literal result elements while e.g. xsl:template or xsl:value-of are not.
|
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="/*"> <xxx> <yyy r="a" s="b"> <zzz> <xsl:value-of select="."/> </zzz> </yyy> </xxx> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa>111</aaa> |
Output
<xxx> <yyy r="a" s="b"> <zzz>111</zzz> </yyy> </xxx> |
| Previous chapter: | Conditional Expressions |
| Next chapter: | Groups |
| Previous page: | - - - |
| Next page: | Usage of XPath in the attribute values - curly brackets {} |