O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting the Value of Nodes with xsl:value-of

In this example, I'll extract the name of each planet and insert that name into the output document. To get the name of each planet, I'll use the <xsl:value-of> element in a template targeted at the <PLANET> element. I'll select the <NAME> element with the select attribute, like this:

Listing . ch13_07.xsl
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="PLANETS">
        <HTML>
            <xsl:apply-templates/>
        </HTML>
    </xsl:template>

    <xsl:template match="PLANET">
        <xsl:value-of select="NAME"/>
    </xsl:template>

</xsl:stylesheet>

Using select like this, you can select nodes. The select attribute is much like the match attribute of the <xsl:template> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required