In comparison with previous stylesheets the output remains unchanged, yet at the first time we are making use of some information which is present in the source XML document.
Element xsl:value-of always contains xsl:select attribute. Value of this attribute is an XPath which localizes elements in XML source document. The xsl:value-of element then selects all text inside these elements and sends them to the output.
The XPath value of select attribute selects the child of root node which have name "aaa". If the stylesheet is used for processing of XML documents which have element "aaa" as the root one, then the document is processed. If the source XML has any other XML element, an implicit processing will be initiated. It is probable that the result of this processing will be identical or very similar to the output provided by the matching "aaa" template in current example, but this is not common.
Please note that there will be no error message. It is not an error if a stylesheet contains templates which are not used during processing or if the stylesheet encounters elements in XML source for which no explicit template exists.
|
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="/"> <xsl:value-of select="/aaa"/> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa>Hello, world!</aaa> |
Output
Hello, world!
|
| Previous chapter: | - - - |
| Next chapter: | Sequences |
| Previous page: | Element xsl:text |
| Next page: | Element xsl:value-of |