The <xsl:value-of> element writes the string value of an expression to the result document; in particular, you can use it to return the value of a node, which, for an element, is the elements enclosed text.
You can assign the <xsl:value-of> elements select attribute an XPath expression that specifies a node or node set. When youre in the template that matches <PLANET> elements, you can use the XPath expression "child::MASS" to refer to the <MASS> child element. As youll see in Chapter 4, you can abbreviate XPath expressions in a number of ways, and in particular, "child::MASS" can also be written simply as "MASS" . That means you can recover the data from the child elements such as <MASS> , <DAY> , and so on in this way:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/PLANETS"> <HTML> <HEAD> <TITLE> The Planets Table </TITLE> </HEAD> <BODY> <H1> The Planets Table </H1> <TABLE BORDER="2"> <TR> <TD>Name</TD> <TD>Mass</TD> <TD>Radius</TD> <TD>Day</TD> </TR> <xsl:apply-templates/> </TABLE> </BODY> </HTML> </xsl:template> <xsl:template match="PLANET"> <TR> <TD><xsl:value-of select="NAME"/></TD> <TD><xsl:value-of select="MASS"/></TD> <TD><xsl:value-of select="RADIUS"/></TD> <TD><xsl:value-of select="DAY"/></TD> </TR> </xsl:template> </xsl:stylesheet>